public static JsObject EvalFunctionInvoke(JsExpression x, Env env) { JsFunction func = x.value == "(" ? (JsFunction)x.child[0].evaluate(env) : (JsFunction)env.Find(x.value); //add variable support,because var has child,so it can't be evaluated var arguments = x.child.Skip(1).Select(item => item.evaluate(env)).ToArray(); return(func.UpdateArgs(arguments).evaluate()); }
public static JsObject EvalPointExpression(JsExpression x, Env env) { JsObject obj = env.Find(x.child[0].value);//root obj JsExpression exp = x.child[1]; if (exp.value == "=") { return(obj.AddDef(exp.child[0].value, exp.child[1].evaluate(obj.Scope))); } else { if (exp.value == "(") { JsFunction func = (JsFunction)obj.FindAttribute(exp.child[0].value); var arguments = exp.child.Skip(1).Select(item => item.evaluate(env)).ToArray(); return(func.UpdateArgs(arguments).evaluate()); } else { return(obj.FindAttribute(exp.value)); } } }