public UserDelegate(UserDelegate oldCopy) : base(oldCopy) { ProgContext = oldCopy.ProgContext; EntryPoint = oldCopy.EntryPoint; Closure = oldCopy.Closure; if (Cpu != null) { Cpu.AddPopContextNotifyee(this); } }
/// <summary> /// Make a new UserDelegate given the current state of the CPU and its stack, and /// the entry point location of the function to call. /// </summary> /// <param name="cpu">the CPU on which this program is running.</param> /// <param name="context">The IProgramContext in which the entryPoint is stored. Entry point 27 in the interpreter is not the same as entrypoint 27 in program context.</param> /// <param name="entryPoint">instruction address where OpcodeCall should jump to to call the function.</param> /// <param name="useClosure">If true, then a snapshot of the current scoping stack, and thus a persistent ref to its variables, /// will be kept in the delegate so it can be called later as a callback with closure. Set to false if the /// function is only getting called instantly using whatever the scope is at the time of the call.</param> public UserDelegate(ICpu cpu, IProgramContext context, int entryPoint, bool useClosure) : base(cpu) { ProgContext = context; EntryPoint = entryPoint; if (useClosure) { CaptureClosure(); } if (Cpu != null) { Cpu.AddPopContextNotifyee(this); } }