Exemple #1
0
static void shell(CTX)
{
	kwb_t wb;
	kwb_init(&(_ctx->stack->cwb), &wb);
	kline_t uline = FILEID_("(shell)") | 1;
	while(1) {
		kline_t inc = 0;
		kstatus_t status = readstmt(_ctx, &wb, &inc);
		if(status == K_CONTINUE && kwb_bytesize(&wb) > 0) {
			status = konoha_eval((konoha_t)_ctx, kwb_top(&wb, 1), uline);
			uline += inc;
			kwb_free(&wb);
			if(status != K_FAILED) {
				dumpEval(_ctx, &wb);
				kwb_free(&wb);
			}
		}
		if(status == K_BREAK) {
			break;
		}
	}
	kwb_free(&wb);
	fprintf(stdout, "\n");
	return;
}
Exemple #2
0
static void dumpMethod(CTX, ksfp_t *sfp, kMethod *mtd)
{
	kwb_t wb;
	kwb_init(&(_ctx->stack->cwb), &wb);
	KSETv(sfp[2].mtd, mtd);
	O_ct(mtd)->p(_ctx, sfp, 2, &wb, 1);
	PLAT printf_i("%s\n", kwb_top(&wb, 1));
	kwb_free(&wb);
	return;
}