List<String> parameters = fn.getParameters();
// Make sure we have the proper number of calling parameters
if (parameters.size() != arguments.size()) {
throw new ParserException(Simple3.formatMessage("error.function_argument_count",
String.valueOf(parameters.size()), String.valueOf(arguments.size())));
}
// Set the function parameters -- these will be stored under the function's
// scope and will not be visible outside of the function. Any variables
// in other scopes having the same name will not be visible to the function.
for (int i = 0; i < parameters.size(); i++) {
theParser.setProgramVariable(parameters.get(i), arguments.get(i).getValue());
}
Reduction statements = fn.getStatements();
if (statements != null) {
statements.execute();
var = statements.getValue();
}
// Simple3 doesn't allow a simple RETURN without a value hence this
// path will never be executed. The code remains to support other
// syntaxes that allow an empty return statement. These lines of
// code will be flagged as untested by the coverage tool when the
// Simple3 tests are run.
if (var == null) {
var = new Variable("");
}
} else {
throw new ParserException(Simple3.formatMessage("error.function_undefined", functionName));
}
return var;
} finally {