Beispiel #1
0
//------------------------------------------------------
static void runCons(Context *ctx, Cons *cons) {
	Func *func = new Func();
	func->name = "__script";
	func->argc = 0;
	try {
		CodeBuilder cb(ctx, func, true, true);
		ValueType ty = codegen(cons, &cb, 0);
		if(ty == VT_INT) {
			cb.createPrintInt(0);
		} else if(ty == VT_BOOLEAN) {
			cb.createPrintBoolean(0);
		}
		cb.createRet(0);
		func->code = cb.getCode();
#ifdef USING_THCODE
		func->thcode = func->code;
#endif
		Scheduler *sche = ctx->sche;
		Task *task = sche->newTask(func, NULL);
		assert(task != NULL);
		sche->enqueueWaitFor(task);
		sche->deleteTask(task);
		delete [] func->code;
	} catch(char *str) {
	}
	delete func;
}