evaluateCall method
Implementation
EvaluateOutput evaluateCall(EvaluateInput input) {
final call = input.expr.call;
final found = input.defStack.find(call.ident);
if (found == null) {
final ext = config.extension[call.ident];
if (ext == null) {
return _errorReferenceNotFound(input.expr.path, call.ident);
}
final args = <String, Value>{};
for (final entry in call.args.entries) {
final argVal = evaluateExpr(
EvaluateInput(defStack: input.defStack, expr: entry.value));
if (argVal.status != EvaluateOutput_Status.OK) {
return argVal;
}
args[entry.key] = argVal.value;
}
return ext(input.expr.path, args);
}
var st = found;
for (final argName in found.def.args) {
final arg = call.args[argName];
if (arg == null) {
return _errorArgumentMismatch(input.expr.path, argName);
}
final argVal =
evaluateExpr(EvaluateInput(defStack: input.defStack, expr: arg));
if (argVal.status != EvaluateOutput_Status.OK) {
return argVal;
}
st = st.register(newDefinition(
input.expr.path.append([call.ident, argName]),
argName,
argVal.value));
}
return evaluateExpr(EvaluateInput(defStack: st, expr: found.def.body));
}