public final class GoloFunction extends ExpressionStatement<GoloFunction> implements BlockContainer<GoloFunction>, ToplevelGoloElement
Such as
function foo = |x| -> x + 1
Modifier and Type | Class and Description |
---|---|
static class |
GoloFunction.Scope |
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
void |
addDecorator(Decorator decorator) |
void |
addSyntheticParameters(java.util.Set<java.lang.String> names) |
GoloFunction |
asClosure() |
ClosureReference |
asClosureReference() |
GoloFunction |
block(java.lang.Object block)
Defines the contained block.
|
void |
captureClosedReference() |
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
GoloFunction |
createDecorator() |
GoloFunction |
decoratedWith(java.lang.Object... decorators)
Adds decorators to this function.
|
GoloFunction |
decorator() |
GoloFunction |
decorator(boolean d) |
boolean |
equals(java.lang.Object obj) |
static GoloFunction |
function(java.lang.Object name)
Creates a function declaration.
|
int |
getArity() |
Block |
getBlock() |
java.lang.String |
getDecoratorRef() |
java.util.List<Decorator> |
getDecorators() |
java.lang.String |
getName() |
java.util.List<java.lang.String> |
getParameterNames() |
int |
getSyntheticParameterCount() |
java.util.Collection<java.lang.String> |
getSyntheticParameterNames() |
java.lang.String |
getSyntheticSelfName() |
LocalReference |
getSyntheticSelfReference() |
int |
hashCode() |
GoloFunction |
inAugment() |
GoloFunction |
inAugment(boolean isInAugment) |
GoloFunction |
inScope(GoloFunction.Scope s) |
void |
insertMissingReturnStatement() |
boolean |
isAnonymous() |
boolean |
isDecorated() |
boolean |
isDecorator() |
boolean |
isInAugment() |
boolean |
isInModule() |
boolean |
isLocal() |
boolean |
isMain() |
boolean |
isModuleInit() |
boolean |
isSynthetic() |
boolean |
isVarargs() |
GoloFunction |
local() |
GoloFunction |
local(boolean isLocal) |
GoloFunction |
name(java.lang.String n) |
java.lang.Object[] |
parametersAsRefs()
Return the parameters of this function wrapped in a
ReferenceLookup . |
void |
removeDecorator(Decorator decorator) |
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
GoloFunction |
returns(java.lang.Object expression) |
GoloFunction |
sameSignature()
Return a new function with the same signature as this one.
|
protected GoloFunction |
self() |
void |
setSyntheticSelfName(java.lang.String name) |
GoloFunction |
synthetic() |
GoloFunction |
synthetic(boolean s) |
java.lang.String |
toString() |
static java.lang.String |
uniqueName() |
static java.lang.String |
uniqueName(java.lang.Object base) |
GoloFunction |
varargs() |
GoloFunction |
varargs(boolean isVarargs) |
GoloFunction |
withParameters(java.util.Collection<?> names) |
GoloFunction |
withParameters(java.lang.Object... names) |
call, clearDeclarations, declarations, hasLocalDeclarations, of, with
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
body
protected GoloFunction self()
self
in class GoloElement<GoloFunction>
public static GoloFunction function(java.lang.Object name)
Typical usage:
function("foo").withParameters("x").returns(plus(ReferenceLookup.of("x"), constant(1)))
creates
function foo = |x| -> x + 1
public GoloFunction name(java.lang.String n)
public java.lang.String getName()
public boolean isMain()
public boolean isModuleInit()
public boolean isAnonymous()
public GoloFunction synthetic(boolean s)
public GoloFunction synthetic()
public boolean isSynthetic()
public GoloFunction decorator()
public GoloFunction decorator(boolean d)
public boolean isDecorator()
public GoloFunction local()
public GoloFunction local(boolean isLocal)
public boolean isLocal()
public GoloFunction inScope(GoloFunction.Scope s)
public GoloFunction inAugment()
public GoloFunction inAugment(boolean isInAugment)
public boolean isInAugment()
public boolean isInModule()
public GoloFunction asClosure()
public GoloFunction block(java.lang.Object block)
This is a builder method.
block
in interface BlockContainer<GoloFunction>
block
- an object that can be converted into a Block
Block.of(Object)
public Block getBlock()
getBlock
in interface BlockContainer<GoloFunction>
public GoloFunction returns(java.lang.Object expression)
public void insertMissingReturnStatement()
public GoloFunction varargs(boolean isVarargs)
public GoloFunction varargs()
public boolean isVarargs()
public int getArity()
public GoloFunction withParameters(java.lang.Object... names)
public GoloFunction withParameters(java.util.Collection<?> names)
public int getSyntheticParameterCount()
public java.util.List<java.lang.String> getParameterNames()
public java.util.Collection<java.lang.String> getSyntheticParameterNames()
public void addSyntheticParameters(java.util.Set<java.lang.String> names)
public java.lang.String getSyntheticSelfName()
public LocalReference getSyntheticSelfReference()
public void setSyntheticSelfName(java.lang.String name)
public void captureClosedReference()
public GoloFunction decoratedWith(java.lang.Object... decorators)
The objects are converted into a decorator if needed.
public boolean isDecorated()
public java.lang.String getDecoratorRef()
public void addDecorator(Decorator decorator)
public void removeDecorator(Decorator decorator)
public java.util.List<Decorator> getDecorators()
public GoloFunction createDecorator()
public ClosureReference asClosureReference()
public GoloFunction sameSignature()
Can be used to generate a wrapper for a given function for instance.
public java.lang.Object[] parametersAsRefs()
ReferenceLookup
.public java.lang.String toString()
toString
in class java.lang.Object
public void accept(GoloIrVisitor visitor)
GoloElement
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<GoloFunction>
public java.util.List<GoloElement<?>> children()
GoloElement
children
in class GoloElement<GoloFunction>
protected void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
GoloElement
Replace original
with newElement
if original
is a child of this node
and type matches.
replaceElement
in class GoloElement<GoloFunction>
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)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static java.lang.String uniqueName()
public static java.lang.String uniqueName(java.lang.Object base)