Code style in 'ldump'/'lundump'.

- function names start with lower case;
- state is always the first parameter.
This commit is contained in:
Roberto Ierusalimschy
2020-02-27 15:17:44 -03:00
parent 6eb53b7526
commit e8a52281d9
2 changed files with 149 additions and 149 deletions

152
ldump.c
View File

@@ -29,15 +29,15 @@ typedef struct {
/* /*
** All high-level dumps go through DumpVector; you can change it to ** All high-level dumps go through dumpVector; you can change it to
** change the endianness of the result ** change the endianness of the result
*/ */
#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) #define dumpVector(D,v,n) dumpBlock(D,v,(n)*sizeof((v)[0]))
#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) #define dumpLiteral(D, s) dumpBlock(D,s,sizeof(s) - sizeof(char))
static void DumpBlock (const void *b, size_t size, DumpState *D) { static void dumpBlock (DumpState *D, const void *b, size_t size) {
if (D->status == 0 && size > 0) { if (D->status == 0 && size > 0) {
lua_unlock(D->L); lua_unlock(D->L);
D->status = (*D->writer)(D->L, b, size, D->data); D->status = (*D->writer)(D->L, b, size, D->data);
@@ -46,19 +46,19 @@ static void DumpBlock (const void *b, size_t size, DumpState *D) {
} }
#define DumpVar(x,D) DumpVector(&x,1,D) #define dumpVar(D,x) dumpVector(D,&x,1)
static void DumpByte (int y, DumpState *D) { static void dumpByte (DumpState *D, int y) {
lu_byte x = (lu_byte)y; lu_byte x = (lu_byte)y;
DumpVar(x, D); dumpVar(D, x);
} }
/* DumpInt Buff Size */ /* dumpInt Buff Size */
#define DIBS ((sizeof(size_t) * 8 / 7) + 1) #define DIBS ((sizeof(size_t) * 8 / 7) + 1)
static void DumpSize (size_t x, DumpState *D) { static void dumpSize (DumpState *D, size_t x) {
lu_byte buff[DIBS]; lu_byte buff[DIBS];
int n = 0; int n = 0;
do { do {
@@ -66,63 +66,63 @@ static void DumpSize (size_t x, DumpState *D) {
x >>= 7; x >>= 7;
} while (x != 0); } while (x != 0);
buff[DIBS - 1] |= 0x80; /* mark last byte */ buff[DIBS - 1] |= 0x80; /* mark last byte */
DumpVector(buff + DIBS - n, n, D); dumpVector(D, buff + DIBS - n, n);
} }
static void DumpInt (int x, DumpState *D) { static void dumpInt (DumpState *D, int x) {
DumpSize(x, D); dumpSize(D, x);
} }
static void DumpNumber (lua_Number x, DumpState *D) { static void dumpNumber (DumpState *D, lua_Number x) {
DumpVar(x, D); dumpVar(D, x);
} }
static void DumpInteger (lua_Integer x, DumpState *D) { static void dumpInteger (DumpState *D, lua_Integer x) {
DumpVar(x, D); dumpVar(D, x);
} }
static void DumpString (const TString *s, DumpState *D) { static void dumpString (DumpState *D, const TString *s) {
if (s == NULL) if (s == NULL)
DumpSize(0, D); dumpSize(D, 0);
else { else {
size_t size = tsslen(s); size_t size = tsslen(s);
const char *str = getstr(s); const char *str = getstr(s);
DumpSize(size + 1, D); dumpSize(D, size + 1);
DumpVector(str, size, D); dumpVector(D, str, size);
} }
} }
static void DumpCode (const Proto *f, DumpState *D) { static void dumpCode (DumpState *D, const Proto *f) {
DumpInt(f->sizecode, D); dumpInt(D, f->sizecode);
DumpVector(f->code, f->sizecode, D); dumpVector(D, f->code, f->sizecode);
} }
static void DumpFunction(const Proto *f, TString *psource, DumpState *D); static void dumpFunction(DumpState *D, const Proto *f, TString *psource);
static void DumpConstants (const Proto *f, DumpState *D) { static void dumpConstants (DumpState *D, const Proto *f) {
int i; int i;
int n = f->sizek; int n = f->sizek;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
const TValue *o = &f->k[i]; const TValue *o = &f->k[i];
int tt = ttypetag(o); int tt = ttypetag(o);
DumpByte(tt, D); dumpByte(D, tt);
switch (tt) { switch (tt) {
case LUA_VNUMFLT: case LUA_VNUMFLT:
DumpNumber(fltvalue(o), D); dumpNumber(D, fltvalue(o));
break; break;
case LUA_VNUMINT: case LUA_VNUMINT:
DumpInteger(ivalue(o), D); dumpInteger(D, ivalue(o));
break; break;
case LUA_VSHRSTR: case LUA_VSHRSTR:
case LUA_VLNGSTR: case LUA_VLNGSTR:
DumpString(tsvalue(o), D); dumpString(D, tsvalue(o));
break; break;
default: default:
lua_assert(tt == LUA_VNIL || tt == LUA_VFALSE || tt == LUA_VTRUE); lua_assert(tt == LUA_VNIL || tt == LUA_VFALSE || tt == LUA_VTRUE);
@@ -131,79 +131,79 @@ static void DumpConstants (const Proto *f, DumpState *D) {
} }
static void DumpProtos (const Proto *f, DumpState *D) { static void dumpProtos (DumpState *D, const Proto *f) {
int i; int i;
int n = f->sizep; int n = f->sizep;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
DumpFunction(f->p[i], f->source, D); dumpFunction(D, f->p[i], f->source);
} }
static void DumpUpvalues (const Proto *f, DumpState *D) { static void dumpUpvalues (DumpState *D, const Proto *f) {
int i, n = f->sizeupvalues; int i, n = f->sizeupvalues;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
DumpByte(f->upvalues[i].instack, D); dumpByte(D, f->upvalues[i].instack);
DumpByte(f->upvalues[i].idx, D); dumpByte(D, f->upvalues[i].idx);
DumpByte(f->upvalues[i].kind, D); dumpByte(D, f->upvalues[i].kind);
} }
} }
static void DumpDebug (const Proto *f, DumpState *D) { static void dumpDebug (DumpState *D, const Proto *f) {
int i, n; int i, n;
n = (D->strip) ? 0 : f->sizelineinfo; n = (D->strip) ? 0 : f->sizelineinfo;
DumpInt(n, D); dumpInt(D, n);
DumpVector(f->lineinfo, n, D); dumpVector(D, f->lineinfo, n);
n = (D->strip) ? 0 : f->sizeabslineinfo; n = (D->strip) ? 0 : f->sizeabslineinfo;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
DumpInt(f->abslineinfo[i].pc, D); dumpInt(D, f->abslineinfo[i].pc);
DumpInt(f->abslineinfo[i].line, D); dumpInt(D, f->abslineinfo[i].line);
} }
n = (D->strip) ? 0 : f->sizelocvars; n = (D->strip) ? 0 : f->sizelocvars;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
DumpString(f->locvars[i].varname, D); dumpString(D, f->locvars[i].varname);
DumpInt(f->locvars[i].startpc, D); dumpInt(D, f->locvars[i].startpc);
DumpInt(f->locvars[i].endpc, D); dumpInt(D, f->locvars[i].endpc);
} }
n = (D->strip) ? 0 : f->sizeupvalues; n = (D->strip) ? 0 : f->sizeupvalues;
DumpInt(n, D); dumpInt(D, n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
DumpString(f->upvalues[i].name, D); dumpString(D, f->upvalues[i].name);
} }
static void DumpFunction (const Proto *f, TString *psource, DumpState *D) { static void dumpFunction (DumpState *D, const Proto *f, TString *psource) {
if (D->strip || f->source == psource) if (D->strip || f->source == psource)
DumpString(NULL, D); /* no debug info or same source as its parent */ dumpString(D, NULL); /* no debug info or same source as its parent */
else else
DumpString(f->source, D); dumpString(D, f->source);
DumpInt(f->linedefined, D); dumpInt(D, f->linedefined);
DumpInt(f->lastlinedefined, D); dumpInt(D, f->lastlinedefined);
DumpByte(f->numparams, D); dumpByte(D, f->numparams);
DumpByte(f->is_vararg, D); dumpByte(D, f->is_vararg);
DumpByte(f->maxstacksize, D); dumpByte(D, f->maxstacksize);
DumpCode(f, D); dumpCode(D, f);
DumpConstants(f, D); dumpConstants(D, f);
DumpUpvalues(f, D); dumpUpvalues(D, f);
DumpProtos(f, D); dumpProtos(D, f);
DumpDebug(f, D); dumpDebug(D, f);
} }
static void DumpHeader (DumpState *D) { static void dumpHeader (DumpState *D) {
DumpLiteral(LUA_SIGNATURE, D); dumpLiteral(D, LUA_SIGNATURE);
DumpInt(LUAC_VERSION, D); dumpInt(D, LUAC_VERSION);
DumpByte(LUAC_FORMAT, D); dumpByte(D, LUAC_FORMAT);
DumpLiteral(LUAC_DATA, D); dumpLiteral(D, LUAC_DATA);
DumpByte(sizeof(Instruction), D); dumpByte(D, sizeof(Instruction));
DumpByte(sizeof(lua_Integer), D); dumpByte(D, sizeof(lua_Integer));
DumpByte(sizeof(lua_Number), D); dumpByte(D, sizeof(lua_Number));
DumpInteger(LUAC_INT, D); dumpInteger(D, LUAC_INT);
DumpNumber(LUAC_NUM, D); dumpNumber(D, LUAC_NUM);
} }
@@ -218,9 +218,9 @@ int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data,
D.data = data; D.data = data;
D.strip = strip; D.strip = strip;
D.status = 0; D.status = 0;
DumpHeader(&D); dumpHeader(&D);
DumpByte(f->sizeupvalues, &D); dumpByte(&D, f->sizeupvalues);
DumpFunction(f, NULL, &D); dumpFunction(&D, f, NULL);
return D.status; return D.status;
} }

146
lundump.c
View File

@@ -44,21 +44,21 @@ static l_noret error (LoadState *S, const char *why) {
/* /*
** All high-level loads go through LoadVector; you can change it to ** All high-level loads go through loadVector; you can change it to
** adapt to the endianness of the input ** adapt to the endianness of the input
*/ */
#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0])) #define loadVector(S,b,n) loadBlock(S,b,(n)*sizeof((b)[0]))
static void LoadBlock (LoadState *S, void *b, size_t size) { static void loadBlock (LoadState *S, void *b, size_t size) {
if (luaZ_read(S->Z, b, size) != 0) if (luaZ_read(S->Z, b, size) != 0)
error(S, "truncated chunk"); error(S, "truncated chunk");
} }
#define LoadVar(S,x) LoadVector(S,&x,1) #define loadVar(S,x) loadVector(S,&x,1)
static lu_byte LoadByte (LoadState *S) { static lu_byte loadByte (LoadState *S) {
int b = zgetc(S->Z); int b = zgetc(S->Z);
if (b == EOZ) if (b == EOZ)
error(S, "truncated chunk"); error(S, "truncated chunk");
@@ -66,12 +66,12 @@ static lu_byte LoadByte (LoadState *S) {
} }
static size_t LoadUnsigned (LoadState *S, size_t limit) { static size_t loadUnsigned (LoadState *S, size_t limit) {
size_t x = 0; size_t x = 0;
int b; int b;
limit >>= 7; limit >>= 7;
do { do {
b = LoadByte(S); b = loadByte(S);
if (x >= limit) if (x >= limit)
error(S, "integer overflow"); error(S, "integer overflow");
x = (x << 7) | (b & 0x7f); x = (x << 7) | (b & 0x7f);
@@ -80,45 +80,45 @@ static size_t LoadUnsigned (LoadState *S, size_t limit) {
} }
static size_t LoadSize (LoadState *S) { static size_t loadSize (LoadState *S) {
return LoadUnsigned(S, ~(size_t)0); return loadUnsigned(S, ~(size_t)0);
} }
static int LoadInt (LoadState *S) { static int loadInt (LoadState *S) {
return cast_int(LoadUnsigned(S, INT_MAX)); return cast_int(loadUnsigned(S, INT_MAX));
} }
static lua_Number LoadNumber (LoadState *S) { static lua_Number loadNumber (LoadState *S) {
lua_Number x; lua_Number x;
LoadVar(S, x); loadVar(S, x);
return x; return x;
} }
static lua_Integer LoadInteger (LoadState *S) { static lua_Integer loadInteger (LoadState *S) {
lua_Integer x; lua_Integer x;
LoadVar(S, x); loadVar(S, x);
return x; return x;
} }
/* /*
** Load a nullable string ** Load a nullable string.
*/ */
static TString *LoadStringN (LoadState *S) { static TString *loadStringN (LoadState *S) {
size_t size = LoadSize(S); size_t size = loadSize(S);
if (size == 0) if (size == 0)
return NULL; return NULL;
else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
char buff[LUAI_MAXSHORTLEN]; char buff[LUAI_MAXSHORTLEN];
LoadVector(S, buff, size); loadVector(S, buff, size);
return luaS_newlstr(S->L, buff, size); return luaS_newlstr(S->L, buff, size);
} }
else { /* long string */ else { /* long string */
TString *ts = luaS_createlngstrobj(S->L, size); TString *ts = luaS_createlngstrobj(S->L, size);
LoadVector(S, getstr(ts), size); /* load directly in final place */ loadVector(S, getstr(ts), size); /* load directly in final place */
return ts; return ts;
} }
} }
@@ -127,35 +127,35 @@ static TString *LoadStringN (LoadState *S) {
/* /*
** Load a non-nullable string. ** Load a non-nullable string.
*/ */
static TString *LoadString (LoadState *S) { static TString *loadString (LoadState *S) {
TString *st = LoadStringN(S); TString *st = loadStringN(S);
if (st == NULL) if (st == NULL)
error(S, "bad format for constant string"); error(S, "bad format for constant string");
return st; return st;
} }
static void LoadCode (LoadState *S, Proto *f) { static void loadCode (LoadState *S, Proto *f) {
int n = LoadInt(S); int n = loadInt(S);
f->code = luaM_newvectorchecked(S->L, n, Instruction); f->code = luaM_newvectorchecked(S->L, n, Instruction);
f->sizecode = n; f->sizecode = n;
LoadVector(S, f->code, n); loadVector(S, f->code, n);
} }
static void LoadFunction(LoadState *S, Proto *f, TString *psource); static void loadFunction(LoadState *S, Proto *f, TString *psource);
static void LoadConstants (LoadState *S, Proto *f) { static void loadConstants (LoadState *S, Proto *f) {
int i; int i;
int n = LoadInt(S); int n = loadInt(S);
f->k = luaM_newvectorchecked(S->L, n, TValue); f->k = luaM_newvectorchecked(S->L, n, TValue);
f->sizek = n; f->sizek = n;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
setnilvalue(&f->k[i]); setnilvalue(&f->k[i]);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
TValue *o = &f->k[i]; TValue *o = &f->k[i];
int t = LoadByte(S); int t = loadByte(S);
switch (t) { switch (t) {
case LUA_VNIL: case LUA_VNIL:
setnilvalue(o); setnilvalue(o);
@@ -167,14 +167,14 @@ static void LoadConstants (LoadState *S, Proto *f) {
setbtvalue(o); setbtvalue(o);
break; break;
case LUA_VNUMFLT: case LUA_VNUMFLT:
setfltvalue(o, LoadNumber(S)); setfltvalue(o, loadNumber(S));
break; break;
case LUA_VNUMINT: case LUA_VNUMINT:
setivalue(o, LoadInteger(S)); setivalue(o, loadInteger(S));
break; break;
case LUA_VSHRSTR: case LUA_VSHRSTR:
case LUA_VLNGSTR: case LUA_VLNGSTR:
setsvalue2n(S->L, o, LoadString(S)); setsvalue2n(S->L, o, loadString(S));
break; break;
default: lua_assert(0); default: lua_assert(0);
} }
@@ -182,91 +182,91 @@ static void LoadConstants (LoadState *S, Proto *f) {
} }
static void LoadProtos (LoadState *S, Proto *f) { static void loadProtos (LoadState *S, Proto *f) {
int i; int i;
int n = LoadInt(S); int n = loadInt(S);
f->p = luaM_newvectorchecked(S->L, n, Proto *); f->p = luaM_newvectorchecked(S->L, n, Proto *);
f->sizep = n; f->sizep = n;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
f->p[i] = NULL; f->p[i] = NULL;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
f->p[i] = luaF_newproto(S->L); f->p[i] = luaF_newproto(S->L);
LoadFunction(S, f->p[i], f->source); loadFunction(S, f->p[i], f->source);
} }
} }
static void LoadUpvalues (LoadState *S, Proto *f) { static void loadUpvalues (LoadState *S, Proto *f) {
int i, n; int i, n;
n = LoadInt(S); n = loadInt(S);
f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc); f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc);
f->sizeupvalues = n; f->sizeupvalues = n;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
f->upvalues[i].name = NULL; f->upvalues[i].name = NULL;
f->upvalues[i].instack = LoadByte(S); f->upvalues[i].instack = loadByte(S);
f->upvalues[i].idx = LoadByte(S); f->upvalues[i].idx = loadByte(S);
f->upvalues[i].kind = LoadByte(S); f->upvalues[i].kind = loadByte(S);
} }
} }
static void LoadDebug (LoadState *S, Proto *f) { static void loadDebug (LoadState *S, Proto *f) {
int i, n; int i, n;
n = LoadInt(S); n = loadInt(S);
f->lineinfo = luaM_newvectorchecked(S->L, n, ls_byte); f->lineinfo = luaM_newvectorchecked(S->L, n, ls_byte);
f->sizelineinfo = n; f->sizelineinfo = n;
LoadVector(S, f->lineinfo, n); loadVector(S, f->lineinfo, n);
n = LoadInt(S); n = loadInt(S);
f->abslineinfo = luaM_newvectorchecked(S->L, n, AbsLineInfo); f->abslineinfo = luaM_newvectorchecked(S->L, n, AbsLineInfo);
f->sizeabslineinfo = n; f->sizeabslineinfo = n;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
f->abslineinfo[i].pc = LoadInt(S); f->abslineinfo[i].pc = loadInt(S);
f->abslineinfo[i].line = LoadInt(S); f->abslineinfo[i].line = loadInt(S);
} }
n = LoadInt(S); n = loadInt(S);
f->locvars = luaM_newvectorchecked(S->L, n, LocVar); f->locvars = luaM_newvectorchecked(S->L, n, LocVar);
f->sizelocvars = n; f->sizelocvars = n;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
f->locvars[i].varname = NULL; f->locvars[i].varname = NULL;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
f->locvars[i].varname = LoadStringN(S); f->locvars[i].varname = loadStringN(S);
f->locvars[i].startpc = LoadInt(S); f->locvars[i].startpc = loadInt(S);
f->locvars[i].endpc = LoadInt(S); f->locvars[i].endpc = loadInt(S);
} }
n = LoadInt(S); n = loadInt(S);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
f->upvalues[i].name = LoadStringN(S); f->upvalues[i].name = loadStringN(S);
} }
static void LoadFunction (LoadState *S, Proto *f, TString *psource) { static void loadFunction (LoadState *S, Proto *f, TString *psource) {
f->source = LoadStringN(S); f->source = loadStringN(S);
if (f->source == NULL) /* no source in dump? */ if (f->source == NULL) /* no source in dump? */
f->source = psource; /* reuse parent's source */ f->source = psource; /* reuse parent's source */
f->linedefined = LoadInt(S); f->linedefined = loadInt(S);
f->lastlinedefined = LoadInt(S); f->lastlinedefined = loadInt(S);
f->numparams = LoadByte(S); f->numparams = loadByte(S);
f->is_vararg = LoadByte(S); f->is_vararg = loadByte(S);
f->maxstacksize = LoadByte(S); f->maxstacksize = loadByte(S);
LoadCode(S, f); loadCode(S, f);
LoadConstants(S, f); loadConstants(S, f);
LoadUpvalues(S, f); loadUpvalues(S, f);
LoadProtos(S, f); loadProtos(S, f);
LoadDebug(S, f); loadDebug(S, f);
} }
static void checkliteral (LoadState *S, const char *s, const char *msg) { static void checkliteral (LoadState *S, const char *s, const char *msg) {
char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */ char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */
size_t len = strlen(s); size_t len = strlen(s);
LoadVector(S, buff, len); loadVector(S, buff, len);
if (memcmp(s, buff, len) != 0) if (memcmp(s, buff, len) != 0)
error(S, msg); error(S, msg);
} }
static void fchecksize (LoadState *S, size_t size, const char *tname) { static void fchecksize (LoadState *S, size_t size, const char *tname) {
if (LoadByte(S) != size) if (loadByte(S) != size)
error(S, luaO_pushfstring(S->L, "%s size mismatch", tname)); error(S, luaO_pushfstring(S->L, "%s size mismatch", tname));
} }
@@ -276,23 +276,23 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
static void checkHeader (LoadState *S) { static void checkHeader (LoadState *S) {
/* skip 1st char (already read and checked) */ /* skip 1st char (already read and checked) */
checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk"); checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk");
if (LoadInt(S) != LUAC_VERSION) if (loadInt(S) != LUAC_VERSION)
error(S, "version mismatch"); error(S, "version mismatch");
if (LoadByte(S) != LUAC_FORMAT) if (loadByte(S) != LUAC_FORMAT)
error(S, "format mismatch"); error(S, "format mismatch");
checkliteral(S, LUAC_DATA, "corrupted chunk"); checkliteral(S, LUAC_DATA, "corrupted chunk");
checksize(S, Instruction); checksize(S, Instruction);
checksize(S, lua_Integer); checksize(S, lua_Integer);
checksize(S, lua_Number); checksize(S, lua_Number);
if (LoadInteger(S) != LUAC_INT) if (loadInteger(S) != LUAC_INT)
error(S, "integer format mismatch"); error(S, "integer format mismatch");
if (LoadNumber(S) != LUAC_NUM) if (loadNumber(S) != LUAC_NUM)
error(S, "float format mismatch"); error(S, "float format mismatch");
} }
/* /*
** load precompiled chunk ** Load precompiled chunk.
*/ */
LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {
LoadState S; LoadState S;
@@ -306,11 +306,11 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {
S.L = L; S.L = L;
S.Z = Z; S.Z = Z;
checkHeader(&S); checkHeader(&S);
cl = luaF_newLclosure(L, LoadByte(&S)); cl = luaF_newLclosure(L, loadByte(&S));
setclLvalue2s(L, L->top, cl); setclLvalue2s(L, L->top, cl);
luaD_inctop(L); luaD_inctop(L);
cl->p = luaF_newproto(L); cl->p = luaF_newproto(L);
LoadFunction(&S, cl->p, NULL); loadFunction(&S, cl->p, NULL);
lua_assert(cl->nupvalues == cl->p->sizeupvalues); lua_assert(cl->nupvalues == cl->p->sizeupvalues);
luai_verifycode(L, buff, cl->p); luai_verifycode(L, buff, cl->p);
return cl; return cl;