commit 52aad0ab5937d4df6fe07aedbf9987f2f792698c
parent 74f1c3d025c6d8a714454470a953f383a1c6a641
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 11 Feb 2000 14:52:32 -0200
removing implementation for better error messages (must rethink it...)
Diffstat:
5 files changed, 25 insertions(+), 102 deletions(-)
diff --git a/ldebug.c b/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.6 2000/01/25 13:57:18 roberto Exp roberto $
+** $Id: ldebug.c,v 1.7 2000/01/28 16:53:00 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -85,21 +85,6 @@ int lua_getstack (lua_State *L, int level, lua_Dbgactreg *ar) {
}
-static const char *luaG_getname (lua_State *L, const char **name, StkId top) {
- StkId f = aux_stackedfunction(L, 0, top);
- if (f == NULL || !hasdebuginfo(L, f) || ttype(f+2) == LUA_T_NIL)
- return ""; /* no name available */
- else {
- int i = (f+2)->value.i;
- if (ttype(f) == LUA_T_LCLMARK)
- f = protovalue(f);
- LUA_ASSERT(L, ttype(f) == LUA_T_LMARK, "must be a Lua function");
- *name = tfvalue(f)->kstr[i]->str;
- return luaO_typename(f+2);
- }
-}
-
-
static int lua_nups (StkId f) {
switch (ttype(f)) {
case LUA_T_LCLOSURE: case LUA_T_CCLOSURE:
@@ -131,10 +116,10 @@ int lua_getlocal (lua_State *L, const lua_Dbgactreg *ar, lua_Dbglocvar *v) {
if (!fp) return 0; /* `f' is not a Lua function? */
v->name = luaF_getlocalname(fp, v->index, lua_currentline(L, f));
if (!v->name) return 0;
- /* if `name', there must be a LUA_T_LINE and a NAME */
- /* therefore, f+3 points to function base */
+ /* if `name', there must be a LUA_T_LINE */
+ /* therefore, f+2 points to function base */
LUA_ASSERT(L, ttype(f+1) == LUA_T_LINE, "");
- v->value = luaA_putluaObject(L, (f+3)+(v->index-1));
+ v->value = luaA_putluaObject(L, (f+2)+(v->index-1));
return 1;
}
@@ -146,7 +131,7 @@ int lua_setlocal (lua_State *L, const lua_Dbgactreg *ar, lua_Dbglocvar *v) {
v->name = luaF_getlocalname(fp, v->index, lua_currentline(L, f));
if (!v->name) return 0;
LUA_ASSERT(L, ttype(f+1) == LUA_T_LINE, "");
- *((f+3)+(v->index-1)) = *v->value;
+ *((f+2)+(v->index-1)) = *v->value;
return 1;
}
@@ -181,8 +166,6 @@ static int checkfunc (lua_State *L, TObject *o) {
static void lua_getobjname (lua_State *L, StkId f, lua_Dbgactreg *ar) {
GlobalVar *g;
- ar->namewhat = luaG_getname(L, &ar->name, f); /* caller debug information */
- if (*ar->namewhat) return;
/* try to find a name for given function */
setnormalized(L->top, f); /* to be used by `checkfunc' */
for (g=L->rootglobal; g; g=g->next) {
@@ -229,24 +212,16 @@ int lua_getinfo (lua_State *L, const char *what, lua_Dbgactreg *ar) {
-static void call_index_error (lua_State *L, TObject *o, const char *tp,
- const char *v) {
- const char *name;
- const char *kind = luaG_getname(L, &name, L->top);
- if (*kind) { /* is there a name? */
- luaL_verror(L, "%.10s `%.30s' is not a %.10s", kind, name, tp);
- }
- else {
- luaL_verror(L, "attempt to %.10s a %.10s value", v, lua_type(L, o));
- }
+static void call_index_error (lua_State *L, TObject *o, const char *v) {
+ luaL_verror(L, "attempt to %.10s a %.10s value", v, lua_type(L, o));
}
void luaG_callerror (lua_State *L, TObject *func) {
- call_index_error(L, func, "function", "call");
+ call_index_error(L, func, "call");
}
void luaG_indexerror (lua_State *L, TObject *t) {
- call_index_error(L, t, "table", "index");
+ call_index_error(L, t, "index");
}
diff --git a/lobject.h b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 1.44 2000/01/25 13:57:18 roberto Exp roberto $
+** $Id: lobject.h,v 1.45 2000/01/28 16:53:00 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -81,10 +81,7 @@ typedef enum {
LUA_T_LMARK = -11, /* mark for Lua prototypes */
LUA_T_CMARK = -12, /* mark for C prototypes */
- LUA_T_LINE = -13,
- LUA_T_NGLOBAL = -14,
- LUA_T_NLOCAL = -15,
- LUA_T_NDOT = -16
+ LUA_T_LINE = -13
} lua_Type;
#define NUM_TAGS 7 /* tags for values visible from Lua */
diff --git a/lopcodes.h b/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.37 2000/01/25 13:57:18 roberto Exp roberto $
+** $Id: lopcodes.h,v 1.38 2000/01/28 16:53:00 roberto Exp roberto $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -104,9 +104,6 @@ CLOSURE,/* b c v_c-v_1 closure(CNST[b], v_c-v_1) */
SETLINEW,/* w - - LINE=w */
SETLINE,/* b - - LINE=b */
-SETNAMEW,/* w c - - NAME=CNST[w],c */
-SETNAME,/* b c - - NAME=CNST[b],c */
-
LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */
LONGARG /* b (add b*(1<<16) to arg of next instruction) */
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 1.56 2000/01/25 18:44:21 roberto Exp roberto $
+** $Id: lparser.c,v 1.57 2000/01/28 16:53:00 roberto Exp roberto $
** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -63,8 +63,6 @@ typedef enum {
typedef struct vardesc {
varkind k;
int info;
- varkind prev_k; /* for debug information (NAMEs) */
- int prev_info;
} vardesc;
@@ -386,31 +384,6 @@ static void check_debugline (LexState *ls) {
}
-static void code_setname (LexState *ls, const vardesc *v) {
- if (ls->L->debug) {
- switch (v->prev_k) {
- case VGLOBAL:
- code_oparg(ls, SETNAME, v->prev_info, 0);
- code_byte(ls, -LUA_T_NGLOBAL);
- break;
- case VLOCAL: {
- TaggedString *varname = ls->fs->localvar[v->prev_info];
- code_oparg(ls, SETNAME, string_constant(ls, ls->fs, varname), 0);
- code_byte(ls, -LUA_T_NLOCAL);
- break;
- }
- case VDOT:
- code_oparg(ls, SETNAME, v->prev_info, 0);
- code_byte(ls, -LUA_T_NDOT);
- break;
- default: /* VINDEXED or VEXP: no debug information */
- code_oparg(ls, SETNAME, 0, 0);
- code_byte(ls, -LUA_T_NIL);
- }
- }
-}
-
-
static void adjuststack (LexState *ls, int n) {
if (n > 0)
code_oparg(ls, POP, n, -n);
@@ -485,19 +458,15 @@ static void lua_pushvar (LexState *ls, vardesc *var) {
assertglobal(ls, var->info); /* make sure that there is a global */
break;
case VDOT:
- code_setname(ls, var);
code_oparg(ls, GETDOTTED, var->info, 0);
break;
case VINDEXED:
- code_setname(ls, var);
code_opcode(ls, GETTABLE, -1);
break;
case VEXP:
close_exp(ls, var->info, 1); /* function must return 1 value */
break;
}
- var->prev_k = var->k; /* save previous var kind and info */
- var->prev_info = var->info;
var->k = VEXP;
var->info = 0; /* now this is a closed expression */
}
@@ -513,7 +482,6 @@ static void storevar (LexState *ls, const vardesc *var) {
assertglobal(ls, var->info); /* make sure that there is a global */
break;
case VINDEXED:
- code_setname(ls, var);
code_opcode(ls, SETTABLEPOP, -3);
break;
default:
@@ -749,7 +717,7 @@ static void explist (LexState *ls, listdesc *d) {
}
-static int funcparams (LexState *ls, int slf, vardesc *v) {
+static int funcparams (LexState *ls, int slf) {
FuncState *fs = ls->fs;
int slevel = fs->stacksize - slf - 1; /* where is func in the stack */
switch (ls->token) {
@@ -776,7 +744,6 @@ static int funcparams (LexState *ls, int slf, vardesc *v) {
luaY_error(ls, "function arguments expected");
break;
}
- code_setname(ls, v);
code_byte(ls, CALL);
code_byte(ls, 0); /* save space for nresult */
code_byte(ls, (Byte)slevel);
@@ -808,19 +775,16 @@ static void var_or_func_tail (LexState *ls, vardesc *v) {
next(ls);
name = checkname(ls);
lua_pushvar(ls, v); /* `v' must be on stack */
- code_setname(ls, v);
code_oparg(ls, PUSHSELF, name, 1);
- v->prev_k = VDOT; /* ':' is syntactic sugar for '.' */
- v->prev_info = name;
v->k = VEXP;
- v->info = funcparams(ls, 1, v);
+ v->info = funcparams(ls, 1);
break;
}
case '(': case STRING: case '{': /* var_or_func_tail -> funcparams */
lua_pushvar(ls, v); /* `v' must be on stack */
v->k = VEXP;
- v->info = funcparams(ls, 0, v);
+ v->info = funcparams(ls, 0);
break;
default: return; /* should be follow... */
@@ -1203,7 +1167,6 @@ static int assignment (LexState *ls, vardesc *v, int nvars) {
storevar(ls, v);
}
else { /* indexed var with values in between*/
- code_setname(ls, v);
code_oparg(ls, SETTABLE, left+(nvars-1), -1);
left += 2; /* table&index are not popped, because they aren't on top */
}
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.84 2000/01/28 16:53:00 roberto Exp roberto $
+** $Id: lvm.c,v 1.85 2000/02/08 16:39:42 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -642,27 +642,18 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
case SETLINEW: aux += highbyte(L, *pc++);
case SETLINE: aux += *pc++;
- if ((base-2)->ttype != LUA_T_LINE) {
- /* open space for LINE and NAME values */
+ if ((base-1)->ttype != LUA_T_LINE) {
+ /* open space for LINE value */
int i = top-base;
- while (i--) base[i+2] = base[i];
- base += 2;
- top += 2;
- (base-1)->ttype = LUA_T_NIL; /* initial value for NAME */
- (base-2)->ttype = LUA_T_LINE;
+ while (i--) base[i+1] = base[i];
+ base++;
+ top++;
+ (base-1)->ttype = LUA_T_LINE;
}
- (base-2)->value.i = aux;
+ (base-1)->value.i = aux;
if (L->linehook) {
L->top = top;
- luaD_lineHook(L, base-3, aux);
- }
- break;
-
- case SETNAMEW: aux += highbyte(L, *pc++);
- case SETNAME: aux += *pc++;
- if ((base-2)->ttype == LUA_T_LINE) { /* function has debug info? */
- (base-1)->ttype = (lua_Type)(-(*pc++));
- (base-1)->value.i = aux;
+ luaD_lineHook(L, base-2, aux);
}
break;