public abstract class ExpressionStatement<T extends ExpressionStatement<T>> extends GoloStatement<T>
Constructor and Description |
---|
ExpressionStatement() |
Modifier and Type | Method and Description |
---|---|
BinaryOperation |
call(java.lang.Object... arguments)
Creates an binary operation representing the anonymous call on this expression.
|
void |
clearDeclarations()
Removes all local declarations.
|
GoloAssignment<?>[] |
declarations()
Returns the local declarations of this expression if any.
|
boolean |
hasLocalDeclarations()
Checks if this expression has local variable declarations.
|
static ExpressionStatement<?> |
of(java.lang.Object expr)
Expression coercion.
|
T |
with(java.lang.Object a)
Defines a variable declaration (assignment) local to this expression.
|
accept, ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, 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, replaceElement, replaceInParentBy, self, walk
public ExpressionStatement()
public T with(java.lang.Object a)
public GoloAssignment<?>[] declarations()
public boolean hasLocalDeclarations()
public void clearDeclarations()
public BinaryOperation call(java.lang.Object... arguments)
For instance, code such as:
(|x| -> x + 2)(40)
actually creates a BinaryOperation
or type OperatorType.ANON_CALL
whose first argument is a ClosureReference
and the second one a FunctionInvocation
holding the
argument.
This method ease the creation of such a node.
This expression must return a FunctionReference
when evaluated. This is not checked.
For instance, in code like
let f = |x| -> |y| -> x * y
f(2)(42)
the call is an anonymous call between f(2)
and (42)
, and can be generated by:
call("f").withArgs(constant(2)).call(constant(42))
See also the Golo guide.
public static ExpressionStatement<?> of(java.lang.Object expr)
If the given value is an expression, casts it. If it's a literal value, returns a ConstantStatement
.
If it's a LocalReference
, creates a ReferenceLookup
from it.
ConstantStatement.isLiteralValue(Object)