aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-28 17:21:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-28 17:21:06 -0300
commit014a09c5095be3ef11366530e4630ee817a526a7 (patch)
tree1460ff0d01cd4adf8fac2609ca2ba90411babf2c /lvm.c
parentb62228297372c7b24b6661ac1bdd7df2e8ece64e (diff)
downloadlua-014a09c5095be3ef11366530e4630ee817a526a7.tar.gz
lua-014a09c5095be3ef11366530e4630ee817a526a7.tar.bz2
lua-014a09c5095be3ef11366530e4630ee817a526a7.zip
better error messages
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lvm.c b/lvm.c
index 254b6c35..2fccacc6 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.117 2000/06/26 19:28:31 roberto Exp roberto $ 2** $Id: lvm.c,v 1.118 2000/06/27 19:00:36 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*/
@@ -67,20 +67,19 @@ int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
67} 67}
68 68
69 69
70static void traceexec (lua_State *L, StkId base, int pc, StkId top) { 70static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) {
71 CallInfo *ci = infovalue(base-1); 71 CallInfo *ci = infovalue(base-1);
72 int oldpc = ci->pc; 72 int *lines = ci->func->f.l->lines;
73 ci->pc = pc; 73 int pc = (*ci->pc - 1) - ci->func->f.l->code;
74 if (L->linehook && ci->func->f.l->debug) { 74 if (lines) {
75 int *lines = ci->func->f.l->lines; 75 /* calls linehook when enters a new line or jumps back (loop) */
76 LUA_ASSERT(L, lines, "must have debug information"); 76 if (lines[pc] != ci->line || pc <= ci->lastpc) {
77 /* calls linehook when jumps back (loop) or enters a new line */
78 if (pc <= oldpc || lines[pc] != ci->line) {
79 ci->line = lines[pc]; 77 ci->line = lines[pc];
80 L->top = top; 78 L->top = top;
81 luaD_lineHook(L, base-2, lines[pc]); 79 luaD_lineHook(L, base-2, lines[pc], linehook);
82 } 80 }
83 } 81 }
82 ci->lastpc = pc;
84} 83}
85 84
86 85
@@ -113,7 +112,7 @@ void luaV_Lclosure (lua_State *L, Proto *l, int nelems) {
113** Receives the table at top-2 and the index at top-1. 112** Receives the table at top-2 and the index at top-1.
114*/ 113*/
115void luaV_gettable (lua_State *L, StkId top) { 114void luaV_gettable (lua_State *L, StkId top) {
116 TObject *table = top-2; 115 StkId table = top-2;
117 const TObject *im; 116 const TObject *im;
118 if (ttype(table) != TAG_TABLE) { /* not a table, get gettable TM */ 117 if (ttype(table) != TAG_TABLE) { /* not a table, get gettable TM */
119 im = luaT_getimbyObj(L, table, IM_GETTABLE); 118 im = luaT_getimbyObj(L, table, IM_GETTABLE);
@@ -348,7 +347,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
348 StkId top; /* keep top local, for performance */ 347 StkId top; /* keep top local, for performance */
349 const Instruction *pc = tf->code; 348 const Instruction *pc = tf->code;
350 TString **kstr = tf->kstr; 349 TString **kstr = tf->kstr;
351 int debug = tf->debug; 350 lua_Hook linehook = L->linehook;
351 infovalue(base-1)->pc = &pc;
352 luaD_checkstack(L, tf->maxstacksize+EXTRA_STACK); 352 luaD_checkstack(L, tf->maxstacksize+EXTRA_STACK);
353 if (tf->is_vararg) { /* varargs? */ 353 if (tf->is_vararg) { /* varargs? */
354 adjust_varargs(L, base, tf->numparams); 354 adjust_varargs(L, base, tf->numparams);
@@ -359,9 +359,9 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
359 top = L->top; 359 top = L->top;
360 /* main loop of interpreter */ 360 /* main loop of interpreter */
361 for (;;) { 361 for (;;) {
362 if (debug) 362 const Instruction i = *pc++;
363 traceexec(L, base, pc - tf->code, top); 363 if (linehook)
364 {const Instruction i = *pc++; 364 traceexec(L, base, top, linehook);
365 switch (GET_OPCODE(i)) { 365 switch (GET_OPCODE(i)) {
366 366
367 case OP_END: 367 case OP_END:
@@ -705,5 +705,5 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
705 break; 705 break;
706 706
707 } 707 }
708 }} 708 }
709} 709}