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 override EvalResult Evaluate(MakeState s) { FunctionStatement fs = new FunctionStatement(); fs.name = null; fs.args = args; fs.code = code; return(new EvalResult(fs)); }
public virtual Expression.EvalResult Run(MakeState s, List <Expression.EvalResult> passed_args) { MakeState new_s = s.Clone(); new_s.PromoteLocalDefines(); 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; var arg_types = new List <Expression.EvalResult.ResultType>(); foreach (var arg in fs.args) { arg_types.Add(arg.argtype); } var mangledname = FuncCall.Mangle(fs.name, arg_types); /* var mangled_names = FuncCall.MangleAll(fs.name, arg_types, s); * * foreach(var mangledname in mangled_names) */ new_s.funcs[mangledname] = 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; }