/**
* @param call
* @throws WinkParseException
*/
private void interpretExprResultCall(final ExprResultCall expr) throws WinkParseException {
final Call call = expr.getCall();
Namespace ns;
ns = new Namespace();
ns.appendNamespace(namespace);
ns.appendNamespace(call.getNamespace());
FunctionObject globalFunc;
try {
final ScriptObject so = resolveByNamespace(ns);
if (!(so instanceof FunctionObject)) {
return;
}
globalFunc = (FunctionObject) so;
} catch (final WinkParseException e) {
if (Constants.failOnUnresolvedNamespace) {
throw new WinkParseException(ns + " not accessible in " + namespace + " - " + Ast.getPositionInfo(expr.getNode()), e);
} else {
System.err.println("WARN - " + ns + " not accessible in " + namespace + " - " + Ast.getPositionInfo(expr.getNode()) + " - " + e.getMessage());
return;
}
}
if (call instanceof DefineCall) {
final Map<String, Namespace> argumentsMap = new HashMap<String, Namespace>();
for (int i = 0; i < globalFunc.getParameters().size(); i++) {
final String funcParam = globalFunc.getParameters().get(i);
final Namespace nsc = new Namespace();
nsc.addName(Constants.WINK_NAMESPACE);
argumentsMap.put(funcParam, nsc);
}
final List<AstNode> childsGlobalFunc = globalFunc.getNode().getChilds();
for (final AstNode cgf : childsGlobalFunc) {
interpretCallSetProp(cgf, globalFunc, argumentsMap, true);
}
} else {
if (globalFunc.getParameters().size() != call.getParameters().size()) {
throw new WinkParseException("call arguments count does not match function parameter count [" + globalFunc + "]");
}
final Map<String, Namespace> argumentsMap = new HashMap<String, Namespace>();
for (int i = 0; i < globalFunc.getParameters().size(); i++) {
final String funcParam = globalFunc.getParameters().get(i);
argumentsMap.put(funcParam, call.getParameters().get(i));
}
final List<AstNode> childsGlobalFunc = globalFunc.getNode().getChilds();
for (final AstNode cgf : childsGlobalFunc) {
interpretCallSetProp(cgf, globalFunc, argumentsMap, false);