Record Class ReferenceAssignment
java.lang.Object
java.lang.Record
org.ek9lang.compiler.support.ReferenceAssignment
- Record Components:
target- the variable now holding the reference.source- the expression whose object it refers to.
public record ReferenceAssignment(ISymbol target, EK9Parser.ExpressionContext source)
extends Record
THE reading of a statement that makes a local variable (never a property) refer to the SAME
object an expression evaluates to - a reference copy (an alias), never a value copy. Use this wherever a check must
follow an object through a local name, rather than re-deriving which operators alias.
Two statement shapes alias:
- A declaration by
<-,:=,=or:(:~:merges into a new object and does not). - An assignment to a bare identifier by a pointer assignment, as
OperationIsAssignmentdefines it (:=,=,:,:=?). The in-place operators (+=,:=:,:~:, ...) mutate the object the target already refers to and create no new reference.
Used by the constructor this-escape check (E08250, phase 3) and the shared-state mutation
check (E08251, phase 5): both were defeated by other <- this / counter <- shared.total
followed by use of the local.
-
Constructor Summary
ConstructorsConstructorDescriptionReferenceAssignment(ISymbol target, EK9Parser.ExpressionContext source) Creates an instance of aReferenceAssignmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static booleanTrue when the assignment statement mutates, in place, the object its target refers to (+=,:=:,:~:, ...), rather than re-pointing the target.static Optional<ReferenceAssignment> of(EK9Parser.AssignmentStatementContext ctx, SymbolsAndScopes symbolsAndScopes) The reference an assignment statement creates, if it creates one.static Optional<ReferenceAssignment> of(EK9Parser.VariableDeclarationContext ctx, SymbolsAndScopes symbolsAndScopes) The reference a variable declaration creates, if it creates one.source()Returns the value of thesourcerecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
public static Optional<ReferenceAssignment> of(EK9Parser.VariableDeclarationContext ctx, SymbolsAndScopes symbolsAndScopes) The reference a variable declaration creates, if it creates one. -
of
public static Optional<ReferenceAssignment> of(EK9Parser.AssignmentStatementContext ctx, SymbolsAndScopes symbolsAndScopes) The reference an assignment statement creates, if it creates one. -
mutatesInPlace
True when the assignment statement mutates, in place, the object its target refers to (+=,:=:,:~:, ...), rather than re-pointing the target. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
target
-
source
-