public Expression LetToExpr(Node node) { var exprs = new List<Expression>(); foreach (var binding in node[0].Nodes) { var name = binding[0].Text; var param = AddBinding(Expression.Parameter(typeof(Object), name)); exprs.Add(param); exprs.Add(Expression.Assign(Lookup(name), ToExpr(binding[1]))); } exprs.Add(ToExpr(node["Term"])); return Expression.Block(exprs); }
public void Eval(MethodInfo mi) { var args = new List<dynamic>(); for (int i = 0; i < mi.GetParameters().Length; ++i) args.Add(Pop()); var result = mi.Invoke(this, args.ToArray()); if (mi.ReturnType != typeof(void)) Push(result); }