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()); } }
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()); }
public EvalResult(FunctionStatement f) { Type = ResultType.Function; funcval = f; }