Class Invoke
- java.lang.Object
-
- org.protelis.lang.interpreter.impl.AbstractProtelisAST<java.lang.Object>
-
- org.protelis.lang.interpreter.impl.Invoke
-
- All Implemented Interfaces:
java.io.Serializable,ProtelisAST<java.lang.Object>,WithBytecode
public final class Invoke extends AbstractProtelisAST<java.lang.Object>
Call an external Java non-static method.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPLYSpecial method name, that causes a Protelis function invocation if the left hand side of theInvokeis aFunctionDefinition.
-
Constructor Summary
Constructors Constructor Description Invoke(ProtelisAST<?> target, java.util.List<ProtelisAST<?>> args)Builds a newAPPLY.Invoke(Metadata metadata, java.lang.String name, ProtelisAST<?> target, java.util.List<ProtelisAST<?>> args)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectevaluate(ExecutionContext context)Evaluates this AST node.BytecodegetBytecode()ProtelisAST<?>getLeftExpression()java.lang.StringgetName()protected booleanisNullable()java.lang.StringtoString()-
Methods inherited from class org.protelis.lang.interpreter.impl.AbstractProtelisAST
branchesToString, branchesToString, eval, forEach, forEachWithIndex, getBranch, getBranches, getBranchesNumber, getMetadata, stringFor
-
-
-
-
Field Detail
-
APPLY
public static final java.lang.String APPLY
Special method name, that causes a Protelis function invocation if the left hand side of theInvokeis aFunctionDefinition.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Invoke
public Invoke(Metadata metadata, java.lang.String name, ProtelisAST<?> target, java.util.List<ProtelisAST<?>> args)
- Parameters:
metadata- AMetadataobject containing information about the code that generated this AST node.name- function (or method) nametarget- Protelis sub-program that annotates itself with the target of this callargs- arguments of the function
-
Invoke
public Invoke(ProtelisAST<?> target, java.util.List<ProtelisAST<?>> args)
Builds a newAPPLY.- Parameters:
target- the target of the invocation, must evaluate to either aFunctionDefinitionor a @JVMEntityof type Method.args- the arguments
-
-
Method Detail
-
evaluate
public java.lang.Object evaluate(ExecutionContext context)
Description copied from class:AbstractProtelisASTEvaluates this AST node. This method can throw any exception,AbstractProtelisASTtakes care of storing the necessary metadata.- Specified by:
evaluatein classAbstractProtelisAST<java.lang.Object>- Parameters:
context- the execution context- Returns:
- the result of the evaluation
-
getLeftExpression
public ProtelisAST<?> getLeftExpression()
- Returns:
- the
ProtelisASTrepresenting the invocation receiver
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceProtelisAST<java.lang.Object>- Overrides:
getNamein classAbstractProtelisAST<java.lang.Object>- Returns:
- The name of the operation
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractProtelisAST<java.lang.Object>
-
isNullable
protected boolean isNullable()
- Overrides:
isNullablein classAbstractProtelisAST<java.lang.Object>- Returns:
- true if this node can get annotated with null values - namely, if it is an interaction with Java
-
-