1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-23 21:27:31 +02:00

lua: re-enable host builds with some more fixes

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@18189 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2009-10-27 21:18:58 +00:00
parent f0bcf0323b
commit dfe29b760d
7 changed files with 27 additions and 722 deletions

View File

@ -18,7 +18,10 @@ PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
http://www.tecgraf.puc-rio.br/lua/ftp/
PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
HOST_PATCH_DIR := ./patches-host
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
define Package/lua/Default
SUBMENU:=Lua
@ -108,6 +111,27 @@ define Build/Compile
install
endef
define Build/Configure
$(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
endef
LUA_OS.Darwin:=macosx
LUA_OS.FreeBSD:=freebsd
LUA_OS:=$(LUA_OS.$(HOST_OS))
LUA_OS?=linux
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR) \
CC="$(HOSTCC) -std=gnu99" \
$(LUA_OS)
endef
define Host/Install
$(MAKE) -C $(HOST_BUILD_DIR) \
INSTALL_TOP="$(STAGING_DIR_HOST)" \
install
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
@ -145,3 +169,5 @@ $(eval $(call BuildPackage,liblua))
$(eval $(call BuildPackage,lua))
$(eval $(call BuildPackage,luac))
$(eval $(call BuildPackage,lua-examples))
$(eval $(call HostBuild))

View File

@ -1887,7 +1887,7 @@ Index: lua-5.1.4/src/lnum_config.h
+** Default number modes
+*/
+#if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
+# define LNUM_DOUBLE
+# define LNUM_FLOAT
+#endif
+#if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
+# define LNUM_INT32

View File

@ -1,154 +0,0 @@
Index: lua-5.1.4/Makefile
===================================================================
--- lua-5.1.4.orig/Makefile 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/Makefile 2008-08-24 16:48:42.000000000 +0200
@@ -42,8 +42,8 @@
# What to install.
TO_BIN= lua luac
-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
+TO_LIB= liblua.a liblua.so.$R
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -63,6 +63,7 @@
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
ranlib:
Index: lua-5.1.4/src/ldo.h
===================================================================
--- lua-5.1.4.orig/src/ldo.h 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/src/ldo.h 2008-08-24 16:48:42.000000000 +0200
@@ -46,7 +46,7 @@
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
+LUA_API void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
Index: lua-5.1.4/src/lfunc.h
===================================================================
--- lua-5.1.4.orig/src/lfunc.h 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/src/lfunc.h 2008-08-24 16:48:42.000000000 +0200
@@ -18,7 +18,7 @@
cast(int, sizeof(TValue *)*((n)-1)))
-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
+LUA_API Proto *luaF_newproto (lua_State *L);
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
Index: lua-5.1.4/src/lmem.h
===================================================================
--- lua-5.1.4.orig/src/lmem.h 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/src/lmem.h 2008-08-24 16:48:42.000000000 +0200
@@ -38,9 +38,9 @@
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
size_t size);
-LUAI_FUNC void *luaM_toobig (lua_State *L);
+LUA_API void *luaM_toobig (lua_State *L);
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
size_t size_elem, int limit,
const char *errormsg);
Index: lua-5.1.4/src/lstring.h
===================================================================
--- lua-5.1.4.orig/src/lstring.h 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/src/lstring.h 2008-08-24 16:48:42.000000000 +0200
@@ -25,7 +25,7 @@
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
#endif
Index: lua-5.1.4/src/lundump.h
===================================================================
--- lua-5.1.4.orig/src/lundump.h 2008-08-24 16:46:37.000000000 +0200
+++ lua-5.1.4/src/lundump.h 2008-08-24 16:48:42.000000000 +0200
@@ -17,7 +17,7 @@
LUAI_FUNC void luaU_header (char* h);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
#ifdef luac_c
/* print one chunk; from print.c */
Index: lua-5.1.4/src/Makefile
===================================================================
--- lua-5.1.4.orig/src/Makefile 2008-08-24 16:48:20.000000000 +0200
+++ lua-5.1.4/src/Makefile 2008-08-24 16:48:42.000000000 +0200
@@ -23,6 +23,7 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
+LUA_SO= liblua.so
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
lundump.o lvm.o lzio.o lnum.o
@@ -33,11 +34,12 @@
LUA_O= lua.o
LUAC_T= luac
-LUAC_O= luac.o print.o
+LUAC_O= luac.o print.o lopcodes.o
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
ALL_A= $(LUA_A)
+ALL_SO= $(LUA_SO)
default: $(PLAT)
@@ -47,14 +49,23 @@
a: $(ALL_A)
+so: $(ALL_SO)
+
$(LUA_A): $(CORE_O) $(LIB_O)
$(AR) $@ $?
$(RANLIB) $@
-$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+$(LUA_SO): $(CORE_O) $(LIB_O)
+ $(CC) -o $@.$(PKG_VERSION) -shared -soname="$@.$(PKG_VERSION)" $? -nostdlib -lgcc
+ ln -fs $@.$(PKG_VERSION) $@
+
+$(LUA_T): $(LUA_O) $(LUA_SO)
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
+
+$(LUAC_T): $(LUAC_O) $(LUA_SO)
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
-$(LUAC_T): $(LUAC_O) $(LUA_A)
+$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
@@ -96,7 +107,7 @@
$(MAKE) all MYCFLAGS=
linux:
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
+ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
macosx:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"

