
org.snapscript.tree.closure.ClosureStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.closure;
import org.snapscript.core.Evaluation;
import org.snapscript.core.Result;
import org.snapscript.core.ResultType;
import org.snapscript.core.Scope;
import org.snapscript.core.Statement;
import org.snapscript.core.Value;
public class ClosureStatement extends Statement {
private final Evaluation evaluation;
private final Statement statement;
public ClosureStatement(Statement statement, Evaluation evaluation) {
this.evaluation = evaluation;
this.statement = statement;
}
@Override
public Result compile(Scope scope) throws Exception {
if(statement != null) {
statement.compile(scope);
}
return ResultType.getNormal();
}
@Override
public Result execute(Scope scope) throws Exception {
if(evaluation != null) {
Value value = evaluation.evaluate(scope, null);
Object object = value.getValue();
return ResultType.getNormal(object);
}
return statement.execute(scope);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy