Example #1
0
        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));
                }
            }
        }
Example #2
0
 public JsObject FindAttribute(string key)
 {
     return(scope.Find(key));
 }