Skip to content

Commit 1e5f661

Browse files
committed
Rename Heap.write to Heap.writeUnion
1 parent 8bfc293 commit 1e5f661

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

+12-12
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ object Objects:
470470

471471
/** Store the heap as a mutable field to avoid threading it through the program. */
472472
class MutableData(private[Heap] var heap: Data):
473-
private[Heap] def update(addr: Addr, value: Value): Unit =
473+
private[Heap] def writeUnion(addr: Addr, value: Value): Unit =
474474
heap.get(addr) match
475475
case None =>
476476
heap = heap.updated(addr, value)
@@ -489,8 +489,8 @@ object Objects:
489489
def read(addr: Addr)(using mutable: MutableData): Value =
490490
mutable.heap(addr)
491491

492-
def write(addr: Addr, value: Value)(using mutable: MutableData): Unit =
493-
mutable.update(addr, value)
492+
def writeUnion(addr: Addr, value: Value)(using mutable: MutableData): Unit =
493+
mutable.writeUnion(addr, value)
494494

495495
def localVarAddr(regions: Regions.Data, sym: Symbol, owner: ClassSymbol): Addr =
496496
LocalVarAddr(regions, sym, owner)
@@ -639,7 +639,7 @@ object Objects:
639639
if arr.addr.owner != State.currentObject then
640640
errorMutateOtherStaticObject(State.currentObject, arr.addr.owner)
641641
else
642-
Heap.write(arr.addr, args.tail.head.value)
642+
Heap.writeUnion(arr.addr, args.tail.head.value)
643643
Bottom
644644
else
645645
// Array.length is OK
@@ -660,7 +660,7 @@ object Objects:
660660
if target.isOneOf(Flags.Method) then
661661
if target.owner == defn.ArrayModuleClass && target.name == nme.apply then
662662
val arr = OfArray(State.currentObject, summon[Regions.Data])
663-
Heap.write(arr.addr, args.map(_.value).join)
663+
Heap.writeUnion(arr.addr, args.map(_.value).join)
664664
arr
665665
else if target.hasSource then
666666
val cls = target.owner.enclosingClass.asClass
@@ -846,7 +846,7 @@ object Objects:
846846
if addr.owner != State.currentObject then
847847
errorMutateOtherStaticObject(State.currentObject, addr.owner)
848848
else
849-
Heap.write(addr, rhs)
849+
Heap.writeUnion(addr, rhs)
850850
else
851851
report.warning("Mutating a field before its initialization: " + field.show + ". Calling trace:\n" + Trace.show, Trace.position)
852852
end match
@@ -871,7 +871,7 @@ object Objects:
871871
case outer: (Ref | Cold.type | Bottom.type) =>
872872
if klass == defn.ArrayClass then
873873
val arr = OfArray(State.currentObject, summon[Regions.Data])
874-
Heap.write(arr.addr, Bottom)
874+
Heap.writeUnion(arr.addr, Bottom)
875875
arr
876876
else
877877
// Widen the outer to finitize the domain. Arguments already widened in `evalArgs`.
@@ -907,7 +907,7 @@ object Objects:
907907
if sym.is(Flags.Mutable) then
908908
val addr = Heap.localVarAddr(summon[Regions.Data], sym, State.currentObject)
909909
Env.setLocalVar(sym, addr)
910-
Heap.write(addr, value)
910+
Heap.writeUnion(addr, value)
911911
else
912912
Env.setLocalVal(sym, value)
913913
}
@@ -968,8 +968,8 @@ object Objects:
968968
* @param value The value of the rhs of the assignment.
969969
*/
970970
def writeLocal(thisV: ThisValue, sym: Symbol, value: Value): Contextual[Value] = log("write local " + sym.show + " with " + value.show, printer, (_: Value).show) {
971-
972971
assert(sym.is(Flags.Mutable), "Writing to immutable variable " + sym.show)
972+
973973
Env.resolveEnv(sym.enclosingMethod, thisV, summon[Env.Data]) match
974974
case Some(thisV -> env) =>
975975
given Env.Data = env
@@ -978,7 +978,7 @@ object Objects:
978978
if addr.owner != State.currentObject then
979979
errorMutateOtherStaticObject(State.currentObject, addr.owner)
980980
else
981-
Heap.write(addr, value)
981+
Heap.writeUnion(addr, value)
982982
case _ =>
983983
report.warning("[Internal error] Variable not found " + sym.show + "\nenv = " + env.show + ". Calling trace:\n" + Trace.show, Trace.position)
984984

@@ -1541,7 +1541,7 @@ object Objects:
15411541
if acc.is(Flags.Mutable) then
15421542
val addr = Heap.fieldVarAddr(summon[Regions.Data], acc, State.currentObject)
15431543
thisV.initVar(acc, addr)
1544-
Heap.write(addr, value)
1544+
Heap.writeUnion(addr, value)
15451545
else
15461546
thisV.initVal(acc, value)
15471547
printer.println(acc.show + " initialized with " + value)
@@ -1636,7 +1636,7 @@ object Objects:
16361636
if sym.is(Flags.Mutable) then
16371637
val addr = Heap.fieldVarAddr(summon[Regions.Data], sym, State.currentObject)
16381638
thisV.initVar(sym, addr)
1639-
Heap.write(addr, res)
1639+
Heap.writeUnion(addr, res)
16401640
else
16411641
thisV.initVal(sym, res)
16421642

0 commit comments

Comments
 (0)