Function* Function_Create(lua_State* L, Function* parent) { Function* function = static_cast<Function*>( Gc_AllocateObject( L, LUA_TFUNCTIONP, sizeof(Function) ) ); Gc* gc = &L->gc; if (parent != NULL) { Gc_IncrementReference(gc, function, parent); } function->parent = parent; function->parser = NULL; function->numRegisters = 0; function->maxStackSize = 0; function->numParams = 0; function->varArg = false; function->numConstants = 0; function->constants = NULL; function->code = NULL; function->codeSize = 0; function->maxCodeSize = 0; function->sourceLine = NULL; function->maxSourceLines = 0; function->numLocals = 0; function->numCommitedLocals = 0; function->numUpValues = 0; function->function = NULL; function->numFunctions = 0; function->maxFunctions = 0; // It's possible for creating the table to trigger garbage collection, so // make sure there's a reference to our function on the stack before we do // that. PushFunction(L, function); function->constants = Table_Create(L, 0, 0); Gc_IncrementReference(&L->gc, function, function->constants); Pop(L, 1); return function; }
void lua_createtable(lua_State *L, int narr, int nrec) { Value value; SetValue( &value, Table_Create(L) ); PushValue( L, &value ); }