MCPcopy Create free account
hub / github.com/DFHack/dfhack / LoadString

Function LoadString

depends/lua/src/lundump.c:88–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87
88static TString *LoadString (LoadState *S, Proto *p) {
89 lua_State *L = S->L;
90 size_t size = LoadByte(S);
91 TString *ts;
92 if (size == 0xFF)
93 LoadVar(S, size);
94 if (size == 0)
95 return NULL;
96 else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
97 char buff[LUAI_MAXSHORTLEN];
98 LoadVector(S, buff, size);
99 ts = luaS_newlstr(L, buff, size);
100 }
101 else { /* long string */
102 ts = luaS_createlngstrobj(L, size);
103 setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
104 luaD_inctop(L);
105 LoadVector(S, getstr(ts), size); /* load directly in final place */
106 L->top--; /* pop string */
107 }
108 luaC_objbarrier(L, p, ts);
109 return ts;
110}
111
112
113static void LoadCode (LoadState *S, Proto *f) {

Callers 3

LoadConstantsFunction · 0.85
LoadDebugFunction · 0.85
LoadFunctionFunction · 0.85

Calls 4

LoadByteFunction · 0.85
luaS_newlstrFunction · 0.85
luaS_createlngstrobjFunction · 0.85
luaD_inctopFunction · 0.85

Tested by

no test coverage detected