diff options
-rw-r--r-- | ldblib.c | 13 | ||||
-rw-r--r-- | ldebug.c | 13 | ||||
-rw-r--r-- | ldebug.h | 5 | ||||
-rw-r--r-- | lstate.h | 4 | ||||
-rw-r--r-- | lua.c | 4 | ||||
-rw-r--r-- | lua.h | 12 | ||||
-rw-r--r-- | lvm.c | 7 |
7 files changed, 28 insertions, 30 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.65 2002/08/05 17:36:24 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.66 2002/08/06 18:01:50 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -126,8 +126,8 @@ static void hookf (lua_State *L, lua_Debug *ar) { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | static int makemask (const char *smask, int count) { | 129 | static unsigned long makemask (const char *smask, int count) { |
130 | int mask = 0; | 130 | unsigned long mask = 0; |
131 | if (strchr(smask, 'c')) mask |= LUA_MASKCALL; | 131 | if (strchr(smask, 'c')) mask |= LUA_MASKCALL; |
132 | if (strchr(smask, 'r')) mask |= LUA_MASKRET; | 132 | if (strchr(smask, 'r')) mask |= LUA_MASKRET; |
133 | if (strchr(smask, 'l')) mask |= LUA_MASKLINE; | 133 | if (strchr(smask, 'l')) mask |= LUA_MASKLINE; |
@@ -135,7 +135,7 @@ static int makemask (const char *smask, int count) { | |||
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | static char *unmakemask (int mask, char *smask) { | 138 | static char *unmakemask (unsigned long mask, char *smask) { |
139 | int i = 0; | 139 | int i = 0; |
140 | if (mask & LUA_MASKCALL) smask[i++] = 'c'; | 140 | if (mask & LUA_MASKCALL) smask[i++] = 'c'; |
141 | if (mask & LUA_MASKRET) smask[i++] = 'r'; | 141 | if (mask & LUA_MASKRET) smask[i++] = 'r'; |
@@ -152,8 +152,9 @@ static int sethook (lua_State *L) { | |||
152 | } | 152 | } |
153 | else { | 153 | else { |
154 | const char *smask = luaL_check_string(L, 2); | 154 | const char *smask = luaL_check_string(L, 2); |
155 | int count = luaL_opt_int(L, 3, 0); | 155 | lua_Number count = luaL_opt_number(L, 3, 0); |
156 | luaL_check_type(L, 1, LUA_TFUNCTION); | 156 | luaL_check_type(L, 1, LUA_TFUNCTION); |
157 | luaL_arg_check(L, count <= LUA_MAXCOUNT, 2, "count too large (>= 2^24)"); | ||
157 | lua_sethook(L, hookf, makemask(smask, count)); | 158 | lua_sethook(L, hookf, makemask(smask, count)); |
158 | } | 159 | } |
159 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); | 160 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); |
@@ -165,7 +166,7 @@ static int sethook (lua_State *L) { | |||
165 | 166 | ||
166 | static int gethook (lua_State *L) { | 167 | static int gethook (lua_State *L) { |
167 | char buff[5]; | 168 | char buff[5]; |
168 | int mask = lua_gethookmask(L); | 169 | unsigned long mask = lua_gethookmask(L); |
169 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); | 170 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); |
170 | lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ | 171 | lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ |
171 | lua_pushstring(L, unmakemask(mask, buff)); | 172 | lua_pushstring(L, unmakemask(mask, buff)); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.130 2002/08/07 19:22:39 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.131 2002/08/08 20:08:41 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -33,11 +33,8 @@ static const char *getfuncname (CallInfo *ci, const char **name); | |||
33 | 33 | ||
34 | static int currentpc (CallInfo *ci) { | 34 | static int currentpc (CallInfo *ci) { |
35 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ | 35 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ |
36 | if (!(ci->state & CI_SAVEDPC)) { /* savedpc outdated? */ | 36 | if (ci->state & CI_HASFRAME) /* function has a frame? */ |
37 | lua_assert(ci->state & CI_HASFRAME); | 37 | ci->u.l.savedpc = *ci->u.l.pc; /* use `pc' from there */ |
38 | ci->u.l.savedpc = *ci->u.l.pc; | ||
39 | ci->state |= CI_SAVEDPC; | ||
40 | } | ||
41 | /* function's pc is saved */ | 38 | /* function's pc is saved */ |
42 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); | 39 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); |
43 | } | 40 | } |
@@ -52,7 +49,7 @@ static int currentline (CallInfo *ci) { | |||
52 | } | 49 | } |
53 | 50 | ||
54 | 51 | ||
55 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask) { | 52 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, unsigned long mask) { |
56 | int allow; | 53 | int allow; |
57 | CallInfo *ci; | 54 | CallInfo *ci; |
58 | lua_lock(L); | 55 | lua_lock(L); |
@@ -75,7 +72,7 @@ LUA_API lua_Hook lua_gethook (lua_State *L) { | |||
75 | } | 72 | } |
76 | 73 | ||
77 | 74 | ||
78 | LUA_API int lua_gethookmask (lua_State *L) { | 75 | LUA_API unsigned long lua_gethookmask (lua_State *L) { |
79 | return L->hookmask; | 76 | return L->hookmask; |
80 | } | 77 | } |
81 | 78 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.h,v 1.28 2002/08/06 18:01:50 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 1.29 2002/08/08 20:08:41 roberto Exp roberto $ |
3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -15,8 +15,7 @@ | |||
15 | 15 | ||
16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) |
17 | 17 | ||
18 | #define resethookcount(L) \ | 18 | #define resethookcount(L) (L->hookcount = lua_getmaskcount(L->hookmask)) |
19 | (L->hookcount = lua_getmaskcount(L->hookmask), L->hookcount *= L->hookcount) | ||
20 | 19 | ||
21 | #define setallowhook(L,cond) ((L->hookmask) = ((L->hookmask) & ~1) | (cond)) | 20 | #define setallowhook(L,cond) ((L->hookmask) = ((L->hookmask) & ~1) | (cond)) |
22 | #define allowhook(L) ((L->hookmask) & 1) | 21 | #define allowhook(L) ((L->hookmask) & 1) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 1.92 2002/08/06 18:01:50 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 1.93 2002/08/07 19:22:39 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -151,7 +151,7 @@ struct lua_State { | |||
151 | CallInfo *end_ci; /* points after end of ci array*/ | 151 | CallInfo *end_ci; /* points after end of ci array*/ |
152 | CallInfo *base_ci; /* array of CallInfo's */ | 152 | CallInfo *base_ci; /* array of CallInfo's */ |
153 | int size_ci; /* size of array `base_ci' */ | 153 | int size_ci; /* size of array `base_ci' */ |
154 | int hookmask; | 154 | unsigned long hookmask; |
155 | ls_count hookcount; | 155 | ls_count hookcount; |
156 | lua_Hook hook; | 156 | lua_Hook hook; |
157 | UpVal *openupval; /* list of open upvalues in this stack */ | 157 | UpVal *openupval; /* list of open upvalues in this stack */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.100 2002/08/07 20:54:17 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.101 2002/08/08 20:08:41 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -45,7 +45,7 @@ static const char *progname; | |||
45 | 45 | ||
46 | 46 | ||
47 | static lua_Hook old_hook = NULL; | 47 | static lua_Hook old_hook = NULL; |
48 | static int old_mask = 0; | 48 | static unsigned long old_mask = 0; |
49 | 49 | ||
50 | 50 | ||
51 | static void lstop (lua_State *l, lua_Debug *ar) { | 51 | static void lstop (lua_State *l, lua_Debug *ar) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.152 2002/08/06 18:01:50 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.153 2002/08/06 18:54:18 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
@@ -316,8 +316,10 @@ typedef enum lua_Hookevent { | |||
316 | #define LUA_MASKCALL (2 << LUA_HOOKCALL) | 316 | #define LUA_MASKCALL (2 << LUA_HOOKCALL) |
317 | #define LUA_MASKRET (2 << LUA_HOOKRET) | 317 | #define LUA_MASKRET (2 << LUA_HOOKRET) |
318 | #define LUA_MASKLINE (2 << LUA_HOOKLINE) | 318 | #define LUA_MASKLINE (2 << LUA_HOOKLINE) |
319 | #define LUA_MASKCOUNT(count) ((count) << (LUA_HOOKCOUNT+1)) | 319 | #define LUA_MASKCOUNT(count) ((unsigned long)(count) << 8) |
320 | #define lua_getmaskcount(mask) ((mask) >> (LUA_HOOKCOUNT+1)) | 320 | #define lua_getmaskcount(mask) ((mask) >> 8) |
321 | |||
322 | #define LUA_MAXCOUNT ((1<<24) - 1) | ||
321 | 323 | ||
322 | typedef struct lua_Debug lua_Debug; /* activation record */ | 324 | typedef struct lua_Debug lua_Debug; /* activation record */ |
323 | 325 | ||
@@ -329,9 +331,9 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); | |||
329 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); | 331 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); |
330 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); | 332 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); |
331 | 333 | ||
332 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask); | 334 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, unsigned long mask); |
333 | LUA_API lua_Hook lua_gethook (lua_State *L); | 335 | LUA_API lua_Hook lua_gethook (lua_State *L); |
334 | LUA_API int lua_gethookmask (lua_State *L); | 336 | LUA_API unsigned long lua_gethookmask (lua_State *L); |
335 | 337 | ||
336 | 338 | ||
337 | #define LUA_IDSIZE 60 | 339 | #define LUA_IDSIZE 60 |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.250 2002/08/07 14:24:24 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.251 2002/08/07 19:22:39 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -70,8 +70,8 @@ int luaV_tostring (lua_State *L, TObject *obj) { | |||
70 | 70 | ||
71 | 71 | ||
72 | static void traceexec (lua_State *L) { | 72 | static void traceexec (lua_State *L) { |
73 | int mask = L->hookmask; | 73 | unsigned long mask = L->hookmask; |
74 | if (mask > LUA_MASKLINE) { /* instruction hook set? */ | 74 | if (mask > LUA_MASKLINE) { /* instruction-hook set? */ |
75 | if (L->hookcount == 0) { | 75 | if (L->hookcount == 0) { |
76 | luaD_callhook(L, LUA_HOOKCOUNT, -1); | 76 | luaD_callhook(L, LUA_HOOKCOUNT, -1); |
77 | resethookcount(L); | 77 | resethookcount(L); |
@@ -92,7 +92,6 @@ static void traceexec (lua_State *L) { | |||
92 | ci = L->ci; /* previous call may reallocate `ci' */ | 92 | ci = L->ci; /* previous call may reallocate `ci' */ |
93 | } | 93 | } |
94 | ci->u.l.savedpc = *ci->u.l.pc; | 94 | ci->u.l.savedpc = *ci->u.l.pc; |
95 | ci->state |= CI_SAVEDPC; /* `savedpc' is updated */ | ||
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||