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.String
APPLY
Special method name, that causes a Protelis function invocation if the left hand side of theInvoke
is 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.Object
evaluate(ExecutionContext context)
Evaluates this AST node.Bytecode
getBytecode()
ProtelisAST<?>
getLeftExpression()
java.lang.String
getName()
protected boolean
isNullable()
java.lang.String
toString()
-
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 theInvoke
is 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
- AMetadata
object 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 aFunctionDefinition
or a @JVMEntity
of type Method.args
- the arguments
-
-
Method Detail
-
evaluate
public java.lang.Object evaluate(ExecutionContext context)
Description copied from class:AbstractProtelisAST
Evaluates this AST node. This method can throw any exception,AbstractProtelisAST
takes care of storing the necessary metadata.- Specified by:
evaluate
in classAbstractProtelisAST<java.lang.Object>
- Parameters:
context
- the execution context- Returns:
- the result of the evaluation
-
getLeftExpression
public ProtelisAST<?> getLeftExpression()
- Returns:
- the
ProtelisAST
representing the invocation receiver
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceProtelisAST<java.lang.Object>
- Overrides:
getName
in classAbstractProtelisAST<java.lang.Object>
- Returns:
- The name of the operation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractProtelisAST<java.lang.Object>
-
isNullable
protected boolean isNullable()
- Overrides:
isNullable
in classAbstractProtelisAST<java.lang.Object>
- Returns:
- true if this node can get annotated with null values - namely, if it is an interaction with Java
-
-