Class Constant<T>
- java.lang.Object
-
- org.protelis.lang.interpreter.impl.AbstractProtelisAST<T>
-
- org.protelis.lang.interpreter.impl.Constant<T>
-
- Type Parameters:
T
- the type of the constant
- All Implemented Interfaces:
java.io.Serializable
,ProtelisAST<T>
,WithBytecode
- Direct Known Subclasses:
NumericConstant
public class Constant<T> extends AbstractProtelisAST<T>
An arbitrary object-valued constant.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
evaluate(ExecutionContext context)
Evaluates this AST node.Bytecode
getBytecode()
T
getConstantValue()
java.lang.String
getName()
java.lang.String
toString()
-
Methods inherited from class org.protelis.lang.interpreter.impl.AbstractProtelisAST
branchesToString, branchesToString, eval, forEach, forEachWithIndex, getBranch, getBranches, getBranchesNumber, getMetadata, isNullable, stringFor
-
-
-
-
Method Detail
-
evaluate
public final T 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<T>
- Parameters:
context
- the execution context- Returns:
- the result of the evaluation
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceProtelisAST<T>
- Overrides:
getName
in classAbstractProtelisAST<T>
- Returns:
- The name of the operation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractProtelisAST<T>
-
getConstantValue
public final T getConstantValue()
- Returns:
- the value associated to this constant
-
-