static void LoadConstants (LoadState *S, Proto *f) { int i; int n = LoadInt(S); f->k = luaM_newvector(S->L, n, TValue); f->sizek = n; for (i = 0; i < n; i++) setnilvalue(&f->k[i]); for (i = 0; i < n; i++) { TValue *o = &f->k[i]; int t = LoadByte(S); switch (t) { case LUA_TNIL: setnilvalue(o); break; case LUA_TBOOLEAN: setbvalue(o, LoadByte(S)); break; case LUA_TNUMFLT: setfltvalue(o, LoadNumber(S)); break; case LUA_TNUMINT: setivalue(o, LoadInteger(S)); break; case LUA_TSHRSTR: case LUA_TLNGSTR: setsvalue2n(S->L, o, LoadString(S)); break; default: lua_assert(0); } } }
static void LoadHeader (LoadState* S) { int version; lua_Number x,tx=TEST_NUMBER; LoadSignature(S); version=LoadByte(S); if (version>VERSION) luaG_runerror(S->L,"%s too new: " "read version %d.%d; expected at most %d.%d", S->name,V(version),V(VERSION)); if (version<VERSION0) /* check last major change */ luaG_runerror(S->L,"%s too old: " "read version %d.%d; expected at least %d.%d", S->name,V(version),V(VERSION0)); S->swap=(luaU_endianness()!=LoadByte(S)); /* need to swap bytes? */ TESTSIZE(sizeof(int),"int"); TESTSIZE(sizeof(size_t), "size_t"); TESTSIZE(sizeof(Instruction), "Instruction"); TESTSIZE(SIZE_OP, "OP"); TESTSIZE(SIZE_A, "A"); TESTSIZE(SIZE_B, "B"); TESTSIZE(SIZE_C, "C"); TESTSIZE(sizeof(lua_Number), "number"); x=LoadNumber(S); if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ luaG_runerror(S->L,"unknown number format in %s",S->name); }
static Proto * LoadFunction(LoadState * S, TString * p) { Proto* f; if(++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); f=luaF_newproto(S->L); setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->source=LoadString(S); if(f->source==NULL) f->source=p; f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); f->nups=LoadByte(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadCode(S,f); LoadConstants(S,f); LoadDebug(S,f); IF (!luaG_checkcode(f), "bad code"); S->L->top--; S->L->nCcalls--; return f; }
static void LoadUpvalues (LoadState *S, Proto *f) { int i, n; n = LoadInt(S); f->upvalues = luaM_newvector(S->L, n, Upvaldesc); f->sizeupvalues = n; for (i = 0; i < n; i++) f->upvalues[i].name = NULL; for (i = 0; i < n; i++) { f->upvalues[i].instack = LoadByte(S); f->upvalues[i].idx = LoadByte(S); } }
static void LoadFunction(LoadState* S, Proto* f) { f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadCode(S,f); LoadConstants(S,f); LoadUpvalues(S,f); LoadDebug(S,f); }
static void LoadFunction (LoadState *S, Proto *f, TString *psource) { f->source = LoadString(S); if (f->source == NULL) /* no source in dump? */ f->source = psource; /* reuse parent's source */ f->linedefined = LoadInt(S); f->lastlinedefined = LoadInt(S); f->numparams = LoadByte(S); f->is_vararg = LoadByte(S); f->maxstacksize = LoadByte(S); LoadCode(S, f); LoadConstants(S, f); LoadUpvalues(S, f); LoadProtos(S, f); LoadDebug(S, f); }
static Proto* LoadFunction(LoadState* S) { Proto* f=luaF_newproto(S->L); setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadCode(S,f); LoadConstants(S,f); LoadUpvalues(S,f); LoadDebug(S,f); S->L->top--; return f; }
static void TestSize (LoadState* S, int s, const char* what) { int r=LoadByte(S); if (r!=s) luaG_runerror(S->L,"virtual machine mismatch in %s: " "size of %s is %d but read %d",S->name,what,s,r); }
TiffUintField::TiffUintField(IFDEntry &entry, BPositionIO &io, swap_action swp) : TiffField(entry) { if (entry.count > 0) { switch (entry.fieldType) { case TIFF_BYTE: fpByte = NULL; LoadByte(entry, io, swp); break; case TIFF_SHORT: fpShort = NULL; LoadShort(entry, io, swp); break; case TIFF_LONG: fpLong = NULL; LoadLong(entry, io, swp); break; default: finitStatus = B_BAD_TYPE; break; } } else finitStatus = B_BAD_VALUE; }
static void LoadConstants (LoadState* S, Proto* f) { int i,n; n=LoadInt(S); f->k=luaM_newvector(S->L,n,TObject); f->sizek=n; for (i=0; i<n; i++) { TObject* o=&f->k[i]; int t=LoadByte(S); switch (t) { case LUA_TNUMBER: setnvalue(o,LoadNumber(S)); break; case LUA_TSTRING: setsvalue2n(o,LoadString(S)); break; case LUA_TNIL: setnilvalue(o); break; default: luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name); break; } } n=LoadInt(S); f->p=luaM_newvector(S->L,n,Proto*); f->sizep=n; for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); }
int i8080_hal_io_input(int port) { if (use_io_space) return LoadPort(port); else return LoadByte((port & 0xff)<<8 | (port & 0xff)); }
static void checkHeader (LoadState *S) { checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ if (LoadByte(S) != LUAC_VERSION) error(S, "version mismatch in"); if (LoadByte(S) != LUAC_FORMAT) error(S, "format mismatch in"); checkliteral(S, LUAC_DATA, "corrupted"); checksize(S, int); checksize(S, size_t); checksize(S, Instruction); checksize(S, lua_Integer); checksize(S, lua_Number); if (LoadInteger(S) != LUAC_INT) error(S, "endianness mismatch in"); if (LoadNumber(S) != LUAC_NUM) error(S, "float format mismatch in"); }
static Proto* LoadFunction (LoadState* S, TString* p) { Proto* f=luaF_newproto(S->L); f->source=LoadString(S); if (f->source==NULL) f->source=p; f->lineDefined=LoadInt(S); f->nups=LoadByte(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadLines(S,f); LoadLocals(S,f); LoadUpvalues(S,f); LoadConstants(S,f); LoadCode(S,f); #ifndef TRUST_BINARIES if (!luaG_checkcode(f)) luaG_runerror(S->L,"bad code in %s",S->name); #endif return f; }
static Proto* LoadFunction(LoadState* S, TString* p) { Proto* f=luaF_newproto(S->L); setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->source=LoadString(S); if (f->source==NULL) f->source=p; f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); f->nups=LoadByte(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadLines(S,f); LoadLocals(S,f); LoadUpvalues(S,f); LoadConstants(S,f); LoadCode(S,f); IF (!luaG_checkcode(f), "bad code"); S->L->top--; return f; }
static TString *LoadString (LoadState *S) { size_t size = LoadByte(S); if (size == 0xFF) LoadVar(S, size); if (size == 0) return NULL; else { char *s = luaZ_openspace(S->L, S->b, --size); LoadVector(S, s, size); return luaS_newlstr(S->L, s, size); } }
static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap) { Proto* tf=luaF_newproto(L); tf->source=LoadString(L,Z,swap); tf->lineDefined=LoadInt(L,Z,swap); tf->numparams=LoadInt(L,Z,swap); tf->is_vararg=LoadByte(L,Z); tf->maxstacksize=LoadInt(L,Z,swap); LoadLocals(L,tf,Z,swap); LoadLines(L,tf,Z,swap); LoadConstants(L,tf,Z,swap); LoadCode(L,tf,Z,swap); return tf; }
static TString *LoadString (LoadState *S) { size_t size = LoadByte(S); if (size == 0xFF) LoadVar(S, size); if (size == 0) return NULL; else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ char buff[LUAI_MAXSHORTLEN]; LoadVector(S, buff, size); return luaS_newlstr(S->L, buff, size); } else { /* long string */ TString *ts = luaS_createlngstrobj(S->L, size); LoadVector(S, getstr(ts), size); /* load directly in final place */ return ts; } }
/* ** load precompiled chunk */ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { LoadState S; LClosure *cl; if (*name == '@' || *name == '=') S.name = name + 1; else if (*name == LUA_SIGNATURE[0]) S.name = "binary string"; else S.name = name; S.L = L; S.Z = Z; checkHeader(&S); cl = luaF_newLclosure(L, LoadByte(&S)); setclLvalue(L, L->top, cl); luaD_inctop(L); cl->p = luaF_newproto(L); LoadFunction(&S, cl->p, NULL); lua_assert(cl->nupvalues == cl->p->sizeupvalues); luai_verifycode(L, buff, cl->p); return cl; }
int i8080_hal_memory_read_byte(int addr) { return LoadByte(addr & 0xffff); }
static void fchecksize (LoadState *S, size_t size, const char *tname) { if (LoadByte(S) != size) error(S, luaO_pushfstring(S->L, "%s size mismatch in", tname)); }