aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/ldo.c b/ldo.c
index 19968f32..0c7b4e14 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.197 2002/10/25 20:05:28 roberto Exp roberto $ 2** $Id: ldo.c,v 1.198 2002/11/06 19:08:00 roberto Exp roberto $
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*/
@@ -47,16 +47,16 @@ struct lua_longjmp {
47static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { 47static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
48 switch (errcode) { 48 switch (errcode) {
49 case LUA_ERRMEM: { 49 case LUA_ERRMEM: {
50 setsvalue(oldtop, luaS_new(L, MEMERRMSG)); 50 setsvalue2s(oldtop, luaS_new(L, MEMERRMSG));
51 break; 51 break;
52 } 52 }
53 case LUA_ERRERR: { 53 case LUA_ERRERR: {
54 setsvalue(oldtop, luaS_new(L, "error in error handling")); 54 setsvalue2s(oldtop, luaS_new(L, "error in error handling"));
55 break; 55 break;
56 } 56 }
57 case LUA_ERRSYNTAX: 57 case LUA_ERRSYNTAX:
58 case LUA_ERRRUN: { 58 case LUA_ERRRUN: {
59 setobj(oldtop, L->top - 1); /* error message on current top */ 59 setobjs2s(oldtop, L->top - 1); /* error message on current top */
60 break; 60 break;
61 } 61 }
62 } 62 }
@@ -188,7 +188,7 @@ static void adjust_varargs (lua_State *L, int nfixargs, StkId base) {
188 actual -= nfixargs; /* number of extra arguments */ 188 actual -= nfixargs; /* number of extra arguments */
189 htab = luaH_new(L, 0, 0); /* create `arg' table */ 189 htab = luaH_new(L, 0, 0); /* create `arg' table */
190 for (i=0; i<actual; i++) /* put extra arguments into `arg' table */ 190 for (i=0; i<actual; i++) /* put extra arguments into `arg' table */
191 setobj(luaH_setnum(L, htab, i+1), L->top - actual + i); 191 setobj2t(luaH_setnum(L, htab, i+1), L->top - actual + i);
192 /* store counter in field `n' */ 192 /* store counter in field `n' */
193 setsvalue(&nname, luaS_newliteral(L, "n")); 193 setsvalue(&nname, luaS_newliteral(L, "n"));
194 setnvalue(luaH_set(L, htab, &nname), actual); 194 setnvalue(luaH_set(L, htab, &nname), actual);
@@ -205,10 +205,10 @@ static StkId tryfuncTM (lua_State *L, StkId func) {
205 if (!ttisfunction(tm)) 205 if (!ttisfunction(tm))
206 luaG_typeerror(L, func, "call"); 206 luaG_typeerror(L, func, "call");
207 /* Open a hole inside the stack at `func' */ 207 /* Open a hole inside the stack at `func' */
208 for (p = L->top; p > func; p--) setobj(p, p-1); 208 for (p = L->top; p > func; p--) setobjs2s(p, p-1);
209 incr_top(L); 209 incr_top(L);
210 func = restorestack(L, funcr); /* previous call may change stack */ 210 func = restorestack(L, funcr); /* previous call may change stack */
211 setobj(func, tm); /* tag method is the new function to be called */ 211 setobj2s(func, tm); /* tag method is the new function to be called */
212 return func; 212 return func;
213} 213}
214 214
@@ -270,7 +270,7 @@ void luaD_poscall (lua_State *L, int wanted, StkId firstResult) {
270 L->ci--; 270 L->ci--;
271 /* move results to correct place */ 271 /* move results to correct place */
272 while (wanted != 0 && firstResult < L->top) { 272 while (wanted != 0 && firstResult < L->top) {
273 setobj(res++, firstResult++); 273 setobjs2s(res++, firstResult++);
274 wanted--; 274 wanted--;
275 } 275 }
276 while (wanted-- > 0) 276 while (wanted-- > 0)
@@ -333,10 +333,10 @@ LUA_API int lua_resume (lua_State *L, int nargs) {
333 old_allowhooks = allowhook(L); 333 old_allowhooks = allowhook(L);
334 lua_assert(L->errfunc == 0); 334 lua_assert(L->errfunc == 0);
335 status = luaD_rawrunprotected(L, resume, &nargs); 335 status = luaD_rawrunprotected(L, resume, &nargs);
336 if (status != 0) { 336 if (status != 0) { /* error? */
337 L->ci = L->base_ci; /* `kill' thread (??) */ 337 L->ci = L->base_ci; /* go back to initial level */
338 luaF_close(L, L->ci->base); /* close eventual pending closures */
338 seterrorobj(L, status, L->ci->base); 339 seterrorobj(L, status, L->ci->base);
339 luaF_close(L, L->top); /* close eventual pending closures */
340 setallowhook(L, old_allowhooks); 340 setallowhook(L, old_allowhooks);
341 restore_stack_limit(L); 341 restore_stack_limit(L);
342 } 342 }
@@ -355,7 +355,7 @@ LUA_API int lua_yield (lua_State *L, int nresults) {
355 if (L->top - nresults > ci->base) { /* is there garbage in the stack? */ 355 if (L->top - nresults > ci->base) { /* is there garbage in the stack? */
356 int i; 356 int i;
357 for (i=0; i<nresults; i++) /* move down results */ 357 for (i=0; i<nresults; i++) /* move down results */
358 setobj(ci->base + i, L->top - nresults + i); 358 setobjs2s(ci->base + i, L->top - nresults + i);
359 L->top = ci->base + nresults; 359 L->top = ci->base + nresults;
360 } 360 }
361 lua_unlock(L); 361 lua_unlock(L);
@@ -391,8 +391,8 @@ int luaD_pcall (lua_State *L, int nargs, int nresults, ptrdiff_t errfunc) {
391 status = luaD_rawrunprotected(L, &f_call, &c); 391 status = luaD_rawrunprotected(L, &f_call, &c);
392 if (status != 0) { /* an error occurred? */ 392 if (status != 0) { /* an error occurred? */
393 StkId oldtop = restorestack(L, old_top) - (nargs+1); 393 StkId oldtop = restorestack(L, old_top) - (nargs+1);
394 luaF_close(L, oldtop); /* close eventual pending closures */
394 seterrorobj(L, status, oldtop); 395 seterrorobj(L, status, oldtop);
395 luaF_close(L, L->top); /* close eventual pending closures */
396 L->ci = restoreci(L, old_ci); 396 L->ci = restoreci(L, old_ci);
397 setallowhook(L, old_allowhooks); 397 setallowhook(L, old_allowhooks);
398 restore_stack_limit(L); 398 restore_stack_limit(L);