aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-05 18:15:18 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-05 18:15:18 -0200
commit592a309177edc52847b1196969ad6d49ba21f4fb (patch)
tree06add977885c012ee22cc4f105785c435b6af353 /ldo.c
parent413fc7334bf8ceaea71417d73edef15c99d3a793 (diff)
downloadlua-592a309177edc52847b1196969ad6d49ba21f4fb.tar.gz
lua-592a309177edc52847b1196969ad6d49ba21f4fb.tar.bz2
lua-592a309177edc52847b1196969ad6d49ba21f4fb.zip
tag system replaced by event tables
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/ldo.c b/ldo.c
index 4e7722e3..aaf4de55 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.144 2001/11/27 20:56:47 roberto Exp $ 2** $Id: ldo.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -43,8 +43,7 @@ void luaD_init (lua_State *L, int stacksize) {
43 stacksize += EXTRA_STACK; 43 stacksize += EXTRA_STACK;
44 L->stack = luaM_newvector(L, stacksize, TObject); 44 L->stack = luaM_newvector(L, stacksize, TObject);
45 L->stacksize = stacksize; 45 L->stacksize = stacksize;
46 setnilvalue(L->stack); /* the `initial' function */ 46 L->top = L->basefunc.base = L->stack + RESERVED_STACK_PREFIX;
47 L->top = L->basefunc.base = L->stack + 1;
48 restore_stack_limit(L); 47 restore_stack_limit(L);
49} 48}
50 49
@@ -143,12 +142,13 @@ void luaD_call (lua_State *L, StkId func) {
143 CallInfo ci; 142 CallInfo ci;
144 if (ttype(func) != LUA_TFUNCTION) { 143 if (ttype(func) != LUA_TFUNCTION) {
145 /* `func' is not a function; check the `function' tag method */ 144 /* `func' is not a function; check the `function' tag method */
146 Closure *tm = luaT_gettmbyObj(G(L), func, TM_FUNCTION); 145 const TObject *tm = luaT_gettmbyobj(L, func, TM_CALL);
147 if (tm == NULL) 146 if (tm == NULL || ttype(tm) != LUA_TFUNCTION)
148 luaG_typeerror(L, func, "call"); 147 luaG_typeerror(L, func, "call");
149 luaD_openstack(L, func); 148 luaD_openstack(L, func);
150 setclvalue(func, tm); /* tag method is the new function to be called */ 149 setobj(func, tm); /* tag method is the new function to be called */
151 } 150 }
151 lua_assert(ttype(func) == LUA_TFUNCTION);
152 ci.prev = L->ci; /* chain new callinfo */ 152 ci.prev = L->ci; /* chain new callinfo */
153 L->ci = &ci; 153 L->ci = &ci;
154 ci.base = func+1; 154 ci.base = func+1;
@@ -300,9 +300,12 @@ struct lua_longjmp {
300 300
301 301
302static void message (lua_State *L, const char *s) { 302static void message (lua_State *L, const char *s) {
303 StkId top = L->top; 303 TObject o, m;
304 luaV_getglobal(L, luaS_newliteral(L, LUA_ERRORMESSAGE), top); 304 setsvalue(&o, luaS_newliteral(L, LUA_ERRORMESSAGE));
305 if (ttype(top) == LUA_TFUNCTION) { 305 luaV_gettable(L, gt(L), &o, &m);
306 if (ttype(&m) == LUA_TFUNCTION) {
307 StkId top = L->top;
308 setobj(top, &m);
306 incr_top; 309 incr_top;
307 setsvalue(top+1, luaS_new(L, s)); 310 setsvalue(top+1, luaS_new(L, s));
308 incr_top; 311 incr_top;