public IodineGeneratorExpr(StackFrame frame, CodeObject target) : base(TypeDefinition) { this.frame = frame.Duplicate(frame); Target = target; SetAttribute("__iter__", new BuiltinMethodCallback((VirtualMachine vm, IodineObject self, IodineObject[] args) => { return(GetIterator(vm)); }, this)); }
public override IodineObject Invoke(VirtualMachine vm, IodineObject[] arguments) { StackFrame newFrame = frame.Duplicate(vm.Top); IodineObject initialValue = vm.InvokeMethod(Target, newFrame, frame.Self, arguments); if (newFrame.Yielded) { return(new IodineGenerator(newFrame, Target, arguments, initialValue)); } return(initialValue); }
public override IodineObject Invoke(VirtualMachine vm, IodineObject[] arguments) { return(vm.InvokeMethod(Target, frame.Duplicate(vm.Top, Target.LocalCount), frame.Self, arguments)); }