diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-20 09:52:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-20 09:52:32 -0300 |
commit | 63a614e1453b6b03b89b5d47efa476acd5f9d1d2 (patch) | |
tree | 203b7f497a7252e3afeb3651a7c6a09c5a3537b0 /lvm.c | |
parent | 48e732e07d21d585982d1c53be0d9031f021f014 (diff) | |
download | lua-63a614e1453b6b03b89b5d47efa476acd5f9d1d2.tar.gz lua-63a614e1453b6b03b89b5d47efa476acd5f9d1d2.tar.bz2 lua-63a614e1453b6b03b89b5d47efa476acd5f9d1d2.zip |
some improvements in stack control
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.219 2002/03/08 19:10:32 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.220 2002/03/19 12:45:25 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 | */ |
@@ -94,15 +94,14 @@ static void traceexec (lua_State *L, lua_Hook linehook) { | |||
94 | 94 | ||
95 | static void callTMres (lua_State *L, const TObject *f, | 95 | static void callTMres (lua_State *L, const TObject *f, |
96 | const TObject *p1, const TObject *p2, TObject *result ) { | 96 | const TObject *p1, const TObject *p2, TObject *result ) { |
97 | StkId stack = L->stack; | 97 | ptrdiff_t res = savestack(L, result); |
98 | setobj(L->top, f); /* push function */ | 98 | setobj(L->top, f); /* push function */ |
99 | setobj(L->top+1, p1); /* 1st argument */ | 99 | setobj(L->top+1, p1); /* 1st argument */ |
100 | setobj(L->top+2, p2); /* 2nd argument */ | 100 | setobj(L->top+2, p2); /* 2nd argument */ |
101 | luaD_checkstack(L, 3); /* cannot check before (could invalidate p1, p2) */ | 101 | luaD_checkstack(L, 3); /* cannot check before (could invalidate p1, p2) */ |
102 | L->top += 3; | 102 | L->top += 3; |
103 | luaD_call(L, L->top - 3, 1); | 103 | luaD_call(L, L->top - 3, 1); |
104 | if (stack != L->stack) /* stack changed? */ | 104 | result = restorestack(L, res); /* previous call may change stack */ |
105 | result = (result - stack) + L->stack; /* correct pointer */ | ||
106 | setobj(result, --L->top); /* get result */ | 105 | setobj(result, --L->top); /* get result */ |
107 | } | 106 | } |
108 | 107 | ||