View File

@ -1,136 +0,0 @@
diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
--- lua-5.1.4.orig/src/Makefile 2009-04-04 23:06:04.000000000 +0200
+++ lua-5.1.4/src/Makefile 2009-04-04 23:06:15.000000000 +0200
@@ -12,7 +12,7 @@
AR= ar rcu
RANLIB= ranlib
RM= rm -f
-LIBS= -lm $(MYLIBS)
+LIBS= -lm -lz $(MYLIBS)
MYCFLAGS=
MYLDFLAGS=
diff -ur lua-5.1.4.orig/src/lauxlib.c lua-5.1.4/src/lauxlib.c
--- lua-5.1.4.orig/src/lauxlib.c 2009-04-04 23:06:04.000000000 +0200
+++ lua-5.1.4/src/lauxlib.c 2009-04-05 03:35:24.000000000 +0200
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <zlib.h>
/* This file uses only the official API of Lua.
@@ -535,6 +536,12 @@
char buff[LUAL_BUFFERSIZE];
} LoadF;
+typedef struct LoadGZ {
+ int first_chunk;
+ gzFile f;
+ char buffer[LUAL_GZLDBUFFER];
+} LoadGZ;
+
static const char *getF (lua_State *L, void *ud, size_t *size) {
LoadF *lf = (LoadF *)ud;
@@ -550,6 +557,28 @@
}
+static const char *getGZ (lua_State *L, void *ud, size_t *size) {
+ LoadGZ *lf = (LoadGZ *)ud;
+ char *sp = 0;
+ (void)L;
+ if (gzeof(lf->f)) return NULL;
+ *size = gzread(lf->f, lf->buffer, sizeof(lf->buffer));
+ if (*size > 0) {
+ if (lf->first_chunk) {
+ lf->first_chunk = 0;
+ if ((lf->buffer[0] == '#') && (lf->buffer[1] == '!') &&
+ (sp=strstr(lf->buffer, "\n")) != NULL)
+ {
+ *size -= ((uint)sp - (uint)lf->buffer);
+ return sp;
+ }
+ }
+ return lf->buffer;
+ }
+ return NULL;
+}
+
+
static int errfile (lua_State *L, const char *what, int fnameindex) {
const char *serr = strerror(errno);
const char *filename = lua_tostring(L, fnameindex) + 1;
@@ -560,6 +589,31 @@
LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
+ if ((filename != NULL) && strstr(filename, ".lua.gz")) {
+ return luaL_loadfile_gzip(L, filename);
+ }
+ else {
+ return luaL_loadfile_plain(L, filename);
+ }
+}
+
+
+LUALIB_API int luaL_loadfile_gzip (lua_State *L, const char *filename) {
+ LoadGZ gzf;
+ int status;
+ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
+ lua_pushfstring(L, "@%s", filename);
+ gzf.f = gzopen(filename, "r");
+ gzf.first_chunk = 1;
+ if (gzf.f == Z_NULL) return errfile(L, "open", fnameindex);
+ status = lua_load(L, getGZ, &gzf, lua_tostring(L, -1));
+ (void)gzclose(gzf.f);
+ lua_remove(L, fnameindex);
+ return status;
+}
+
+
+LUALIB_API int luaL_loadfile_plain (lua_State *L, const char *filename) {
LoadF lf;
int status, readstatus;
int c;
diff -ur lua-5.1.4.orig/src/lauxlib.h lua-5.1.4/src/lauxlib.h
--- lua-5.1.4.orig/src/lauxlib.h 2009-04-04 23:06:04.000000000 +0200
+++ lua-5.1.4/src/lauxlib.h 2009-04-04 23:06:15.000000000 +0200
@@ -81,6 +81,8 @@
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
+LUALIB_API int (luaL_loadfile_gzip) (lua_State *L, const char *filename);
+LUALIB_API int (luaL_loadfile_plain) (lua_State *L, const char *filename);
LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
const char *name);
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
diff -ur lua-5.1.4.orig/src/luaconf.h lua-5.1.4/src/luaconf.h
--- lua-5.1.4.orig/src/luaconf.h 2009-04-04 23:06:04.000000000 +0200
+++ lua-5.1.4/src/luaconf.h 2009-04-04 23:27:20.000000000 +0200
@@ -101,7 +101,9 @@
#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
#define LUA_PATH_DEFAULT \
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
+ "./?.lua.gz;" LUA_LDIR"?.lua.gz;" LUA_LDIR"?/init.lua.gz;" \
+ LUA_CDIR"?.lua.gz;" LUA_CDIR"?/init.lua.gz"
#define LUA_CPATH_DEFAULT \
"./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
#endif
@@ -506,6 +508,12 @@
*/
#define LUAL_BUFFERSIZE BUFSIZ
+
+/*
+@@ LUAL_GZLDBUFFER is the buffer size used by the gzip source loader.
+*/
+#define LUAL_GZLDBUFFER 8192
+
/* }================================================================== */

