public final class FunctionInvocation extends AbstractInvocation<FunctionInvocation>
usesNamedArguments
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
FunctionInvocation |
constant() |
FunctionInvocation |
constant(boolean isConstant) |
protected FunctionInvocation |
copy() |
static FunctionInvocation |
create(java.lang.String name,
boolean onReference,
boolean onModuleState,
boolean constant,
java.lang.Object... args)
Full function invocation creation in one call.
|
boolean |
isAnonymous()
Checks if this call is anonymous.
|
boolean |
isConstant() |
boolean |
isOnModuleState() |
boolean |
isOnReference() |
static FunctionInvocation |
of(java.lang.Object name)
Calls a function by name.
|
FunctionInvocation |
onModuleState() |
FunctionInvocation |
onModuleState(boolean isOnModuleState) |
FunctionInvocation |
onReference()
Define this call as being on a reference.
|
FunctionInvocation |
onReference(boolean isOnReference)
Define this call as being on a reference or not.
|
protected FunctionInvocation |
self() |
java.lang.String |
toString() |
FunctionInvocation |
withArgs(java.lang.Object... arguments)
Defines the values of the arguments for this invocation.
|
children, getArguments, getArity, getFunctionName, getModuleName, getName, getPackageAndClass, namedArgumentsComplete, replaceElement, setPackageAndClass, usesNamedArguments, withNamedArguments
call, clearDeclarations, declarations, hasLocalDeclarations, 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
public static FunctionInvocation create(java.lang.String name, boolean onReference, boolean onModuleState, boolean constant, java.lang.Object... args)
A lot less readable than the fluent API, but useful when doing meta-generation
name
- the name of the function to callonReference
- tells if the call is on a referenceonModuleState
- tells if the call in on a module level variableconstant
- tells if the call is constant (banged)args
- the call argumentsof(Object)
public static FunctionInvocation of(java.lang.Object name)
Typical usage:
FunctionInvocation.of("foo").withArgs(constant("answer "), constant(42))
creates
foo("answer ", 42)
name
- the name of the function to call, a GoloFunction
, a ReferenceLookup
or a java.lang.reflect.Method
protected FunctionInvocation self()
self
in class GoloElement<FunctionInvocation>
public FunctionInvocation onReference(boolean isOnReference)
For instance in:
let f = |x| -> x + 2
f(40)
the call to f
is on a reference.public FunctionInvocation onReference()
onReference(true)
.public boolean isOnReference()
public boolean isAnonymous()
For instance, in:
f("answer")(42)
the call with 42
is an anonymous one.public FunctionInvocation onModuleState(boolean isOnModuleState)
public FunctionInvocation onModuleState()
public boolean isOnModuleState()
public FunctionInvocation constant(boolean isConstant)
public FunctionInvocation constant()
public boolean isConstant()
protected FunctionInvocation copy()
public FunctionInvocation withArgs(java.lang.Object... arguments)
This is a builder method.
This methods appends the arguments to the existing ones, so that it can be called multiple times to create the invocation incrementally. On the other hand, it is not idempotent.
Calls AbstractInvocation.withNamedArguments()
if needed.
withArgs
in class AbstractInvocation<FunctionInvocation>
arguments
- the arguments of the invocation. An argument can be any GoloElement
, or are converted with
ExpressionStatement.of(Object)
otherwise, so that strings and primitives are automatically wrapped in a
ConstantStatement
.AbstractInvocation.withNamedArguments()
,
ExpressionStatement.of(Object)
public 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<FunctionInvocation>