IoObject *IoObject_performWithDebugger(IoCoroutine *self, IoObject *locals, IoMessage *m) { IoState *state = IOSTATE; IoObject *currentCoroutine = IoState_currentCoroutine(state); if (IoCoroutine_rawDebuggingOn(currentCoroutine)) { IoObject *debugger = state->debugger; // stack retain it? if (debugger) { IoObject_setSlot_to_(debugger, IOSYMBOL("messageCoroutine"), currentCoroutine); IoObject_setSlot_to_(debugger, IOSYMBOL("messageSelf"), self); IoObject_setSlot_to_(debugger, IOSYMBOL("messageLocals"), locals); IoObject_setSlot_to_(debugger, IOSYMBOL("message"), m); { IoObject *context; IoCoroutine *c = IoObject_rawGetSlot_context_(debugger, IOSYMBOL("debuggerCoroutine"), &context); IOASSERT(c, "Debugger needs a debuggerCoroutine slot"); IoCoroutine_rawResume(c); } } } return IoObject_perform(self, locals, m); }
void IoCoroutine_rawReturnToParent(IoCoroutine *self) { IoCoroutine *parent = IoCoroutine_rawParentCoroutine(self); if (parent && ISCOROUTINE(parent)) { IoCoroutine_rawResume(parent); } else { if (self == IOSTATE->mainCoroutine) { printf("IoCoroutine error: attempt to return from main coro\n"); exit(-1); } } if (!ISNIL(IoCoroutine_rawException(self))) { IoCoroutine_rawPrintBackTrace(self); } printf("IoCoroutine error: unable to auto abort coro %p by resuming parent coro %s_%p\n", (void *)self, IoObject_name(parent), (void *)parent); exit(-1); }
IO_METHOD(IoCoroutine, resume) { /*doc Coroutine resume Yields to the receiver. Runs the receiver if it is not running yet. Returns self. */ //printf("IoCoroutine_resume(%p)\n", (void *)self); return IoCoroutine_rawResume(self); }
IO_METHOD(IoCoroutine, resume) { /*doc Coroutine resume Yields to the receiver. Runs the receiver if it is not running yet. Returns self. */ return IoCoroutine_rawResume(self); }
IoObject *IoCoroutine_resume(IoCoroutine *self, IoObject *locals, IoMessage *m) { //printf("IoCoroutine_resume()\n"); return IoCoroutine_rawResume(self); }