View File

@ -1,53 +0,0 @@
diff -ur lua-luci-5.1.3/src/luaconf.h lua-luci-5.1.3-new/src/luaconf.h
--- lua-luci-5.1.3/src/luaconf.h 2008-04-14 13:19:54.000000000 +0200
+++ lua-luci-5.1.3-new/src/luaconf.h 2008-04-14 13:19:17.000000000 +0200
@@ -38,7 +38,6 @@
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
-#define LUA_USE_READLINE /* needs some extra libraries */
#endif
#if defined(LUA_USE_MACOSX)
Nur in lua-luci-5.1.3-new/src: luaconf.h.orig.
diff -ur lua-luci-5.1.3/src/Makefile lua-luci-5.1.3-new/src/Makefile
--- lua-luci-5.1.3/src/Makefile 2008-04-14 13:19:57.000000000 +0200
+++ lua-luci-5.1.3-new/src/Makefile 2008-04-14 13:19:17.000000000 +0200
@@ -17,6 +17,7 @@
MYCFLAGS=
MYLDFLAGS=
MYLIBS=
+# USE_READLINE=1
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
@@ -86,7 +87,7 @@
@echo "MYLIBS = $(MYLIBS)"
# convenience targets for popular platforms
-
+RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
none:
@echo "Please choose a platform:"
@echo " $(PLATS)"
@@ -101,16 +102,16 @@
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
freebsd:
- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
+ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
generic:
$(MAKE) all MYCFLAGS=
linux:
- $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
+ $(MAKE) all MYCFLAGS+="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
macosx:
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
# use this on Mac OS X 10.3-
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
Nur in lua-luci-5.1.3-new/src: Makefile.orig.

