Copyright (C) 2013 Madis Pink
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...
If you think the Android project bad listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.madisp.bad.expr;
/*fromwww.java2s.com*/import com.madisp.bad.eval.BadScope;
import com.madisp.bad.eval.Scope;
import com.madisp.bad.eval.Watcher;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: madis
* Date: 5/12/13
* Time: 3:24 PM
*/publicclass BlockExpression implements Expression {
privatefinal Expression expr;
private List<String> vars;
public BlockExpression(Expression expression, List<String> vars) {
this.vars = vars;
this.expr = expression;
}
@Override
public Object value(Scope scope) {
returnthis;
}
@Override
publicvoid addWatcher(Scope scope, Watcher w) {
}
public Object yield(Scope scope, Object... args) {
BadScope execScope = new BadScope(null, new Object());
for (int i = 0; i < Math.min(args.length, vars.size()); i++) {
execScope.setVar(null, vars.get(i), args[i]);
}
execScope.setParent(scope);
return expr.value(execScope);
}
}