void* Gc_AllocateObject(lua_State* L, int type, size_t size, bool link) { Gc_Check(L, &L->gc); Gc_Object* object = static_cast<Gc_Object*>(Allocate(L, size)); if (object == NULL) { // Emergency run of the garbage collector to free up memory. Gc_Collect(L, &L->gc); object = static_cast<Gc_Object*>(Allocate(L, size)); if (object == NULL) { // Out of memory! State_Error(L); } } object->nextGrey = NULL; object->type = type; if (L->gc.state == Gc_State_Finish) { // If we've already finished marking but have not done the sweep, we need // to make the object black to prevent it from being collected. object->color = Color_Black; } else { // If we are not in a GC cycle or haven't finished propagating, then // we'll either color this object with a write barrier or when we rescan // the stack during finalization (or it will be garbage). object->color = Color_White; } if (link) { object->next = L->gc.first; L->gc.first = object; } else { object->next = NULL; } return object; }
void Parser_Error(Parser* parser, const char* fmt, ...) { PushFString(parser->L, "Error line %d: ", parser->lineNumber); va_list argp; va_start(argp, fmt); PushVFString(parser->L, fmt, argp); va_end(argp); Concat(parser->L, 2); State_Error(parser->L); }
int lua_error(lua_State* L) { State_Error(L); return 0; }