protected internal override void TraverseEval(Eval eval) { var m = eval.InvokedMethod(); eval.InvocationArgs().ForEach(Traverse); var lam = eval.InvokedLambda(); if (lam.InvokedAsCtor) { il.newobj(m); } else if (lam.InvokedAsVirtual) { il.callvirt(m); } else { il.call(m); } var rets_smth = lam.Sig.Ret != typeof(void); var ret_aint_used = !(Stack.SecondOrDefault() is Expression); if (rets_smth && ret_aint_used) { il.pop(); } }
public Eval Redirect(Eval eval) { var m = eval.InvokedMethod(); var a = eval.InvocationArgs().ToReadOnly(); var redirectors = _redirects.Select(kvp => kvp.Key(m) ? kvp.Value : null).Where(f => f != null); var f_mredir = redirectors.AssertSingle().Item1; var m_redir = f_mredir(m, a); var f_aredir = redirectors.AssertSingle().Item2; var a_redir = f_aredir(m, a); if (m_redir == null || a_redir == null) return null; // todo. this doesn't preserve virtuality of the call! return new Eval(new Apply(new Lambda(m_redir), a_redir)); }
public Eval Redirect(Eval eval) { var m = eval.InvokedMethod(); var a = eval.InvocationArgs().ToReadOnly(); var redirectors = _redirects.Select(kvp => kvp.Key(m) ? kvp.Value : null).Where(f => f != null); var f_mredir = redirectors.AssertSingle().Item1; var m_redir = f_mredir(m, a); var f_aredir = redirectors.AssertSingle().Item2; var a_redir = f_aredir(m, a); if (m_redir == null || a_redir == null) { return(null); } // todo. this doesn't preserve virtuality of the call! return(new Eval(new Apply(new Lambda(m_redir), a_redir))); }
protected override void TraverseEval(Eval eval) { var m = eval.InvokedMethod(); eval.InvocationArgs().ForEach(Traverse); var lam = eval.InvokedLambda(); if (lam.InvokedAsCtor) il.newobj(m); else if (lam.InvokedAsVirtual) il.callvirt(m); else il.call(m); var rets_smth = lam.Sig.Ret != typeof(void); var ret_aint_used = !(Stack.SecondOrDefault() is Expression); if (rets_smth && ret_aint_used) il.pop(); }