public final class LocalReference extends GoloElement<LocalReference>
A reference is ether a variable (as defined by var answer = 42
) or a constant
(as defined by let answer = 42
).
Modifier and Type | Class and Description |
---|---|
static class |
LocalReference.Kind |
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
static LocalReference |
create(java.lang.Object name,
LocalReference.Kind kind) |
boolean |
equals(java.lang.Object o) |
static LocalReference |
generate()
Creates a new local reference with a generated unique name.
|
static LocalReference |
generate(java.lang.String prefix) |
int |
getIndex()
Internal API
|
LocalReference.Kind |
getKind() |
java.lang.String |
getName() |
int |
hashCode() |
LocalReference |
index(int index) |
boolean |
isConstant() |
boolean |
isModuleState() |
boolean |
isSynthetic() |
LocalReference |
kind(LocalReference.Kind k) |
ReferenceLookup |
lookup()
Returns a
ReferenceLookup referencing this variable. |
LocalReference |
moduleLevel() |
static LocalReference |
of(java.lang.Object name)
Creates a local reference.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected LocalReference |
self() |
void |
setIndex(int index)
Internal API
|
LocalReference |
synthetic() |
LocalReference |
synthetic(boolean isSynthetic) |
java.lang.String |
toString() |
LocalReference |
variable() |
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, inheritedMetadata, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static LocalReference of(java.lang.Object name)
If the argument is already a local reference, it is returned unchanged, otherwise, its string representation is used to name the reference.
name
- the name of the referencepublic static LocalReference generate()
public static LocalReference generate(java.lang.String prefix)
public static LocalReference create(java.lang.Object name, LocalReference.Kind kind)
protected LocalReference self()
self
in class GoloElement<LocalReference>
public LocalReference.Kind getKind()
public LocalReference variable()
public LocalReference moduleLevel()
public LocalReference kind(LocalReference.Kind k)
public java.lang.String getName()
public LocalReference synthetic(boolean isSynthetic)
public LocalReference synthetic()
public boolean isSynthetic()
public boolean isModuleState()
public boolean isConstant()
public int getIndex()
public void setIndex(int index)
public LocalReference index(int index)
public ReferenceLookup lookup()
ReferenceLookup
referencing this variable.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
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<LocalReference>
protected void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
Replace original
with newElement
if original
is a child of this node
and type matches.
replaceElement
in class GoloElement<LocalReference>
original
- the original value to replace. Must be a child of this nodenewElement
- the element to replace with. Type must match.GoloElement.cantReplace()
,
GoloElement.cantReplace(GoloElement, GoloElement)
,
GoloElement.doesNotContain(GoloElement)
,
GoloElement.cantConvert(String, Object)