예제 #1
0
        protected override object DoEvaluate(Irony.Interpreter.ScriptThread thread)
        {
            // PROLOG
            thread.CurrentNode = this;
            try
            {
                var appResult = new MtResult();

                MtResult[] args = _args.Evaluate(thread) as MtResult[];
                if (args == null)
                {
                    throw new Exception("Args evaluated to null!");
                }

                var subthreadF = _head.NewScriptThread(thread);
                var headResult = _head.Evaluate(subthreadF);
                if (headResult == null)
                {
                    throw new Exception("Head can't evaluate to null!");
                }

                MtFunctionObjectBase.ExtractAsFunction(headResult, (wrkFun) =>
                {
#if DEBUG && !SILVERLIGHT
                    if (wrkFun is BuiltInCallTarget)
                    {
                        var builtin = wrkFun as BuiltInCallTarget;
                        Debug.Print("Calling builtin: {0}", builtin.Name);
                    }
                    else
                    {
                        Debug.Print("Calling user function");
                    }
#endif

                    var resultFun = wrkFun.Call(thread, args) as MtResult;
                    resultFun.GetValue((r3) =>
                    {
                        appResult.SetValue(r3);
                    });
                });

                return(appResult);
            }
            catch (Exception e)
            {
                throw new Exception("Exception on MtApplication.", e);
            }
            finally
            {
                // EPILOG
                //thread.CurrentNode = Parent;
            }
        }
예제 #2
0
        protected override object DoEvaluate(Irony.Interpreter.ScriptThread thread)
        {
            thread.CurrentNode = this;
            try
            {
                // TODO Create a new context with $ as the current array? RECURSIVE ARRAYS? \ :D /

                var ret = new MtResult();

                var expressions = _expressionList.Evaluate(thread) as MtResult[];

                ret.SetValue(new MtObject(expressions));

                return(ret);
            }
            catch (Exception e)
            {
                throw new Exception("Exception on MtArray.DoEvaluate.", e);
            }
            finally
            {
                //thread.CurrentNode = Parent;
            }
        }