public final class AssignmentStatement extends GoloAssignment<AssignmentStatement> implements ToplevelGoloElement
An assignment is a statement like:
var foo = 42
let bar = a(more: complex()) + expression
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
static AssignmentStatement |
create()
Creates a uninitialized assignment.
|
static AssignmentStatement |
create(java.lang.Object ref,
java.lang.Object value,
java.lang.Object declaring)
Full assignment creation in one call.
|
LocalReference |
getLocalReference() |
LocalReference[] |
getReferences()
Returns the references contained in this element.
|
int |
getReferencesCount()
Returns the number of references contained in this element.
|
boolean |
isConstant()
Checks if this assignment is constant.
|
protected AssignmentStatement |
self() |
AssignmentStatement |
to(java.lang.Object... refs)
Defines the references to which assign the expression.
|
java.lang.String |
toString() |
AssignmentStatement |
variable()
Makes this assignment variable.
|
as, children, declaring, declaring, expression, getDeclaringReferences, isDeclaring, replaceElement
of
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static AssignmentStatement create(java.lang.Object ref, java.lang.Object value, java.lang.Object declaring)
A lot less readable than the fluent API, but useful when doing meta-generation
ref
- the reference to assign to (to(Object...)
).value
- the value to assign (GoloAssignment.as(Object)
).declaring
- whether the assignment is a declaring one.public static AssignmentStatement create()
protected AssignmentStatement self()
self
in class GoloElement<AssignmentStatement>
public LocalReference getLocalReference()
public AssignmentStatement variable()
variable
in class GoloAssignment<AssignmentStatement>
LocalReference.variable()
public boolean isConstant()
isConstant
in class GoloAssignment<AssignmentStatement>
LocalReference.isConstant()
public LocalReference[] getReferences()
getReferences
in interface ReferencesHolder
public int getReferencesCount()
getReferencesCount
in interface ReferencesHolder
public AssignmentStatement to(java.lang.Object... refs)
This is a builder method.
For instance, code like:
foo = 42
can be generated by:
assign(constant(42)).to(localRef("foo"))
or using implicit conversions:
assign(42).to("foo")
to
in class GoloAssignment<AssignmentStatement>
refs
- the LocalReference
s to assign topublic java.lang.String toString()
toString
in class java.lang.Object
public void accept(GoloIrVisitor visitor)
This method should only call the visitor visitXXXX
method.
The children of this node will be visited by the
GoloElement.walk(GoloIrVisitor)
method.
accept
in class GoloElement<AssignmentStatement>