diff --git a/profile/3.3.5a-windows-386/include/lua/lex.h b/profile/3.3.5a-windows-386/include/lua/lex.h new file mode 100644 index 0000000..280b5df --- /dev/null +++ b/profile/3.3.5a-windows-386/include/lua/lex.h @@ -0,0 +1,34 @@ +#ifndef LUA_LEX_H +#define LUA_LEX_H + +DECLARE_UNION(SemInfo); +DECLARE_STRUCT(LexState); + +#include "lua/parser.h" +#include "lua/state.h" + +union SemInfo { + lua_Number r; + TString* ts; +}; /* semantics information */ + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + +struct LexState { + int32_t current; /* current character (charint) */ + int32_t linenumber; /* input line counter */ + int32_t lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + FuncState* fs; /* `FuncState' is private to the parser */ + lua_State* L; + ZIO* z; /* input stream */ + Mbuffer* buff; /* buffer for tokens */ + TString* source; /* current source name */ + char decpoint; /* locale decimal point */ +}; + +#endif diff --git a/profile/3.3.5a-windows-386/include/lua/object.h b/profile/3.3.5a-windows-386/include/lua/object.h index d5b3044..b5ba7b3 100644 --- a/profile/3.3.5a-windows-386/include/lua/object.h +++ b/profile/3.3.5a-windows-386/include/lua/object.h @@ -140,6 +140,7 @@ struct UpVal { struct CClosure { GCObject* next; + uint32_t unk04; lu_byte tt; lu_byte marked; lu_byte isC; @@ -155,7 +156,7 @@ struct LClosure { lu_byte tt; lu_byte marked; lu_byte isC; - lu_byte nupvalues; + lu_byte nupvalues; // accessed at GCObject* gclist; Table* env; Proto* p; diff --git a/profile/3.3.5a-windows-386/include/lua/parser.h b/profile/3.3.5a-windows-386/include/lua/parser.h new file mode 100644 index 0000000..36f5c69 --- /dev/null +++ b/profile/3.3.5a-windows-386/include/lua/parser.h @@ -0,0 +1,44 @@ +#ifndef LUA_PARSER_H +#define LUA_PARSER_H + +DECLARE_STRUCT(upvaldesc); +DECLARE_STRUCT(BlockCnt); +DECLARE_STRUCT(FuncState); + +#include "lua/lex.h" +#include "lua/object.h" +#include "lua/types.h" + +struct upvaldesc { + lu_byte k; + lu_byte info; +}; + +struct BlockCnt { + BlockCnt* previous; + int32_t breaklist; + lu_byte nactvar; + lu_byte upval; + lu_byte isbreakable; +}; + +struct FuncState { + Proto* f; + Table* h; + FuncState* prev; + LexState* ls; + lua_State* L; + BlockCnt* bl; + int32_t pc; + int32_t lasttarget; + int32_t jpc; + int32_t freereg; + int32_t nk; + int32_t np; + int16_t nlocvars; + lu_byte nactvar; + upvaldesc upvalues[60]; + uint16_t actvar[200]; +}; + +#endif diff --git a/profile/3.3.5a-windows-386/include/lua/state.h b/profile/3.3.5a-windows-386/include/lua/state.h index 89fb97e..9008c81 100644 --- a/profile/3.3.5a-windows-386/include/lua/state.h +++ b/profile/3.3.5a-windows-386/include/lua/state.h @@ -13,6 +13,7 @@ DECLARE_STRUCT(LG); #include "lua/object.h" #include "lua/types.h" +#include "lua/zio.h" struct stringtable { GCObject** hash; diff --git a/profile/3.3.5a-windows-386/include/lua/types.h b/profile/3.3.5a-windows-386/include/lua/types.h index 8a9791b..73e32ed 100644 --- a/profile/3.3.5a-windows-386/include/lua/types.h +++ b/profile/3.3.5a-windows-386/include/lua/types.h @@ -8,18 +8,19 @@ DECLARE_STRUCT(lua_State); DECLARE_STRUCT(lua_Debug); -DECLARE_STRUCT(Mbuffer); DECLARE_UNION(L_Umaxalign); DECLARE_STRUCT(lua_longjmp); DECLARE_STRUCT(luaL_Reg); -struct Mbuffer { - char* buffer; - size_t n; - size_t buffsize; -}; +DECLARE_ENUM(OpArgMask); +DECLARE_ENUM(OpMode); +DECLARE_ENUM(OpCode); -typedef void (*lua_Hook)(lua_State*, lua_Debug*); +typedef const char* (*lua_Reader_interface)(lua_State* L, void* ud, size_t* sz); +typedef lua_Reader_interface lua_Reader; + +typedef void (*lua_Hook_interface)(lua_State*, lua_Debug*); +typedef lua_Hook_interface lua_Hook; typedef uint8_t lu_byte; @@ -56,4 +57,73 @@ struct luaL_Reg { lua_CFunction func; }; +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +enum OpMode { iABC, iABx, iAsBx }; + +enum OpCode { + /*---------------------------------------------------------------------- + name args description + ------------------------------------------------------------------------*/ + OP_MOVE, /* A B R(A) := R(B) */ + OP_LOADK, /* A Bx R(A) := Kst(Bx) */ + OP_LOADBOOL, /* A B C R(A) := (Bool)B; if (C) pc++ */ + OP_LOADNIL, /* A B R(A) := ... := R(B) := nil */ + OP_GETUPVAL, /* A B R(A) := UpValue[B] */ + + OP_GETGLOBAL, /* A Bx R(A) := Gbl[Kst(Bx)] */ + OP_GETTABLE, /* A B C R(A) := R(B)[RK(C)] */ + + OP_SETGLOBAL, /* A Bx Gbl[Kst(Bx)] := R(A) */ + OP_SETUPVAL, /* A B UpValue[B] := R(A) */ + OP_SETTABLE, /* A B C R(A)[RK(B)] := RK(C) */ + + OP_NEWTABLE, /* A B C R(A) := {} (size = B,C) */ + + OP_SELF, /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */ + + OP_ADD, /* A B C R(A) := RK(B) + RK(C) */ + OP_SUB, /* A B C R(A) := RK(B) - RK(C) */ + OP_MUL, /* A B C R(A) := RK(B) * RK(C) */ + OP_DIV, /* A B C R(A) := RK(B) / RK(C) */ + OP_MOD, /* A B C R(A) := RK(B) % RK(C) */ + OP_POW, /* A B C R(A) := RK(B) ^ RK(C) */ + OP_UNM, /* A B R(A) := -R(B) */ + OP_NOT, /* A B R(A) := not R(B) */ + OP_LEN, /* A B R(A) := length of R(B) */ + + OP_CONCAT, /* A B C R(A) := R(B).. ... ..R(C) */ + + OP_JMP, /* sBx pc+=sBx */ + + OP_EQ, /* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ + OP_LT, /* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ + OP_LE, /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ + + OP_TEST, /* A C if not (R(A) <=> C) then pc++ */ + OP_TESTSET, /* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + + OP_CALL, /* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ + OP_TAILCALL, /* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ + OP_RETURN, /* A B return R(A), ... ,R(A+B-2) (see note) */ + + OP_FORLOOP, /* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ + OP_CLOSURE, /* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + + OP_VARARG /* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +}; + #endif diff --git a/profile/3.3.5a-windows-386/include/lua/zio.h b/profile/3.3.5a-windows-386/include/lua/zio.h new file mode 100644 index 0000000..f9fd97e --- /dev/null +++ b/profile/3.3.5a-windows-386/include/lua/zio.h @@ -0,0 +1,25 @@ +#ifndef LUA_ZIO_H +#define LUA_ZIO_H + +DECLARE_STRUCT(Mbuffer); +DECLARE_STRUCT(Zio); +typedef Zio ZIO; + +struct Mbuffer { + char* buffer; + size_t n; + size_t buffsize; +}; + +#include "lua/state.h" +#include "lua/types.h" + +struct Zio { + size_t n; /* bytes still unread */ + const char* p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State* L; /* Lua state (for reader) */ +}; + +#endif diff --git a/profile/3.3.5a-windows-386/include/main.h b/profile/3.3.5a-windows-386/include/main.h index 5f80fd3..5cb4c49 100644 --- a/profile/3.3.5a-windows-386/include/main.h +++ b/profile/3.3.5a-windows-386/include/main.h @@ -10,7 +10,9 @@ #include "external/d3d9/d3d9.h" #include "lua/debug.h" +#include "lua/lex.h" #include "lua/object.h" +#include "lua/parser.h" #include "lua/state.h" #include "lua/types.h" diff --git a/profile/3.3.5a-windows-386/symbol/lua/func.sym b/profile/3.3.5a-windows-386/symbol/lua/func.sym index a0fe4b4..452d025 100644 --- a/profile/3.3.5a-windows-386/symbol/lua/func.sym +++ b/profile/3.3.5a-windows-386/symbol/lua/func.sym @@ -11,7 +11,49 @@ luaG_concaterror 00850BF0 f end=00850C13 type="void __stdcall func(lua_State* L, luaG_typeerror 00850B60 f end=00850BEC type="void __stdcall func(lua_State* L, TValue* o, char* op)" getobjname 008505A0 f end=008506F9 type="char* __usercall func@(lua_State* L, CallInfo* ci, int32_t stackpos@, char** name)" symbexec 00850130 f end=0085050D type="Instruction __stdcall func(Proto* pt, int32_t lastpc, int32_t reg)" -checkArgMode 008500E0 f end=0085012C +luaG_checkopenop 008500B0 f end=008500DC type="bool __stdcall func(Instruction i)" +checkArgMode 008500E0 f end=0085012C type="int32_t __usercall func@(Proto* pt@, int32_t r@, OpArgMask mode@)" +kname 00850570 f end=00850596 type="char* __usercall func@(Proto* p@, int32_t c@)" +auxgetinfo 00850950 f end=00850A4C type="int32_t __usercall func@(lua_State* L, char* what, lua_Debug* ar@, Closure* f, CallInfo* ci@)" +funcinfo 0084FF80 f end=0084FFF4 type="void __usercall func(lua_Debug* ar@, Closure* cl@)" +currentline 0084FDF0 f end=0084FE33 type="int32_t __usercall func@(lua_State* L@, CallInfo* ci@)" +getfuncname 00850720 f end=008507C0 type="char* __usercall func@(lua_State* L@, CallInfo* ci@, char** name)" +collectvalidlines 00850000 f end=008500AD type="void __usercall func(lua_State* L@, Closure* f@)" +luaH_setnum 0085C590 f end=0085C5DA type="TValue* __stdcall func(lua_State* L, Table* t, int32_t key)" +luaH_getnum 0085C3A0 f end=0085C427 type="TValue* __stdcall func(Table* t, int32_t key)" +mainposition 0085BCB0 f end=0085BD56 type="Node* __usercall func@(Table* t@, TValue* key@)" +hashnum 0085BC70 f end=0085BCA6 type="Node* __usercall func@(Table* t@, lua_Number n)" +newkey 0085CAB0 f end=0085CBB4 type="TValue* __stdcall func(lua_State* L, Table* t, TValue* key)" +luaH_set 0085C520 f end=0085C582 type="void __stdcall func(lua_State* L, Table* t, TValue* key)" +numusearray 0085C050 f end=0085C0CD type="int32_t __stdcall func(Table* t, int32_t* nums)" +numusehash 0085C0D0 f end=0085C189 type="int32_t __usercall func@(Table* t@, int32_t* nums, int32_t* pnasize)" +computesizes 0085BFD0 f end=0085C04D type="int32_t __stdcall func(int32_t* nums, int32_t* narray)" +resize 0085C6F0 f end=0085C95A type="void __usercall func(lua_State* L, Table* t@, int32_t nasize@, int32_t nhsize)" +rehash 0085C9B0 f end=0085CAA3 type="void __usercall func(lua_State* L, Table* t@, TValue* ek@)" +luaH_setstr 0085CBC0 f end=0085CC08 type="void __stdcall func(lua_State* L, Table* t, TString* key)" +luaX_newstring 0085DA00 f end=0085DA50 type="TString* __stdcall func(LexState* ls, char* str, size_t l)" +save 0085D810 f end=0085D884 type="void __usercall func(LexState* ls@, char c)" +luaX_lexerror 0085D940 f end=0085D9D3 type="void __stdcall func(LexState* ls, char* msg, int32_t token)" +luaO_pushfstring 0084D840 f end=0084D859 type="char* __stdcall func(lua_State* L, char* fmt, ...)" +luaX_token2str 0085D8E0 f end=0085D935 type="char* __stdcall func(LexState* ls, int32_t token)" +llex 0085E600 f end=0085EBF6 type="int32_t __usercall func@(LexState* ls@, SemInfo* seminfo)" +luaZ_fill 0085D0F0 f end=0085D132 type="int32_t __stdcall func(ZIO* z)" +inclinenumber 0085DA50 f end=0085DADC type="void __usercall func(LexState* ls@)" +read_string 0085E160 f end=0085E4E8 type="void __stdcall func(LexState* ls, int32_t del, SemInfo* seminfo)" +skip_sep 0085DDD0 f end=0085DE67 type="int32_t __stdcall func@(LexState* ls@)" +read_long_string 0085DE70 f end=0085E0E9 type="void __usercall func(LexState* ls@, SemInfo* seminfo@, int32_t sep)" +check_next 0085DB70 f end=0085DBCB type="int32_t __usercall func@(LexState* ls@, char* set@)" +luaO_str2d 0084D480 f end=0084D51D type="bool __stdcall func(char* s, lua_Number* result)" +trydecpoint 0085DBD0 f end=0085DCAF type="void __usercall func(LexState* ls@, SemInfo* seminfo)" +read_numeral 0085DCB0 f end=0085DDC1 type="void __usercall func(LexState* ls@, SemInfo* seminfo@)" +luaX_lookahead 0085ED00 f end=0085ED1B type="void __stdcall func(LexState* ls)" +luaX_next 0085ECB0 f end=0085ECF9 type="void __stdcall func(LexState* ls)" ; TODO: understand changes to structures +testnext 0085ED70 f end=0085ED8F type="int32_t __usercall func@(LexState* ls@, int32_t c)" +check_match 0085ED90 f end=0085EDFE type="void __usercall func(LexState* ls@, int32_t what@, int32_t who, int32_t where@)" +singlevar 0085F1F0 f end=0085F24F type="void __usercall func(LexState* ls@, expdesc* var@)" +singlevaraux 0085F100 f end=0085F1E2 type="int32_t __stdcall func(FuncState* fs, TString* n, expdesc* var, int base)" +indexupvalue 0085EFB0 f end=0085F0FB type="int32_t __stdcall func(FuncState* fs, TString* name, expdesc* v)" +luaM_growaux_ 0085D740 f end=0085D805 type="int32_t __stdcall func(lua_State* L, void* block, int32_t* size, size_t size_elems, int32_t limit, char* errormsg)" lua_checkstack 0084DAB0 f end=0084DB06 lua_xmove 0084DB10 f end=0084DB90 lua_newthread 0084DB90 f end=0084DBD0 @@ -116,7 +158,7 @@ luaC_gettime 0085B5A0 f end=0085B602 luaC_step 0085B950 f end=0085B9D2 luaC_fullgc 0085B9E0 f end=0085BA4B luaC_barrierf 0085BA50 f end=0085BA83 -luaC_barrierback 0085BA90 f end=0085BAAB +luaC_barrierback 0085BA90 f end=0085BAAB type="void __stdcall func(lua_State* L, Table* t)" luaC_link 0085BAB0 f end=0085BAF1 luaT_gettm 0085BBE0 f end=0085BC09 luaT_gettmbyobj 0085BC10 f end=0085BC67 @@ -163,8 +205,8 @@ luaL_openlib 0084FC00 f end=0084FD1E lua_getlocal 0084FEC0 f end=0084FF26 luaG_errormsg 00850830 f end=0085091E luaG_ordererror 00850C60 f end=00850CB2 -_luaopen_string 00854070 f end=008540C3 -_luaopen_base 00854F40 f end=0085505E +createmetatable 00854070 f end=008540C3 type="void __usercall func(lua_State* L@)" +base_open 00854F40 f end=0085505E type="void __usercall func(lua_State* L@)" luaD_pcall 00855A20 f end=00855AD6 lua_yield 00856150 f end=00856184 luaV_gettable 00857250 f end=008573B5 diff --git a/profile/3.3.5a-windows-386/symbol/lua/label.sym b/profile/3.3.5a-windows-386/symbol/lua/label.sym index 5f81345..a4fd508 100644 --- a/profile/3.3.5a-windows-386/symbol/lua/label.sym +++ b/profile/3.3.5a-windows-386/symbol/lua/label.sym @@ -7,3 +7,4 @@ lua_taintexpected 00D413A0 l type="int32_t" lua_taintedclosure 00D413A4 l type="int32_t" luaT_typenames 00A48208 l type="char*[11]" luaP_opmodes 00A484B4 l type="lu_byte[38]" +luaX_tokens 00A48588 l type="char*[32]" diff --git a/profile/3.3.5a-windows-386/symbol/stdlib/func.sym b/profile/3.3.5a-windows-386/symbol/stdlib/func.sym new file mode 100644 index 0000000..2be8d43 --- /dev/null +++ b/profile/3.3.5a-windows-386/symbol/stdlib/func.sym @@ -0,0 +1 @@ +strtod 0088E9C1 f end=0088E9D4 type="double __stdcall func(char* str, char** endptr)"