Пример #1
0
        static void Execute(ForeachFunctionValue main, FunctionArgument args, EvalContext cal)
        {
            var children = args.Contents;

            try
            {
                IEnumerableValue l = cal.GetValue <IEnumerableValue>(cal.Evaluate(main.Collection));
                foreach (var t in l)
                {
                    cal.Variables.Set(main.Vid, t);
                    try
                    {
                        foreach (var v in children)
                        {
                            cal.Evaluate(v);
                        }
                    }
                    catch (BContinue)
                    {
                        continue;
                    }
                }
            }
            catch (BBreak)
            {
                return;
            }
        }
Пример #2
0
        static void Execute(ForFunctionValue main, FunctionArgument args, EvalContext cal)
        {
            var children = args.Contents;

            try
            {
                for (cal.Evaluate(main.Begin);
                     cal.GetValue <bool>(cal.Evaluate(main.Condition));
                     cal.Evaluate(main.Step))
                {
                    try
                    {
                        foreach (var v in children)
                        {
                            cal.Evaluate(v);
                        }
                    }
                    catch (BContinue)
                    {
                        continue;
                    }
                }
            }
            catch (BBreak)
            {
                return;
            }
        }
Пример #3
0
        static void Execute(DoWhileFunctionValue main, FunctionArgument args, EvalContext cal)
        {
            var children = args.Contents;

            try
            {
                do
                {
                    try
                    {
                        foreach (var v in children)
                        {
                            cal.Evaluate(v);
                        }
                    }
                    catch (BContinue)
                    {
                        continue;
                    }
                }while (cal.GetValue <bool>(cal.Evaluate(main.Condition)));
            }
            catch (BBreak)
            {
                return;
            }
        }
Пример #4
0
        static IExpr Execute(IfFunctionValue main, FunctionArgument args, EvalContext cal)
        {
            var children = args.Contents;

            if (cal.GetValue <bool>(cal.Evaluate(main.Condition)))
            {
                foreach (var v in children)
                {
                    cal.Evaluate(v);
                }
                return(BuiltinValues.Null);
            }
            else
            {
                return(new ElseFunctionValue(true, main));
            }
        }
Пример #5
0
        static void Execute(ElseFunctionValue main, FunctionArgument args, EvalContext cal)
        {
            if (main.IsHappen == false)
            {
                return;
            }
            var children = args.Contents;

            foreach (var v in children)
            {
                cal.Evaluate(v);
            }
        }
Пример #6
0
        public object Execute(string code)
        {
            var e = eb.GetExpr(code);

            return(context.Evaluate(e));
        }