Class ConditionalSideEffect
- java.lang.Object
-
- org.protelis.lang.interpreter.impl.AbstractProtelisAST<Unit>
-
- org.protelis.lang.interpreter.impl.ConditionalSideEffect
-
- All Implemented Interfaces:
java.io.Serializable
,ProtelisAST<Unit>
,WithBytecode
public final class ConditionalSideEffect extends AbstractProtelisAST<Unit>
Branch with side effects, returnsUnit
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConditionalSideEffect(Metadata metadata, ProtelisAST<java.lang.Boolean> cond, ProtelisAST<?> then)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Unit
evaluate(ExecutionContext context)
Evaluates this AST node.Bytecode
getBytecode()
java.lang.String
toString()
-
Methods inherited from class org.protelis.lang.interpreter.impl.AbstractProtelisAST
branchesToString, branchesToString, eval, forEach, forEachWithIndex, getBranch, getBranches, getBranchesNumber, getMetadata, getName, isNullable, stringFor
-
-
-
-
Constructor Detail
-
ConditionalSideEffect
public ConditionalSideEffect(@Nonnull Metadata metadata, @Nonnull ProtelisAST<java.lang.Boolean> cond, @Nonnull ProtelisAST<?> then)
- Parameters:
metadata
- AMetadata
object containing information about the code that generated this AST node.cond
- conditionthen
- branch to execute if condition is true (erase otherwise)
-
-
Method Detail
-
evaluate
public Unit 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<Unit>
- Parameters:
context
- the execution context- Returns:
- the result of the evaluation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractProtelisAST<Unit>
-
-