aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-26 16:28:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-26 16:28:31 -0300
commitafef009fcea199bd4eff28ea6e5206b59cda9939 (patch)
tree3954490fd4149900be8e795f630104637cd02f4b /lcode.c
parentb69e712713785394ceefa11ab3e5f9636abea733 (diff)
downloadlua-afef009fcea199bd4eff28ea6e5206b59cda9939.tar.gz
lua-afef009fcea199bd4eff28ea6e5206b59cda9939.tar.bz2
lua-afef009fcea199bd4eff28ea6e5206b59cda9939.zip
new version of debug system
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/lcode.c b/lcode.c
index 50ed11e6..98ad5078 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.37 2000/06/21 17:05:49 roberto Exp roberto $ 2** $Id: lcode.c,v 1.38 2000/06/21 18:13:56 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -283,7 +283,6 @@ static void luaK_testgo (FuncState *fs, expdesc *v, int invert, OpCode jump) {
283 prevpos = fs->pc-1; 283 prevpos = fs->pc-1;
284 previous = &fs->f->code[prevpos]; 284 previous = &fs->f->code[prevpos];
285 LUA_ASSERT(L, *previous==previous_instruction(fs), "no jump allowed here"); 285 LUA_ASSERT(L, *previous==previous_instruction(fs), "no jump allowed here");
286 LUA_ASSERT(L, GET_OPCODE(*previous) != OP_SETLINE, "no setline allowed here");
287 if (!ISJUMP(GET_OPCODE(*previous))) 286 if (!ISJUMP(GET_OPCODE(*previous)))
288 prevpos = luaK_code1(fs, jump, NO_JUMP); 287 prevpos = luaK_code1(fs, jump, NO_JUMP);
289 else { /* last instruction is already a jump */ 288 else { /* last instruction is already a jump */
@@ -316,7 +315,6 @@ void luaK_tostack (LexState *ls, expdesc *v, int onlyone) {
316 FuncState *fs = ls->fs; 315 FuncState *fs = ls->fs;
317 if (!discharge(fs, v)) { /* `v' is an expression? */ 316 if (!discharge(fs, v)) { /* `v' is an expression? */
318 OpCode previous = GET_OPCODE(fs->f->code[fs->pc-1]); 317 OpCode previous = GET_OPCODE(fs->f->code[fs->pc-1]);
319 LUA_ASSERT(L, previous != OP_SETLINE, "bad place to set line");
320 if (!ISJUMP(previous) && v->u.l.f == NO_JUMP && v->u.l.t == NO_JUMP) { 318 if (!ISJUMP(previous) && v->u.l.f == NO_JUMP && v->u.l.t == NO_JUMP) {
321 /* expression has no jumps */ 319 /* expression has no jumps */
322 if (onlyone) 320 if (onlyone)
@@ -623,17 +621,15 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
623 case iS: i = CREATE_S(o, arg1); break; 621 case iS: i = CREATE_S(o, arg1); break;
624 case iAB: i = CREATE_AB(o, arg1, arg2); break; 622 case iAB: i = CREATE_AB(o, arg1, arg2); break;
625 } 623 }
626 /* check space for new instruction plus eventual SETLINE */ 624 if (fs->f->debug) {
627 luaM_growvector(fs->L, fs->f->code, fs->pc, 2, Instruction,
628 "code size overflow", MAX_INT);
629 /* check the need for SETLINE */
630 if (fs->debug && fs->ls->lastline != fs->lastsetline) {
631 LexState *ls = fs->ls; 625 LexState *ls = fs->ls;
632 luaX_checklimit(ls, ls->lastline, MAXARG_U, "lines in a chunk"); 626 luaX_checklimit(ls, ls->lastline, MAXARG_U, "lines in a chunk");
633 fs->f->code[fs->pc++] = CREATE_U(OP_SETLINE, ls->lastline); 627 luaM_growvector(fs->L, fs->f->lines, fs->pc, 1, int, "??", MAXARG_U);
634 fs->lastsetline = ls->lastline; 628 fs->f->lines[fs->pc] = ls->lastline;
635 } 629 }
636 /* put new instruction in code array */ 630 /* put new instruction in code array */
631 luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction,
632 "code size overflow", MAX_INT);
637 fs->f->code[fs->pc] = i; 633 fs->f->code[fs->pc] = i;
638 return fs->pc++; 634 return fs->pc++;
639} 635}
@@ -688,6 +684,5 @@ const struct OpProperties luaK_opproperties[NUM_OPCODES] = {
688 {iS, -3}, /* OP_FORLOOP */ 684 {iS, -3}, /* OP_FORLOOP */
689 {iS, 3}, /* OP_LFORPREP */ 685 {iS, 3}, /* OP_LFORPREP */
690 {iS, -4}, /* OP_LFORLOOP */ 686 {iS, -4}, /* OP_LFORLOOP */
691 {iAB, VD}, /* OP_CLOSURE */ 687 {iAB, VD} /* OP_CLOSURE */
692 {iU, 0} /* OP_SETLINE */
693}; 688};