From d9c2d065698641837bc75ded236b23d5aaa36fd4 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Sep 2020 20:55:10 +0800 Subject: *table string comment --- luatest.sln | 20 --- luatest/luatest.vcxproj | 3 +- luatest/luatest.vcxproj.filters | 243 ++++++++++++++------------- math/math.vcxproj | 130 -------------- math/math.vcxproj.filters | 9 - math/math.vcxproj.user | 4 - src/00-misc/math_return_table/init.lua | 0 src/00-misc/math_return_table/matrix.lua | 0 src/00-misc/math_return_table/misc/guid.lua | 0 src/00-misc/math_return_table/misc/init.lua | 0 src/00-misc/math_return_table/misc/lerp.lua | 0 src/00-misc/math_return_table/misc/rand.lua | 0 src/00-misc/math_return_table/misc/uuid.lua | 0 src/00-misc/math_return_table/quaternion.lua | 0 src/00-misc/math_return_table/vector.lua | 0 src/lua51/lcode.h | 2 + src/lua51/lobject.h | 20 +-- src/lua51/lstate.h | 7 +- src/lua51/lstring.c | 36 ++-- src/lua51/ltable.c | 16 +- src/lua51/lvm.c | 1 + src/lua51/lvm.h | 2 +- src/math/math.cpp | 37 ---- src/math/math.h | 9 - 24 files changed, 180 insertions(+), 359 deletions(-) delete mode 100644 math/math.vcxproj delete mode 100644 math/math.vcxproj.filters delete mode 100644 math/math.vcxproj.user delete mode 100644 src/00-misc/math_return_table/init.lua delete mode 100644 src/00-misc/math_return_table/matrix.lua delete mode 100644 src/00-misc/math_return_table/misc/guid.lua delete mode 100644 src/00-misc/math_return_table/misc/init.lua delete mode 100644 src/00-misc/math_return_table/misc/lerp.lua delete mode 100644 src/00-misc/math_return_table/misc/rand.lua delete mode 100644 src/00-misc/math_return_table/misc/uuid.lua delete mode 100644 src/00-misc/math_return_table/quaternion.lua delete mode 100644 src/00-misc/math_return_table/vector.lua delete mode 100644 src/math/math.cpp delete mode 100644 src/math/math.h diff --git a/luatest.sln b/luatest.sln index 38e85e0..9c39c00 100644 --- a/luatest.sln +++ b/luatest.sln @@ -5,10 +5,6 @@ VisualStudioVersion = 15.0.28307.168 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luatest", "luatest\luatest.vcxproj", "{A034D469-27DF-4900-B3E8-C430D3A90D71}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "math", "math\math.vcxproj", "{602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua\lua.vcxproj", "{71F99467-FABE-417A-BE91-8D4465FFA775}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -25,22 +21,6 @@ Global {A034D469-27DF-4900-B3E8-C430D3A90D71}.Release|x64.Build.0 = Release|x64 {A034D469-27DF-4900-B3E8-C430D3A90D71}.Release|x86.ActiveCfg = Release|Win32 {A034D469-27DF-4900-B3E8-C430D3A90D71}.Release|x86.Build.0 = Release|Win32 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Debug|x64.ActiveCfg = Debug|x64 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Debug|x64.Build.0 = Debug|x64 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Debug|x86.ActiveCfg = Debug|Win32 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Debug|x86.Build.0 = Debug|Win32 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Release|x64.ActiveCfg = Release|x64 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Release|x64.Build.0 = Release|x64 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Release|x86.ActiveCfg = Release|Win32 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0}.Release|x86.Build.0 = Release|Win32 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Debug|x64.ActiveCfg = Debug|x64 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Debug|x64.Build.0 = Debug|x64 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Debug|x86.ActiveCfg = Debug|Win32 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Debug|x86.Build.0 = Debug|Win32 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Release|x64.ActiveCfg = Release|x64 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Release|x64.Build.0 = Release|x64 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Release|x86.ActiveCfg = Release|Win32 - {71F99467-FABE-417A-BE91-8D4465FFA775}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/luatest/luatest.vcxproj b/luatest/luatest.vcxproj index 68136a4..5d6e144 100644 --- a/luatest/luatest.vcxproj +++ b/luatest/luatest.vcxproj @@ -156,6 +156,8 @@ + + @@ -194,7 +196,6 @@ - diff --git a/luatest/luatest.vcxproj.filters b/luatest/luatest.vcxproj.filters index c3f8d56..d7dbd45 100644 --- a/luatest/luatest.vcxproj.filters +++ b/luatest/luatest.vcxproj.filters @@ -19,193 +19,208 @@ {f3e095fb-8219-46c2-9d97-20539e925d7c} - - {47f87cf7-c82c-4329-ac70-1cc49d9f3910} + + {d1ee8d0a-7426-49c4-b7a1-7d97e19b2b50} + + + {8d328705-208e-4a5f-bbbc-07d8f9687572} + + + {a61a0f7b-2516-4681-8493-d1345f0a66ae} + + + {f78e0054-c3c6-4069-8891-df4e87d5ad3d} + + + {e29c325c-ca6b-4d89-90d2-ad4a1613009f} - - lua51 + + 01-coroutine + + + 02-enum + + + 03-coroutine_pool + + + 04-thread + + + 00-misc - lua51 + lua51\lib - lua51 - - - lua51 + lua51\lib - lua51 + lua51\lib - - lua51 - - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\lib - - lua51 + + lua51\core - - lua51 + + lua51\core - - lua51 + + lua51\core - + lua51 - + lua51 - - lua51 + + lua51\core\compiler - lua51 + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\compiler - - 01-coroutine + + lua51\core\object - - 02-enum + + lua51\core\object - - 03-coroutine_pool + + lua51\core\object - - 04-thread + + lua51\core\compiler - - 00-misc + + lua51\core\compiler - - lua51 - + - lua51 + lua51\lib - - lua51 + + lua51\core - lua51 - - - lua51 + lua51\core - - lua51 + + lua51\core - - lua51 + + lua51\core - lua51 + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - lua51 + lua51\core\object - - lua51 + + lua51\core\compiler - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - - lua51 + + lua51\core\object - lua51 + lua51\core\compiler - lua51 + lua51\core\compiler + + + lua51\core\config + + + lua51\core\config - - - lua51 - 01-coroutine diff --git a/math/math.vcxproj b/math/math.vcxproj deleted file mode 100644 index 44b07bf..0000000 --- a/math/math.vcxproj +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {602A64C7-2EB4-42D7-9AE0-CCA3E69E16A0} - math - 10.0.17763.0 - - - - DynamicLibrary - true - v141 - MultiByte - - - DynamicLibrary - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - - - $(OutDir) - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - $(OutDir) - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/math/math.vcxproj.filters b/math/math.vcxproj.filters deleted file mode 100644 index 67045a2..0000000 --- a/math/math.vcxproj.filters +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/math/math.vcxproj.user b/math/math.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/math/math.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/00-misc/math_return_table/init.lua b/src/00-misc/math_return_table/init.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/matrix.lua b/src/00-misc/math_return_table/matrix.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/misc/guid.lua b/src/00-misc/math_return_table/misc/guid.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/misc/init.lua b/src/00-misc/math_return_table/misc/init.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/misc/lerp.lua b/src/00-misc/math_return_table/misc/lerp.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/misc/rand.lua b/src/00-misc/math_return_table/misc/rand.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/misc/uuid.lua b/src/00-misc/math_return_table/misc/uuid.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/quaternion.lua b/src/00-misc/math_return_table/quaternion.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/00-misc/math_return_table/vector.lua b/src/00-misc/math_return_table/vector.lua deleted file mode 100644 index e69de29..0000000 diff --git a/src/lua51/lcode.h b/src/lua51/lcode.h index b941c60..45d9f68 100644 --- a/src/lua51/lcode.h +++ b/src/lua51/lcode.h @@ -1,3 +1,5 @@ +//c Éú³É×Ö½ÚÂë + /* ** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ ** Code generator for Lua diff --git a/src/lua51/lobject.h b/src/lua51/lobject.h index 25dc341..4e9daee 100644 --- a/src/lua51/lobject.h +++ b/src/lua51/lobject.h @@ -40,10 +40,10 @@ typedef union GCObject GCObject; ** Common Header for all collectable objects (in macro form, to be ** included in other objects) */ -// ÐèÒªÀ¬»ø»ØÊÕµÄÀàÐͰüº¬Õâ¸öÍ· -//c next Ö¸ÏòÏÂÒ»¸ögcÁ´±íµÄ³ÉÔ± -//c tt Êý¾ÝÀàÐÍ -//c GC±ê¼Ç£¬ÓÃÀ´±£´æÑÕÉ«,Óа×É«£¨2ÖÖ£©,»ÒÉ«ºÍºÚÉ« +// ÐèÒªÀ¬»ø»ØÊÕµÄÀàÐͰüº¬Õâ¸öÍ·£¬°üº¬TString, Udata, Proto, UpVal, Closure, TableÒÔ¼°lua_StateÆß¸ö +//c next Ö¸ÏòÏÂÒ»¸ögcÁ´±íµÄ³ÉÔ± +//c tt Êý¾ÝÀàÐÍ +//c marked GC±ê¼Ç£¬ÓÃÀ´±£´æÑÕÉ«,Óа×É«£¨2ÖÖ£©,»ÒÉ«ºÍºÚÉ« #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked @@ -211,17 +211,17 @@ typedef union TString { L_Umaxalign dummy; /* ensures maximum alignment for strings */ struct { CommonHeader; - lu_byte reserved;//±ê¼Ç×Ö·û´®ÊÇ·ñÊÇluaµÄ¹Ø¼ü×Ö£¬Èç¹ûÊÇ£¬²»»á±»GC»ØÊÕ - unsigned int hash;//×Ö·û´®µÄ¹þÏ£Öµ£¬±È½Ï×Ö·û´®µÄÒÀ¾Ý - size_t len; - } tsv; + lu_byte reserved;//c ±ê¼Ç×Ö·û´®ÊÇ·ñÊÇluaµÄ¹Ø¼ü×Ö£¬Èç¹ûÊÇ£¬²»»á±»GC»ØÊÕ + unsigned int hash;//c ×Ö·û´®µÄ¹þÏ£Öµ£¬±È½Ï×Ö·û´®µÄÒÀ¾Ý + size_t len; //c ×Ö·û´®³¤¶È + } tsv; //c tstring value } TString; #define getstr(ts) cast(const char *, (ts) + 1) #define svalue(o) getstr(rawtsvalue(o)) -// userdata£¬ºÍTString±È½ÏÏñ +//c userdata£¬ºÍTString±È½ÏÏñ typedef union Udata { L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ struct { @@ -240,7 +240,7 @@ typedef union Udata { */ typedef struct Proto { CommonHeader; - //c º¯ÊýµÄ³£Á¿ + //c ³£Á¿±í£¬ÄÜ¿´³öÀ´lua±£´æ³£Á¿µÄµ¥ÔªÊǺ¯ÊýÔ­ÐÍ£¬ËùÓдúÂëÆ¬¶Î¶¼»á±»±àÒëΪproto TValue *k; /* constants used by the function */ //c º¯Êý×Ö½ÚÂë Instruction *code; diff --git a/src/lua51/lstate.h b/src/lua51/lstate.h index 2f71e57..1c049e1 100644 --- a/src/lua51/lstate.h +++ b/src/lua51/lstate.h @@ -41,9 +41,9 @@ struct lua_longjmp; /* defined in ldo.c */ //c rehashÔÚlstring.c -> luaS_resize typedef struct stringtable { GCObject **hash; //c ×Ö·û´®£¬ÒòΪÊÇÉ¢ÁÐͰ£¬ËùÒÔÊÇ** - lu_int32 nuse; //c ͰÓõ½µÄÈÝÁ¿£¬ÒòΪ²»Ò»¶¨size¶¼Óõ½ÁË /* number of elements */ - int size; //c ͰµÄ×ÜÈÝÁ¿£¬Êdz£Öµ - // nuseºÍsizeÊÇÓÃÀ´¶¯Ì¬¿ØÖÆÍ°ÈÝÁ¿µÄ¹Ø¼ü + lu_int32 nuse; //c ͰÓõ½µÄÈÝÁ¿£¬ÒòΪ²»Ò»¶¨size¶¼Óõ½ÁË /* number of elements */ + int size; //c ͰµÄ×ÜÈÝÁ¿£¬Êdz£Öµ + //c nuseºÍsizeÊÇÓÃÀ´¶¯Ì¬¿ØÖÆÍ°ÈÝÁ¿µÄ¹Ø¼ü } stringtable; @@ -120,7 +120,6 @@ typedef struct global_State { } global_State; -//c Ò»¸ölua_state£¬¿ÉÒÔ¿´×öÊÇÒ»¸ö //c StkIdÒýÓõÄÓÀÔ¶ÊÇlua_StateÕ»ÉϵÄÄÚÈÝ /* ** `per thread' state diff --git a/src/lua51/lstring.c b/src/lua51/lstring.c index 73d34c4..cadbb4b 100644 --- a/src/lua51/lstring.c +++ b/src/lua51/lstring.c @@ -25,19 +25,19 @@ void luaS_resize (lua_State *L, int newsize) { GCObject **newhash; stringtable *tb; int i; - if (G(L)->gcstate == GCSsweepstring)//Èç¹ûGCÔÚ»ØÊÕ×Ö·û´®½×¶Î£¬²»Òªrehash + if (G(L)->gcstate == GCSsweepstring)//Èç¹ûGCÔÚ»ØÊÕ×Ö·û´®½×¶Î£¬²»Òªrehash£¬µÈGCÍêÁËÔÙ¸ã return; /* cannot resize during GC traverse */ newhash = luaM_newvector(L, newsize, GCObject *); //½¨Á¢Ò»¸öеÄÉ¢ÁÐͰ£¬²¢Çå¿Õ tb = &G(L)->strt;//¾ÉµÄÉ¢ÁÐͰ for (i=0; isize; i++) { - GCObject *p = tb->hash[i]; + GCObject *p = tb->hash[i]; // ij¸öͰ while (p) { /* for each node in the list */ GCObject *next = p->gch.next; /* save next */ - unsigned int h = gco2ts(p)->hash; - //еÄÉ¢ÁÐÖµ + unsigned int h = gco2ts(p)->hash; //c ±£´æhashÖµ + //еÄÉ¢ÁÐÖµ£¬²¢¼ÓÈëͰÖÐ int h1 = lmod(h, newsize); /* new position */ lua_assert(cast_int(h%newsize) == lmod(h, newsize)); p->gch.next = newhash[h1];//c ½ÓÔÚͬһ¸öhashµÄ×îÇ°Ãæ /* chain it */ @@ -45,37 +45,42 @@ void luaS_resize (lua_State *L, int newsize) { p = next; } } + // ÊͷžÉÉ¢ÁÐͰ luaM_freearray(L, tb->hash, tb->size, TString *); tb->size = newsize; - tb->hash = newhash; + tb->hash = newhash; // ÉèÖÃÐÂÉ¢ÁÐͰ } -//c н¨×Ö·û´® +//c н¨×Ö·û´®²¢¼ÓÈëÉ¢ÁÐͰ static TString *newlstr (lua_State *L, const char *str, size_t l, unsigned int h) { TString *ts; stringtable *tb; if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) luaM_toobig(L); + //c ͬʱÉêÇëÁËTStringºÍ×Ö·û´®Äڴ棬×Ö·û´®ÄÚÈÝ»á½ô¸úÔÚTString½á¹¹ºó±ß ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); ts->tsv.len = l; ts->tsv.hash = h; ts->tsv.marked = luaC_white(G(L)); ts->tsv.tt = LUA_TSTRING; ts->tsv.reserved = 0; - memcpy(ts+1, str, l*sizeof(char)); + + memcpy(ts+1, str, l*sizeof(char)); //c ¸´ÖÆ×Ö·û´®ÄÚÈÝ ((char *)(ts+1))[l] = '\0'; /* ending 0 */ - tb = &G(L)->strt; - // ¼ÆËãhashÖµ - h = lmod(h, tb->size); + + tb = &G(L)->strt; //c É¢ÁÐͰ + + h = lmod(h, tb->size); //c ¼ÆËãhashÖµ²¢½«Õâ¸ö×Ö·û´®¼ÓÈëͰ ts->tsv.next = tb->hash[h]; /* chain new entry */ tb->hash[h] = obj2gco(ts); tb->nuse++; - //c ¸ø×Ö·û´®Í¨À©ÈÝ£¬Èç¹û×Ö·û´®ÊýÁ¿´óÓÚͰÈÝÁ¿ - //c ¸øÍ°À©ÈÝΪ2±¶ + + //c Èç¹û×Ö·û´®ÊýÁ¿´óÓÚͰÈÝÁ¿£¬¸ø×Ö·û´®Í¨À©ÈÝ£¬¸øÍ°À©ÈÝΪ2±¶ if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) luaS_resize(L, tb->size*2); /* too crowded */ + return ts; } @@ -89,11 +94,14 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { //c Èç¹û×Ö·û´®·Ç³£³¤£¬²»ÒªÖðλ¼ÆËãÉ¢ÁÐÖµ£¬Ã¿step²½È¡Ò»¸ö×Ö·û¼ÆËã¼´¿É for (l1=l; l1>=step; l1-=step) /* compute hash */ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + //c ±éÀúÕâ¸öhash¶ÔÓ¦µÄÉ¢ÁÐͰ for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; o != NULL; o = o->gch.next) { TString *ts = rawgco2ts(o); - if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {//c Èç¹ûÉ¢ÁÐÖµÏàͬ£¬ÓÃmemcmp¿ìËÙ¶Ô±È + //c Èç¹û³¤¶ÈÏàͬ£¬ÓÃmemcmp¿ìËÙ¶Ô±È + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + //c Õâ¸ö×Ö·û´®ÒѾ­´æÔÚ£¬Ö±½Ó·µ»ØÕâ¸öÒýÓà //c Èç¹û×Ö·û´®±»±ê¼ÇÁË»ØÊÕ(gch.marked)£¬ÖØÐ±ê¼ÇËü²»Òª»ØÊÕ /* string may be dead */ if (isdead(G(L), o)) changewhite(o); diff --git a/src/lua51/ltable.c b/src/lua51/ltable.c index 73464a0..38f4218 100644 --- a/src/lua51/ltable.c +++ b/src/lua51/ltable.c @@ -92,7 +92,7 @@ static Node *hashnum (const Table *t, lua_Number n) { } - +//c ¼ÆËãhash²»Í¬keyÀàÐ͵ÄhashÖµ /* ** returns the `main' position of an element in a table (that is, the index ** of its hash value) @@ -404,7 +404,7 @@ static Node *getfreepos (Table *t) { } -//c ±íн¨key +//c ±íн¨key£¬¹æÔòÈçÏ¡ý /* ** inserts a new key into a hash table; first, check whether key's main ** position is free. If not, check whether colliding node is in its main @@ -416,6 +416,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { Node *mp = mainposition(t, key); if (!ttisnil(gval(mp)) || mp == dummynode) {//c mainpositionÉÏÒѾ­ÓÐÊý¾Ý Node *othern; + //c ȡһ¸ö¿ÕͰ£¬ºóÃæ¿ÉÄÜ»áÓõ½ Node *n = getfreepos(t); /* get a free place */ //c Èç¹ûûÓпÕ룬À©Õ¹hash table´óСΪ2±¶ if (n == NULL) { /* cannot find a free place? */ @@ -425,8 +426,9 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { } lua_assert(n != dummynode); //c ÏÈ¿´Ò»ÏÂÏÖÔÚmainpositionÉϵÄÕâ¸önode£¬ËüµÄmainpositionÊDz»ÊÇÕâ¸öÖµ - //c ²»Êǵϰ¸øÐµÄkeyÈ÷ - othern = mainposition(t, key2tval(mp)); + //c ²»ÊǵĻ°ËµÃ÷Õâ¸önodeÊÇÁÙʱ·ÅÔÚÕâÀïµÄ£¬¸øÐµÄkeyÈ÷£¬°ÑÕâ¸önodeÒÆµ½Ò»¸ö¿ÕλÉÏ + //c othernÊÇÔ­ÏÈmpλÖõÄÕâ¸ökeyÓ¦¸Ã¶ÔÓ¦µÄλÖà + othern = mainposition(t, key2tval(mp)); //c key2tval(mp)ÄÇ´ómpµÄkeyµØÖ·£¬ÓÃÀ´¼ÆËãhash if (othern != mp) { /* is colliding node out of its main position? */ // °Ñmp¿Õ³öÀ´,mpÀïµÄÖµÒÆµ½n(freeposition) /* yes; move colliding node into free position */ @@ -434,8 +436,9 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ - setnilvalue(gval(mp)); + setnilvalue(gval(mp)); // Çå¿ÕÕâ¸öλÖã¬Áô¸öÒª¼ÓµÄÕâ¸ökeyÓà //mpÊÇÒª¸³ÖµµÄλÖ㬼´ÐÂkeyµÄÔªËØµÄλÖà } else { /* colliding node is in its own main position */ @@ -443,7 +446,8 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { //c ½«free position²åÈëµ½mpºóµÚÒ»¸ö gnext(n) = gnext(mp); /* chain new position */ gnext(mp) = n; - //c ÐÞ¸ÄÒ»ÏÂmpÖ¸Õ룬ָÏòfreeposition£¬Áô¸öºóÐøÊ¹Óà + + //c ÐÞ¸ÄÒ»ÏÂmpÖ¸Õ룬ָÏòfreeposition£¬Áô¸øºóÐøÊ¹Óá£Ò»¸öhack£¬ÕâÑù¾Í¿ÉÒÔºÍmainpositionλÖÃÉÏÊǿյļæÈÝ mp = n; } } diff --git a/src/lua51/lvm.c b/src/lua51/lvm.c index 21de678..b353500 100644 --- a/src/lua51/lvm.c +++ b/src/lua51/lvm.c @@ -393,6 +393,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { base = L->base; //c baseÊǼĴæÆ÷¿ªÊ¼µØÖ·,ÿ¸ö·½·¨±»µ÷ÓÃʱ¶¼»áµÃµ½×Ô¼ºµÄÒ»×éÐéÄâ¼Ä´æÆ÷ k = cl->p->k; //c µ±Ç°º¯ÊýÔ­Ð͵ij£Á¿£¬ËùÓк¯Êýµ÷Óö¼»áÓõ½µÄ + //c ÐéÄâ»úÖ÷Ñ­»· /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; diff --git a/src/lua51/lvm.h b/src/lua51/lvm.h index 19fec22..78c4963 100644 --- a/src/lua51/lvm.h +++ b/src/lua51/lvm.h @@ -30,7 +30,7 @@ LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val); LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val); -//c ÐéÄâ»úÖ÷Èë¿Ú +//c ÐéÄâ»úÖ÷Èë¿Ú luaV_execute LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); diff --git a/src/math/math.cpp b/src/math/math.cpp deleted file mode 100644 index acb215f..0000000 --- a/src/math/math.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "math.h" - -#pragma comment(lib, "lua.lib") - -#define MATH_API __declspec(dllexport) - -MATH_API int /*__cdecl*/ luaopen_math_vector(lua_State* L) -{ - lua_pushstring(L, "math.vector module"); - - return 1; -} - - -extern "C" MATH_API int /*__cdecl*/ luaopen_math_matrix(lua_State* L) -{ - lua_pushstring(L, "math.matrix module"); - - return 1; -} - -extern "C" MATH_API int /*__cdecl*/ luaopen_math_quaternion(lua_State* L) -{ - lua_pushstring(L, "math.quaternion module"); - - return 1; -} - -MATH_API void foo() -{ - -} - -class MATH_API Vector -{ - -}; diff --git a/src/math/math.h b/src/math/math.h deleted file mode 100644 index 494b725..0000000 --- a/src/math/math.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -extern "C" { -#include "../lua51/lua.h" -#include "../lua51/lualib.h" -#include "../lua51/lauxlib.h" -} - -//#define MATH_API __declspec(dllexport) -- cgit v1.1-26-g67d0