diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-19 11:20:30 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-19 11:20:30 -0200 |
commit | 4ac58853dc820127a11a14ed8bde1fae9458369e (patch) | |
tree | e8179692c97e935ba921c8ebd17abf9c8510d89e /ldebug.c | |
parent | f2c451d7455aad3496f32dfa2bfca7f7e8b5376d (diff) | |
download | lua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.gz lua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.bz2 lua-4ac58853dc820127a11a14ed8bde1fae9458369e.zip |
thead-specific state separated from "global" state
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.52 2000/12/26 18:46:09 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.53 2001/01/18 15:59:09 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 | */ |
@@ -96,20 +96,20 @@ int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) { | |||
96 | refi = prefi ? *prefi : 0; | 96 | refi = prefi ? *prefi : 0; |
97 | if (lineinfo[refi] < 0) | 97 | if (lineinfo[refi] < 0) |
98 | refline += -lineinfo[refi++]; | 98 | refline += -lineinfo[refi++]; |
99 | LUA_ASSERT(lineinfo[refi] >= 0, "invalid line info"); | 99 | lua_assert(lineinfo[refi] >= 0); |
100 | while (lineinfo[refi] > pc) { | 100 | while (lineinfo[refi] > pc) { |
101 | refline--; | 101 | refline--; |
102 | refi--; | 102 | refi--; |
103 | if (lineinfo[refi] < 0) | 103 | if (lineinfo[refi] < 0) |
104 | refline -= -lineinfo[refi--]; | 104 | refline -= -lineinfo[refi--]; |
105 | LUA_ASSERT(lineinfo[refi] >= 0, "invalid line info"); | 105 | lua_assert(lineinfo[refi] >= 0); |
106 | } | 106 | } |
107 | for (;;) { | 107 | for (;;) { |
108 | int nextline = refline + 1; | 108 | int nextline = refline + 1; |
109 | int nextref = refi + 1; | 109 | int nextref = refi + 1; |
110 | if (lineinfo[nextref] < 0) | 110 | if (lineinfo[nextref] < 0) |
111 | nextline += -lineinfo[nextref++]; | 111 | nextline += -lineinfo[nextref++]; |
112 | LUA_ASSERT(lineinfo[nextref] >= 0, "invalid line info"); | 112 | lua_assert(lineinfo[nextref] >= 0); |
113 | if (lineinfo[nextref] > pc) | 113 | if (lineinfo[nextref] > pc) |
114 | break; | 114 | break; |
115 | refline = nextline; | 115 | refline = nextline; |
@@ -122,7 +122,7 @@ int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) { | |||
122 | 122 | ||
123 | static int currentpc (StkId f) { | 123 | static int currentpc (StkId f) { |
124 | CallInfo *ci = infovalue(f); | 124 | CallInfo *ci = infovalue(f); |
125 | LUA_ASSERT(isLmark(f), "function has no pc"); | 125 | lua_assert(isLmark(f)); |
126 | if (ci->pc) | 126 | if (ci->pc) |
127 | return (*ci->pc - ci->func->f.l->code) - 1; | 127 | return (*ci->pc - ci->func->f.l->code) - 1; |
128 | else | 128 | else |
@@ -204,13 +204,13 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { | |||
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | static const char *travtagmethods (lua_State *L, const TObject *o) { | 207 | static const char *travtagmethods (global_State *G, const TObject *o) { |
208 | if (ttype(o) == LUA_TFUNCTION) { | 208 | if (ttype(o) == LUA_TFUNCTION) { |
209 | int e; | 209 | int e; |
210 | for (e=0; e<TM_N; e++) { | 210 | for (e=0; e<TM_N; e++) { |
211 | int t; | 211 | int t; |
212 | for (t=0; t<L->ntag; t++) | 212 | for (t=0; t<G->ntag; t++) |
213 | if (clvalue(o) == luaT_gettm(L, t, e)) | 213 | if (clvalue(o) == luaT_gettm(G, t, e)) |
214 | return luaT_eventname[e]; | 214 | return luaT_eventname[e]; |
215 | } | 215 | } |
216 | } | 216 | } |
@@ -237,7 +237,7 @@ static void getname (lua_State *L, StkId f, lua_Debug *ar) { | |||
237 | if ((ar->name = travglobals(L, &o)) != NULL) | 237 | if ((ar->name = travglobals(L, &o)) != NULL) |
238 | ar->namewhat = "global"; | 238 | ar->namewhat = "global"; |
239 | /* not found: try tag methods */ | 239 | /* not found: try tag methods */ |
240 | else if ((ar->name = travtagmethods(L, &o)) != NULL) | 240 | else if ((ar->name = travtagmethods(G(L), &o)) != NULL) |
241 | ar->namewhat = "tag-method"; | 241 | ar->namewhat = "tag-method"; |
242 | else ar->namewhat = ""; /* not found at all */ | 242 | else ar->namewhat = ""; /* not found at all */ |
243 | } | 243 | } |
@@ -308,22 +308,22 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
308 | top++; /* `arg' */ | 308 | top++; /* `arg' */ |
309 | while (pc < lastpc) { | 309 | while (pc < lastpc) { |
310 | const Instruction i = code[pc++]; | 310 | const Instruction i = code[pc++]; |
311 | LUA_ASSERT(0 <= top && top <= pt->maxstacksize, "wrong stack"); | 311 | lua_assert(0 <= top && top <= pt->maxstacksize); |
312 | switch (GET_OPCODE(i)) { | 312 | switch (GET_OPCODE(i)) { |
313 | case OP_RETURN: { | 313 | case OP_RETURN: { |
314 | LUA_ASSERT(top >= GETARG_U(i), "wrong stack"); | 314 | lua_assert(top >= GETARG_U(i)); |
315 | top = GETARG_U(i); | 315 | top = GETARG_U(i); |
316 | break; | 316 | break; |
317 | } | 317 | } |
318 | case OP_TAILCALL: { | 318 | case OP_TAILCALL: { |
319 | LUA_ASSERT(top >= GETARG_A(i), "wrong stack"); | 319 | lua_assert(top >= GETARG_A(i)); |
320 | top = GETARG_B(i); | 320 | top = GETARG_B(i); |
321 | break; | 321 | break; |
322 | } | 322 | } |
323 | case OP_CALL: { | 323 | case OP_CALL: { |
324 | int nresults = GETARG_B(i); | 324 | int nresults = GETARG_B(i); |
325 | if (nresults == MULT_RET) nresults = 1; | 325 | if (nresults == MULT_RET) nresults = 1; |
326 | LUA_ASSERT(top >= GETARG_A(i), "wrong stack"); | 326 | lua_assert(top >= GETARG_A(i)); |
327 | top = pushpc(stack, pc, GETARG_A(i), nresults); | 327 | top = pushpc(stack, pc, GETARG_A(i), nresults); |
328 | break; | 328 | break; |
329 | } | 329 | } |
@@ -368,10 +368,9 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
368 | } | 368 | } |
369 | default: { | 369 | default: { |
370 | OpCode op = GET_OPCODE(i); | 370 | OpCode op = GET_OPCODE(i); |
371 | LUA_ASSERT(luaK_opproperties[op].push != VD, | 371 | lua_assert(luaK_opproperties[op].push != VD); |
372 | "invalid opcode for default"); | ||
373 | top -= (int)luaK_opproperties[op].pop; | 372 | top -= (int)luaK_opproperties[op].pop; |
374 | LUA_ASSERT(top >= 0, "wrong stack"); | 373 | lua_assert(top >= 0); |
375 | top = pushpc(stack, pc, top, luaK_opproperties[op].push); | 374 | top = pushpc(stack, pc, top, luaK_opproperties[op].push); |
376 | } | 375 | } |
377 | } | 376 | } |
@@ -389,7 +388,7 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) { | |||
389 | int pc = currentpc(func); | 388 | int pc = currentpc(func); |
390 | int stackpos = obj - (func+1); /* func+1 == function base */ | 389 | int stackpos = obj - (func+1); /* func+1 == function base */ |
391 | Instruction i = luaG_symbexec(p, pc, stackpos); | 390 | Instruction i = luaG_symbexec(p, pc, stackpos); |
392 | LUA_ASSERT(pc != -1, "function must be active"); | 391 | lua_assert(pc != -1); |
393 | switch (GET_OPCODE(i)) { | 392 | switch (GET_OPCODE(i)) { |
394 | case OP_GETGLOBAL: { | 393 | case OP_GETGLOBAL: { |
395 | *name = p->kstr[GETARG_U(i)]->str; | 394 | *name = p->kstr[GETARG_U(i)]->str; |
@@ -397,7 +396,7 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) { | |||
397 | } | 396 | } |
398 | case OP_GETLOCAL: { | 397 | case OP_GETLOCAL: { |
399 | *name = luaF_getlocalname(p, GETARG_U(i)+1, pc); | 398 | *name = luaF_getlocalname(p, GETARG_U(i)+1, pc); |
400 | LUA_ASSERT(*name, "local must exist"); | 399 | lua_assert(*name); |
401 | return "local"; | 400 | return "local"; |
402 | } | 401 | } |
403 | case OP_PUSHSELF: | 402 | case OP_PUSHSELF: |
@@ -449,7 +448,7 @@ void luaG_typeerror (lua_State *L, StkId o, const char *op) { | |||
449 | 448 | ||
450 | void luaG_binerror (lua_State *L, StkId p1, int t, const char *op) { | 449 | void luaG_binerror (lua_State *L, StkId p1, int t, const char *op) { |
451 | if (ttype(p1) == t) p1++; | 450 | if (ttype(p1) == t) p1++; |
452 | LUA_ASSERT(ttype(p1) != t, "must be an error"); | 451 | lua_assert(ttype(p1) != t); |
453 | luaG_typeerror(L, p1, op); | 452 | luaG_typeerror(L, p1, op); |
454 | } | 453 | } |
455 | 454 | ||