View File

@ -1,15 +0,0 @@
--- b/src/luaconf.h 2008-05-06 20:10:46.000000000 +0200
+++ a/src/luaconf.h 2008-05-06 20:10:27.000000000 +0200
@@ -95,9 +95,9 @@
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
-#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#define LUA_ROOT "/usr/"
+#define LUA_LDIR LUA_ROOT "share/lua/"
+#define LUA_CDIR LUA_ROOT "lib/lua/"
#define LUA_PATH_DEFAULT \
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"

View File

@ -1,363 +0,0 @@
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -31,6 +31,9 @@
/* limit for table tag-method chains (to avoid loops) */
#define MAXTAGLOOP 100
+#ifdef __GNUC__
+#define COMPUTED_GOTO 1
+#endif
/*
* If 'obj' is a string, it is tried to be interpreted as a number.
@@ -562,12 +565,63 @@
ARITH_OP1_END
#endif
+#ifdef COMPUTED_GOTO
+#define OPCODE_TARGET(op) DO_OP_##op:
+#define CALL_OPCODE(op) goto *opcodes[op];
+#define OPCODE_PTR(op) [OP_##op] = &&DO_OP_##op
+#else
+#define OPCODE_TARGET(op) case OP_##op:
+#define CALL_OPCODE(op) switch (op)
+#endif
+
void luaV_execute (lua_State *L, int nexeccalls) {
LClosure *cl;
StkId base;
TValue *k;
const Instruction *pc;
+#ifdef COMPUTED_GOTO
+ static const void *opcodes[] = {
+ OPCODE_PTR(MOVE),
+ OPCODE_PTR(LOADK),
+ OPCODE_PTR(LOADBOOL),
+ OPCODE_PTR(LOADNIL),
+ OPCODE_PTR(GETUPVAL),
+ OPCODE_PTR(GETGLOBAL),
+ OPCODE_PTR(GETTABLE),
+ OPCODE_PTR(SETGLOBAL),
+ OPCODE_PTR(SETUPVAL),
+ OPCODE_PTR(SETTABLE),
+ OPCODE_PTR(NEWTABLE),
+ OPCODE_PTR(SELF),
+ OPCODE_PTR(ADD),
+ OPCODE_PTR(SUB),
+ OPCODE_PTR(MUL),
+ OPCODE_PTR(DIV),
+ OPCODE_PTR(MOD),
+ OPCODE_PTR(POW),
+ OPCODE_PTR(UNM),
+ OPCODE_PTR(NOT),
+ OPCODE_PTR(LEN),
+ OPCODE_PTR(CONCAT),
+ OPCODE_PTR(JMP),
+ OPCODE_PTR(EQ),
+ OPCODE_PTR(LT),
+ OPCODE_PTR(LE),
+ OPCODE_PTR(TEST),
+ OPCODE_PTR(TESTSET),
+ OPCODE_PTR(CALL),
+ OPCODE_PTR(TAILCALL),
+ OPCODE_PTR(RETURN),
+ OPCODE_PTR(FORLOOP),
+ OPCODE_PTR(FORPREP),
+ OPCODE_PTR(TFORLOOP),
+ OPCODE_PTR(SETLIST),
+ OPCODE_PTR(CLOSE),
+ OPCODE_PTR(CLOSURE),
+ OPCODE_PTR(VARARG)
+ };
+#endif
reentry: /* entry point */
lua_assert(isLua(L->ci));
pc = L->savedpc;
@@ -592,33 +646,33 @@
lua_assert(base == L->base && L->base == L->ci->base);
lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
- switch (GET_OPCODE(i)) {
- case OP_MOVE: {
+ CALL_OPCODE(GET_OPCODE(i)) {
+ OPCODE_TARGET(MOVE) {
setobjs2s(L, ra, RB(i));
continue;
}
- case OP_LOADK: {
+ OPCODE_TARGET(LOADK) {
setobj2s(L, ra, KBx(i));
continue;
}
- case OP_LOADBOOL: {
+ OPCODE_TARGET(LOADBOOL) {
setbvalue(ra, GETARG_B(i));
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
continue;
}
- case OP_LOADNIL: {
+ OPCODE_TARGET(LOADNIL) {
TValue *rb = RB(i);
do {
setnilvalue(rb--);
} while (rb >= ra);
continue;
}
- case OP_GETUPVAL: {
+ OPCODE_TARGET(GETUPVAL) {
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
continue;
}
- case OP_GETGLOBAL: {
+ OPCODE_TARGET(GETGLOBAL) {
TValue g;
TValue *rb = KBx(i);
sethvalue(L, &g, cl->env);
@@ -626,88 +680,88 @@
Protect(luaV_gettable(L, &g, rb, ra));
continue;
}
- case OP_GETTABLE: {
+ OPCODE_TARGET(GETTABLE) {
Protect(luaV_gettable(L, RB(i), RKC(i), ra));
continue;
}
- case OP_SETGLOBAL: {
+ OPCODE_TARGET(SETGLOBAL) {
TValue g;
sethvalue(L, &g, cl->env);
lua_assert(ttisstring(KBx(i)));
Protect(luaV_settable(L, &g, KBx(i), ra));
continue;
}
- case OP_SETUPVAL: {
+ OPCODE_TARGET(SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, ra);
luaC_barrier(L, uv, ra);
continue;
}
- case OP_SETTABLE: {
+ OPCODE_TARGET(SETTABLE) {
Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
continue;
}
- case OP_NEWTABLE: {
+ OPCODE_TARGET(NEWTABLE) {
int b = GETARG_B(i);
int c = GETARG_C(i);
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
Protect(luaC_checkGC(L));
continue;
}
- case OP_SELF: {
+ OPCODE_TARGET(SELF) {
StkId rb = RB(i);
setobjs2s(L, ra+1, rb);
Protect(luaV_gettable(L, rb, RKC(i), ra));
continue;
}
- case OP_ADD: {
+ OPCODE_TARGET(ADD) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue( luai_numadd, try_addint, luai_vectadd );
Protect(Arith(L, ra, rb, rc, TM_ADD)); \
continue;
}
- case OP_SUB: {
+ OPCODE_TARGET(SUB) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue( luai_numsub, try_subint, luai_vectsub );
Protect(Arith(L, ra, rb, rc, TM_SUB));
continue;
}
- case OP_MUL: {
+ OPCODE_TARGET(MUL) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
Protect(Arith(L, ra, rb, rc, TM_MUL));
continue;
}
- case OP_DIV: {
+ OPCODE_TARGET(DIV) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
Protect(Arith(L, ra, rb, rc, TM_DIV));
continue;
}
- case OP_MOD: {
+ OPCODE_TARGET(MOD) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
Protect(Arith(L, ra, rb, rc, TM_MOD));
continue;
}
- case OP_POW: {
+ OPCODE_TARGET(POW) {
TValue *rb = RKB(i), *rc= RKC(i);
arith_op_continue(luai_numpow, try_powint, luai_vectpow);
Protect(Arith(L, ra, rb, rc, TM_POW));
continue;
}
- case OP_UNM: {
+ OPCODE_TARGET(UNM) {
TValue *rb = RB(i);
arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
Protect(Arith(L, ra, rb, rb, TM_UNM));
continue;
}
- case OP_NOT: {
+ OPCODE_TARGET(NOT) {
int res = l_isfalse(RB(i)); /* next assignment may change this value */
setbvalue(ra, res);
continue;
}
- case OP_LEN: {
+ OPCODE_TARGET(LEN) {
const TValue *rb = RB(i);
switch (ttype(rb)) {
case LUA_TTABLE: {
@@ -727,18 +781,18 @@
}
continue;
}
- case OP_CONCAT: {
+ OPCODE_TARGET(CONCAT) {
int b = GETARG_B(i);
int c = GETARG_C(i);
Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
setobjs2s(L, RA(i), base+b);
continue;
}
- case OP_JMP: {
+ OPCODE_TARGET(JMP) {
dojump(L, pc, GETARG_sBx(i));
continue;
}
- case OP_EQ: {
+ OPCODE_TARGET(EQ) {
TValue *rb = RKB(i);
TValue *rc = RKC(i);
Protect(
@@ -748,7 +802,7 @@
pc++;
continue;
}
- case OP_LT: {
+ OPCODE_TARGET(LT) {
Protect(
if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
@@ -756,7 +810,7 @@
pc++;
continue;
}
- case OP_LE: {
+ OPCODE_TARGET(LE) {
Protect(
if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
@@ -764,13 +818,13 @@
pc++;
continue;
}
- case OP_TEST: {
+ OPCODE_TARGET(TEST) {
if (l_isfalse(ra) != GETARG_C(i))
dojump(L, pc, GETARG_sBx(*pc));
pc++;
continue;
}
- case OP_TESTSET: {
+ OPCODE_TARGET(TESTSET) {
TValue *rb = RB(i);
if (l_isfalse(rb) != GETARG_C(i)) {
setobjs2s(L, ra, rb);
@@ -779,7 +833,7 @@
pc++;
continue;
}
- case OP_CALL: {
+ OPCODE_TARGET(CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) L->top = ra+b; /* else previous instruction set top */
@@ -800,7 +854,7 @@
}
}
}
- case OP_TAILCALL: {
+ OPCODE_TARGET(TAILCALL) {
int b = GETARG_B(i);
if (b != 0) L->top = ra+b; /* else previous instruction set top */
L->savedpc = pc;
@@ -832,7 +886,7 @@
}
}
}
- case OP_RETURN: {
+ OPCODE_TARGET(RETURN) {
int b = GETARG_B(i);
if (b != 0) L->top = ra+b-1;
if (L->openupval) luaF_close(L, base);
@@ -847,7 +901,7 @@
goto reentry;
}
}
- case OP_FORLOOP: {
+ OPCODE_TARGET(FORLOOP) {
/* If start,step and limit are all integers, we don't need to check
* against overflow in the looping.
*/
@@ -875,7 +929,7 @@
}
continue;
}
- case OP_FORPREP: {
+ OPCODE_TARGET(FORPREP) {
const TValue *init = ra;
const TValue *plimit = ra+1;
const TValue *pstep = ra+2;
@@ -898,7 +952,7 @@
dojump(L, pc, GETARG_sBx(i));
continue;
}
- case OP_TFORLOOP: {
+ OPCODE_TARGET(TFORLOOP) {
StkId cb = ra + 3; /* call base */
setobjs2s(L, cb+2, ra+2);
setobjs2s(L, cb+1, ra+1);
@@ -914,7 +968,7 @@
pc++;
continue;
}
- case OP_SETLIST: {
+ OPCODE_TARGET(SETLIST) {
int n = GETARG_B(i);
int c = GETARG_C(i);
int last;
@@ -936,11 +990,11 @@
}
continue;
}
- case OP_CLOSE: {
+ OPCODE_TARGET(CLOSE) {
luaF_close(L, ra);
continue;
}
- case OP_CLOSURE: {
+ OPCODE_TARGET(CLOSURE) {
Proto *p;
Closure *ncl;
int nup, j;
@@ -960,7 +1014,7 @@
Protect(luaC_checkGC(L));
continue;
}
- case OP_VARARG: {
+ OPCODE_TARGET(VARARG) {
int b = GETARG_B(i) - 1;
int j;
CallInfo *ci = L->ci;