示例#1
0
文件: IoCoroutine.c 项目: jdp/io
void IoCoroutine_rawPrintBackTrace(IoCoroutine *self)
{
	IoObject *e = IoCoroutine_rawException(self);
	IoMessage *caughtMessage = IoObject_rawGetSlot_(e, IOSYMBOL("caughtMessage"));

	if (IoObject_rawGetSlot_(e, IOSYMBOL("showStack"))) // sanity check
	{
		IoState_on_doCString_withLabel_(IOSTATE, e, "showStack", "[Coroutine]");
	}
	else
	{
		IoSymbol *error = IoObject_rawGetSlot_(e, IOSYMBOL("error"));

		if (error)
		{
			fputs(CSTRING(error), stderr);
			fputs("\n", stderr);
		}
		else
		{
			fputs("error: [missing error slot in Exception object]\n", stderr);
		}

		if (caughtMessage)
		{
			UArray *ba = IoMessage_asMinimalStackEntryDescription(caughtMessage);
			fputs(UArray_asCString(ba), stderr);
			fputs("\n", stderr);
			UArray_free(ba);
		}
	}
}
示例#2
0
文件: IoCoroutine.c 项目: jdp/io
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);
}
示例#3
0
IoObject *IoState_tryToPerform(IoState *self,
							  IoObject *target,
							  IoObject *locals,
							  IoMessage *m)
{
	IoCoroutine *tryCoro = IoCoroutine_newWithTry(self, target, locals, m);

	if (IoCoroutine_rawException(tryCoro) != self->ioNil)
	{
		IoState_exception_(self, tryCoro);
	}

	return IoCoroutine_rawResult(tryCoro);

	return IoMessage_locals_performOn_(m, locals, target);
}
示例#4
0
文件: IoDrawStuff.c 项目: ADTSH/io
IoObject *IoDrawStuff_tryCallback(IoDrawStuff *self, IoMessage *m)
{
    IoState *state = IoObject_state(proto);
    IoObject *tryCoro = DATA(self)->coroutine;
    IoObject *t = DATA(self)->eventTarget;
    IoObject *result = state->ioNil;
    //printf("IoDrawStuff_tryCallback(self, %p)\n", (void*)m);
    //printf("IoDrawStuff_tryCallback target: %p)\n", (void*)t);

    if(t)
    {
        IoMessage_locals_performOn_(m, t, t);
        if (IoCoroutine_rawException(tryCoro) != state->ioNil)
            IoState_exception_(state, tryCoro);
        
        IoCoroutine_clearStack(tryCoro);
        return IoCoroutine_rawResult(tryCoro);
    }
    return result;
}