diff options
author | niemeyer <devnull@localhost> | 2004-03-19 21:14:32 +0000 |
---|---|---|
committer | niemeyer <devnull@localhost> | 2004-03-19 21:14:32 +0000 |
commit | fa111e33baa1443d7d84b0872234e60f46ab948f (patch) | |
tree | f362091fc9585e9700ed80a23424ff4af690890b /lua | |
parent | 635edd95230e17e8ada5793719d7e385e729df30 (diff) | |
download | librpm-tizen-fa111e33baa1443d7d84b0872234e60f46ab948f.tar.gz librpm-tizen-fa111e33baa1443d7d84b0872234e60f46ab948f.tar.bz2 librpm-tizen-fa111e33baa1443d7d84b0872234e60f46ab948f.zip |
Upgrading to Lua 5.0.2.
CVS patchset: 7179
CVS date: 2004/03/19 21:14:32
Diffstat (limited to 'lua')
-rw-r--r-- | lua/COPYRIGHT | 2 | ||||
-rw-r--r-- | lua/include/lua.h | 8 | ||||
-rw-r--r-- | lua/ldo.c | 25 | ||||
-rw-r--r-- | lua/lgc.c | 23 | ||||
-rw-r--r-- | lua/lgc.h | 4 | ||||
-rw-r--r-- | lua/lib/lbaselib.c | 7 | ||||
-rw-r--r-- | lua/lib/liolib.c | 6 | ||||
-rw-r--r-- | lua/lparser.c | 10 | ||||
-rw-r--r-- | lua/luac/luac.c | 4 | ||||
-rw-r--r-- | lua/lvm.c | 15 |
10 files changed, 65 insertions, 39 deletions
diff --git a/lua/COPYRIGHT b/lua/COPYRIGHT index fd3cdf9b3..16321abf6 100644 --- a/lua/COPYRIGHT +++ b/lua/COPYRIGHT @@ -9,7 +9,7 @@ For details and rationale, see http://www.lua.org/license.html . =============================================================================== -Copyright (C) 2003 Tecgraf, PUC-Rio. +Copyright (C) 2003-2004 Tecgraf, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lua/include/lua.h b/lua/include/lua.h index 56415a565..99838f4e0 100644 --- a/lua/include/lua.h +++ b/lua/include/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lua.h,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Lua - An Extensible Extension Language ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** http://www.lua.org mailto:info@lua.org @@ -14,8 +14,8 @@ #include <stddef.h> -#define LUA_VERSION "Lua 5.0" -#define LUA_COPYRIGHT "Copyright (C) 1994-2003 Tecgraf, PUC-Rio" +#define LUA_VERSION "Lua 5.0.2" +#define LUA_COPYRIGHT "Copyright (C) 1994-2004 Tecgraf, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" @@ -365,7 +365,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2003 Tecgraf, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2004 Tecgraf, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: ldo.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -322,11 +322,11 @@ static void resume (lua_State *L, void *ud) { int nargs = *cast(int *, ud); CallInfo *ci = L->ci; if (ci == L->base_ci) { /* no activation record? */ - if (nargs >= L->top - L->base) - luaG_runerror(L, "cannot resume dead coroutine"); + lua_assert(nargs < L->top - L->base); luaD_precall(L, L->top - (nargs + 1)); /* start coroutine */ } - else if (ci->state & CI_YIELD) { /* inside a yield? */ + else { /* inside a yield */ + lua_assert(ci->state & CI_YIELD); if (ci->state & CI_C) { /* `common' yield? */ /* finish interrupted execution of `OP_CALL' */ int nresults; @@ -341,18 +341,31 @@ static void resume (lua_State *L, void *ud) { ci->state &= ~CI_YIELD; } } - else - luaG_runerror(L, "cannot resume non-suspended coroutine"); firstResult = luaV_execute(L); if (firstResult != NULL) /* return? */ luaD_poscall(L, LUA_MULTRET, firstResult); /* finalize this coroutine */ } +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + LUA_API int lua_resume (lua_State *L, int nargs) { int status; lu_byte old_allowhooks; lua_lock(L); + if (L->ci == L->base_ci) { + if (nargs >= L->top - L->base) + return resume_error(L, "cannot resume dead coroutine"); + } + else if (!(L->ci->state & CI_YIELD)) /* not inside a yield? */ + return resume_error(L, "cannot resume non-suspended coroutine"); old_allowhooks = L->allowhook; lua_assert(L->errfunc == 0 && L->nCcalls == 0); status = luaD_rawrunprotected(L, resume, &nargs); @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lgc.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -110,7 +110,8 @@ static void marktmu (GCState *st) { /* move `dead' udata that need finalization to list `tmudata' */ -void luaC_separateudata (lua_State *L) { +size_t luaC_separateudata (lua_State *L) { + size_t deadmem = 0; GCObject **p = &G(L)->rootudata; GCObject *curr; GCObject *collected = NULL; /* to collect udata with gc event */ @@ -125,6 +126,7 @@ void luaC_separateudata (lua_State *L) { p = &curr->gch.next; } else { /* must call its gc method */ + deadmem += sizeudata(gcotou(curr)->uv.len); *p = curr->gch.next; curr->gch.next = NULL; /* link `curr' at the end of `collected' list */ *lastcollected = curr; @@ -134,6 +136,7 @@ void luaC_separateudata (lua_State *L) { /* insert collected udata with gc event into `tmudata' list */ *lastcollected = G(L)->tmudata; G(L)->tmudata = collected; + return deadmem; } @@ -244,7 +247,7 @@ static void traversestack (GCState *st, lua_State *L1) { for (ci = L1->base_ci; ci <= L1->ci; ci++) { lua_assert(ci->top <= L1->stack_last); lua_assert(ci->state & (CI_C | CI_HASFRAME | CI_SAVEDPC)); - if (!(ci->state & CI_C) && lim < ci->top) + if (lim < ci->top) lim = ci->top; } for (o = L1->stack; o < L1->top; o++) @@ -387,7 +390,7 @@ static void sweepstrings (lua_State *L, int all) { } -static void checkSizes (lua_State *L) { +static void checkSizes (lua_State *L, size_t deadmem) { /* check size of string hash */ if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) && G(L)->strt.size > MINSTRTABSIZE*2) @@ -397,7 +400,7 @@ static void checkSizes (lua_State *L) { size_t newsize = luaZ_sizebuffer(&G(L)->buff) / 2; luaZ_resizebuffer(L, &G(L)->buff, newsize); } - G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ + G(L)->GCthreshold = 2*G(L)->nblocks - deadmem; /* new threshold */ } @@ -451,7 +454,8 @@ static void markroot (GCState *st, lua_State *L) { } -static void mark (lua_State *L) { +static size_t mark (lua_State *L) { + size_t deadmem; GCState st; GCObject *wkv; st.g = G(L); @@ -464,7 +468,7 @@ static void mark (lua_State *L) { wkv = st.wkv; /* keys must be cleared after preserving udata */ st.wkv = NULL; st.wv = NULL; - luaC_separateudata(L); /* separate userdata to be preserved */ + deadmem = luaC_separateudata(L); /* separate userdata to be preserved */ marktmu(&st); /* mark `preserved' userdata */ propagatemarks(&st); /* remark, to propagate `preserveness' */ cleartablekeys(wkv); @@ -473,13 +477,14 @@ static void mark (lua_State *L) { cleartablevalues(st.wv); cleartablekeys(st.wkv); cleartablevalues(st.wkv); + return deadmem; } void luaC_collectgarbage (lua_State *L) { - mark(L); + size_t deadmem = mark(L); luaC_sweep(L, 0); - checkSizes(L); + checkSizes(L, deadmem); luaC_callGCTM(L); } @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lgc.h,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -15,7 +15,7 @@ if (G(L)->nblocks >= G(L)->GCthreshold) luaC_collectgarbage(L); } -void luaC_separateudata (lua_State *L); +size_t luaC_separateudata (lua_State *L); void luaC_callGCTM (lua_State *L); void luaC_sweep (lua_State *L, int all); void luaC_collectgarbage (lua_State *L); diff --git a/lua/lib/lbaselib.c b/lua/lib/lbaselib.c index 72114c083..e7b0fe33b 100644 --- a/lua/lib/lbaselib.c +++ b/lua/lib/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lbaselib.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -274,10 +274,11 @@ static int luaB_loadfile (lua_State *L) { static int luaB_dofile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); int status = luaL_loadfile(L, fname); if (status != 0) lua_error(L); lua_call(L, 0, LUA_MULTRET); - return lua_gettop(L) - 1; + return lua_gettop(L) - n; } @@ -324,7 +325,7 @@ static int luaB_xpcall (lua_State *L) { static int luaB_tostring (lua_State *L) { - char buff[64]; + char buff[128]; luaL_checkany(L, 1); if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ return 1; /* use its value */ diff --git a/lua/lib/liolib.c b/lua/lib/liolib.c index 0ff671c1e..3e3963644 100644 --- a/lua/lib/liolib.c +++ b/lua/lib/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: liolib.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -158,7 +158,7 @@ static int aux_close (lua_State *L) { static int io_close (lua_State *L) { - if (lua_isnone(L, 1)) { + if (lua_isnone(L, 1) && lua_type(L, lua_upvalueindex(1)) == LUA_TTABLE) { lua_pushstring(L, IO_OUTPUT); lua_rawget(L, lua_upvalueindex(1)); } @@ -175,7 +175,7 @@ static int io_gc (lua_State *L) { static int io_tostring (lua_State *L) { - char buff[32]; + char buff[128]; FILE **f = topfile(L, 1); if (*f == NULL) strcpy(buff, "closed"); diff --git a/lua/lparser.c b/lua/lparser.c index 35fd6d300..81341bf92 100644 --- a/lua/lparser.c +++ b/lua/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lparser.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -1141,11 +1141,15 @@ static void ifstat (LexState *ls, int line) { static void localfunc (LexState *ls) { expdesc v, b; + FuncState *fs = ls->fs; new_localvar(ls, str_checkname(ls), 0); - init_exp(&v, VLOCAL, ls->fs->freereg++); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); adjustlocalvars(ls, 1); body(ls, &b, 0, ls->linenumber); - luaK_storevar(ls->fs, &v, &b); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; } diff --git a/lua/luac/luac.c b/lua/luac/luac.c index 12bff913e..e319ebc9f 100644 --- a/lua/luac/luac.c +++ b/lua/luac/luac.c @@ -1,5 +1,5 @@ /* -** $Id: luac.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: luac.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Lua compiler (saves bytecodes to files; also list bytecodes) ** See Copyright Notice in lua.h */ @@ -182,7 +182,9 @@ int main(int argc, char* argv[]) FILE* D=fopen(output,"wb"); if (D==NULL) cannot(output,"open","out"); if (stripping) strip(L,f); + lua_lock(L); luaU_dump(L,f,writer,D); + lua_unlock(L); if (ferror(D)) cannot(output,"write","out"); fclose(D); } @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lvm.c,v 1.2 2004/03/19 21:14:32 niemeyer Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -66,7 +66,7 @@ int luaV_tostring (lua_State *L, StkId obj) { static void traceexec (lua_State *L) { lu_byte mask = L->hookmask; - if (mask > LUA_MASKLINE) { /* instruction-hook set? */ + if (mask & LUA_MASKCOUNT) { /* instruction-hook set? */ if (L->hookcount == 0) { resethookcount(L); luaD_callhook(L, LUA_HOOKCOUNT, -1); @@ -399,10 +399,12 @@ StkId luaV_execute (lua_State *L) { TObject *k; const Instruction *pc; callentry: /* entry point when calling new functions */ - L->ci->u.l.pc = &pc; - if (L->hookmask & LUA_MASKCALL) + if (L->hookmask & LUA_MASKCALL) { + L->ci->u.l.pc = &pc; luaD_callhook(L, LUA_HOOKCALL, -1); + } retentry: /* entry point when returning to old functions */ + L->ci->u.l.pc = &pc; lua_assert(L->ci->state == CI_SAVEDPC || L->ci->state == (CI_SAVEDPC | CI_CALLING)); L->ci->state = CI_HASFRAME; /* activate frame */ @@ -673,9 +675,7 @@ StkId luaV_execute (lua_State *L) { } else { /* yes: continue its execution */ int nresults; - lua_assert(ci->u.l.pc == &pc && - ttisfunction(ci->base - 1) && - (ci->state & CI_SAVEDPC)); + lua_assert(ttisfunction(ci->base - 1) && (ci->state & CI_SAVEDPC)); lua_assert(GET_OPCODE(*(ci->u.l.savedpc - 1)) == OP_CALL); nresults = GETARG_C(*(ci->u.l.savedpc - 1)) - 1; luaD_poscall(L, nresults, ra); @@ -778,3 +778,4 @@ StkId luaV_execute (lua_State *L) { } } + |