// First evaluate the action-level thunks, so that their value
// will not be affected by subsequent assignments to action
// or actor variables.
env.freezeLocal();
final Action action = envAction;
final InputPattern[] inputPatterns = action.getInputPatterns();
for (int i = 0; i < inputPatterns.length; i++) {
final InputPattern inputPattern = inputPatterns[i];
// FIXME: handle multiports
final InputChannel channel = ((InputPort) (inputPortMap
.get(inputPattern.getPortname()))).getChannel(0);
if (inputPattern.getRepeatExpr() == null) {
if (!channel.hasAvailable(inputPattern.getVariables().length)) {
throw new InterpreterException("Not enough inputs:"
+ inputPattern.getVariables().length);
}
} else {
int repeatVal = context.intValue(env.get(new EnvironmentKey(
inputPattern.getPortname())));
if (!channel.hasAvailable(inputPattern.getVariables().length
* repeatVal)) {
throw new InterpreterException(
"Not enough repeated inputs:"
+ (inputPattern.getVariables().length * repeatVal));
}
}
}
final StmtEvaluator eval = new StmtEvaluator(context, env);
final Statement[] body = action.getBody();
for (int i = 0; i < body.length; i++) {
eval.evaluate(body[i]);
}
}