diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-11-08 01:02:20 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-11-08 01:02:20 +0100 |
commit | 5cc021cedf5d0eb3946d9e5afbb5249afebfd2c8 (patch) | |
tree | b0a56172ae43a1e3f2015839510b6602072eff17 /lib/lua/src/luacomp.c | |
parent | d76fa54bb846140f0b7ed440a1bbf3015ed3a7f6 (diff) |
Small adjustments preparing for LuaJIT.
Diffstat (limited to 'lib/lua/src/luacomp.c')
-rw-r--r-- | lib/lua/src/luacomp.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/lua/src/luacomp.c b/lib/lua/src/luacomp.c deleted file mode 100644 index 298175f..0000000 --- a/lib/lua/src/luacomp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - ** Lua compiler (saves bytecodes to files; also list bytecodes) - ** Highly hacked by Nicolas "Pixel" Noble to be transformed into a - ** small form-factor LUA compiler. - ** See Copyright Notice in lua.h - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "lua.h" -#include "lauxlib.h" - -#include "lfunc.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstring.h" -#include "lundump.h" -#include "ldo.h" - -#ifndef PROGNAME -#define PROGNAME "luacomp" /* program name */ -#endif - -const char * progname = PROGNAME; /* actual program name */ - -#define toproto(L, i) (clvalue(L->top + (i))->l.p) - -static Proto * combine(lua_State * L, int n) { - if (n == 1) - return toproto(L, -1); - else { - int i, pc = 0; - Proto * f = luaF_newproto(L); - - setptvalue2s(L, L->top, f); incr_top(L); - f->source = luaS_newliteral(L, "=(" PROGNAME ")"); - f->maxstacksize = 1; - pc = 2 * n + 1; - f->code = luaM_newvector(L, pc, Instruction); - f->sizecode = pc; - f->p = luaM_newvector(L, n, Proto *); - f->sizep = n; - pc = 0; - for (i = 0; i < n; i++) { - f->p[i] = toproto(L, i - n - 1); - f->code[pc++] = CREATE_ABx(OP_CLOSURE, 0, i); - f->code[pc++] = CREATE_ABC(OP_CALL, 0, 1, 1); - } - f->code[pc++] = CREATE_ABC(OP_RETURN, 0, 1, 0); - return f; - } -} - -#ifdef __cplusplus -extern "C" void luacmain(lua_State * L, int stripping, lua_Chunkwriter w, void *uD, int listing); -#endif - -void luacmain(lua_State * L, int stripping, lua_Chunkwriter w, void *uD, int listing) { - Proto * f; - - f = combine(L, lua_gettop(L)); - if (listing) - luaU_print(f, listing > 1); - lua_lock(L); - luaU_dump(L, f, w, uD, stripping); - lua_unlock(L); -} |