public static Func <T, TResult> Create <T, TResult>(Func <Func <T, TResult>, T, TResult> function) { var selfRef = new RefOf <Func <T, TResult> >(); var unbound = new Func <Func <T, TResult>, Func <T, TResult>, T, TResult>((s, l, t) => function(s, t)); selfRef.Ref = Chain(selfRef, unbound, null); return(selfRef.Ref); }
public override void Visit(RefOf node) { // TODO: This implementation is not strictly correct, as it // will not continue to refer to the location if its value is // replaced (as can happen if it's currently uninitialized). // But currently the result of RefOf isn't used on any of // the tested machines, so postponing this. thread.Push(new ValueIoLocation(new AcpiObject.ObjectReference(new AcpiObjectCell(thread.Pop().Read())))); }
public static Func <T, TResult> Chain <T, TResult>( this Func <T, TResult> lastFunction, Func <Func <T, TResult>, Func <T, TResult>, T, TResult> selfFunction) { var selfRef = new RefOf <Func <T, TResult> >(); var lastBinding = (Binding <T, TResult>)lastFunction.Target; selfRef.Ref = Chain <T, TResult>(selfRef, selfFunction, lastBinding); return(selfRef.Ref); }
private static Func <T, TResult> Chain <T, TResult>( RefOf <Func <T, TResult> > selfRef, Func <Func <T, TResult>, Func <T, TResult>, T, TResult> unbound, Binding <T, TResult> lastBinding) { Func <T, TResult> last = null; Func <T, TResult> bound = (t) => unbound(selfRef.Ref, last, t); if (lastBinding != null) { last = Chain(selfRef, lastBinding.Unbound, lastBinding.LastBinding); } var binding = new Binding <T, TResult>(bound, unbound, lastBinding); return(new Func <T, TResult>(binding.Invoke)); }