Пример #1
0
        public override EvalResult Evaluate(MakeState s)
        {
            FunctionStatement fs = new FunctionStatement();

            fs.name = name;
            fs.args = new List <FunctionStatement.FunctionArg>();
            foreach (var arg in args)
            {
                fs.args.Add(new FunctionStatement.FunctionArg {
                    argtype = arg
                });
            }
            var mangled = fs.Mangle();

            if (s.funcs.ContainsKey(mangled))
            {
                fs.args = s.funcs[mangled].args;
                fs.code = s.funcs[mangled].code;
                return(new EvalResult(fs));
            }
            else
            {
                return(new EvalResult());
            }
        }
Пример #2
0
        public virtual Expression.EvalResult Run(MakeState s, List <Expression.EvalResult> passed_args)
        {
            MakeState new_s = s.Clone();

            new_s.ClearLocalDefines();

            for (int i = 0; i < args.Count; i++)
            {
                if (args[i].argtype == Expression.EvalResult.ResultType.Function)
                {
                    FunctionStatement fs = new FunctionStatement();
                    var ofs = passed_args[i].funcval;
                    fs.name = args[i].name;
                    fs.args = ofs.args;
                    fs.code = ofs.code;

                    new_s.funcs[fs.Mangle()] = fs;
                }
                else
                {
                    new_s.SetLocalDefine(args[i].name, passed_args[i]);
                }
            }

            code.Execute(new_s);
            if (new_s.returns != null)
            {
                return(new_s.returns);
            }

            return(new Expression.EvalResult());
        }
Пример #3
0
 public EvalResult(FunctionStatement f)
 {
     Type    = ResultType.Function;
     funcval = f;
 }