Example #1
0
void knh_throw(CTX ctx, ksfp_t *sfp, long start)
{
	if(IS_Exception(ctx->e)) {
		ksfp_t *sp = (sfp == NULL) ? ctx->esp : sfp + start;
		kExceptionHandler *hdr = ctx->ehdrNC;
		if((ctx->e)->uline == 0) {
			(ctx->e)->uline = knh_stack_uline(ctx, sfp);
		}
		while(ctx->stack <= sp) {
			if(sp[0].mtdNC != NULL && isCalledMethod(ctx, sp)) {
				knh_Exception_addStackTrace(ctx, ctx->e, sp+1);
				sp[0].mtdNC = 0;
			}
			if(sp[0].hdr == hdr) {
				size_t i = 0, size = knh_Array_size(hdr->stacklist);
				for(i = 0; i < size; i++) {
					kObject *o = knh_Array_n(hdr->stacklist, i);
					O_cTBL(o)->cdef->checkout(ctx, RAWPTR(o), 1);
				}
				kArrayrimSize(ctx, hdr->stacklist, 0);
#ifdef K_USING_SETJMP_
				knh_longjmp(DP(hdr)->jmpbuf, 1);
#else
				knh_ExceptionHandler_longjmp(ctx, hdr);
#endif
				goto L_NOCATCH;
			}
			sp--;
		}
		L_NOCATCH:;
		knh_write_Object(ctx, KNH_STDERR, UPCAST(ctx->e), FMT_dump);
		knh_exit(ctx, 0);
	}
}
Example #2
0
static void knh_Actor_setMethodInfo(CTX ctx, knh_Actor_t *actor)
{
	knh_MethodInfo_t **info = actor->mtd_info;
	knh_Array_t *mn_array = O_cTBL(ctx->script)->methods;
	knh_Method_t **methods = mn_array->methods;
	int i = 0;
	while (methods[i] != NULL) {
		const char *mn_name = knh_getmnname(ctx, methods[i]->mn);
		//fprintf(stderr, "mn_name = [%s]\n", mn_name);
		(*info)->mtd_name = mn_name;
		(*info)->mtd = methods[i];
		info++;
		i++;
	}
}
Example #3
0
static int knh_runMain(CTX ctx, int argc, const char **argv)
{
	KONOHA_BEGIN(ctx);
	kMethod *mtd = ClassTBL_getMethodNULL(ctx, O_cTBL(ctx->script), MN_main);
	int res = 0;
	if(mtd != NULL) {
		int thisidx = 1 + K_CALLDELTA;
		BEGIN_LOCAL(ctx, lsfp, 5);
		lsfp[1].ivalue = 0;
		lsfp[thisidx+K_PCIDX].pc = NULL;
		klr_setmtdNC(ctx,lsfp[thisidx+K_MTDIDX], mtd);
		KNH_SETv(ctx, lsfp[thisidx].o, ctx->script);
		KNH_SETv(ctx, lsfp[thisidx+1].o, knh_getPropertyNULL(ctx, STEXT("script.argv")));
		klr_setesp(ctx, lsfp + thisidx+2);
		if(knh_VirtualMachine_launch(ctx, lsfp + thisidx)) {
			res = (int)lsfp[1].ivalue;
		}
		END_LOCAL(ctx, lsfp);
	}
	KONOHA_END(ctx);
	return res;
}
Example #4
0
		else {
			knh_write_ascii(ctx, w, "to ");
		}
		knh_write_cid(ctx, w, SP(mpr)->tcid);
		knh_write_EOL(ctx, w);
	}
	if(hasCaption == 1) {
		knh_write_EOL(ctx, w);
	}
}

//## @Static method void System.man(Object c, NameSpace ns);
METHOD System_man(CTX ctx, knh_sfp_t *sfp _RIX)
{
	knh_OutputStream_t *w = KNH_STDOUT;
	const knh_ClassTBL_t *ct = O_cTBL(sfp[1].o);
	knh_NameSpace_t *ns = sfp[2].ns;
	if(IS_Class(sfp[1].o)) {
		ct = ClassTBL(((knh_Class_t*)sfp[1].o)->cid);
	}
	ClassNAME_man(ctx, w, ct);
	if(!class_isPrivate(ct->cid)) {
		if(ct->constDictCaseMapNULL != NULL) {
			ClassCONST_man(ctx, w, ct, ns);
		}
		ClassOP_man(ctx, w, ct, ns);
		ClassMETHOD_man(ctx, w, ct, ns);
		ClassFMT_man(ctx, w, ct, ns);
		ClassTYPEMAP_man(ctx, w, ct, ns);
	}
}