merge host build of lua from tools/ into package/lua/Makefile

SVN-Revision: 14622
This commit is contained in:
Felix Fietkau 2009-02-22 18:10:23 +00:00
parent aa0778f77e
commit 25d318e815
10 changed files with 18 additions and 4469 deletions

View file

@ -19,6 +19,7 @@ PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
http://www.tecgraf.puc-rio.br/lua/ftp/
PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
define Package/lua/Default
@ -81,9 +82,21 @@ $(call Package/lua/Default/description)
This package contains LUA language examples.
endef
define Build/Configure
# Host build
define Host/Configure
endef
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR)/src luac-host
endef
define Host/Install
$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/luac-host $(STAGING_DIR_HOST)/bin/luac
endef
# Target build
TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC)
ifneq ($(CONFIG_USE_EGLIBC),)
@ -92,6 +105,8 @@ ifneq ($(CONFIG_USE_EGLIBC),)
endif
endif
Build/Configure=$(Host/Configure)
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CROSS)gcc" \
@ -140,6 +155,7 @@ define Package/lua-examples/install
$(1)/usr/share/lua/examples/
endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,liblua))
$(eval $(call BuildPackage,lua))
$(eval $(call BuildPackage,luac))

View file

@ -9,7 +9,7 @@
curdir:=tools
# subdirectories to descend into
$(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) lua quilt autoconf $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) yaffs2
$(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) quilt autoconf $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) yaffs2
# builddir dependencies
$(curdir)/squashfs/compile := $(curdir)/lzma/install

View file

@ -1,42 +0,0 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=lua
PKG_VERSION:=5.1.4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
http://ftp.gwdg.de/pub/languages/lua/ \
http://mirrors.dotsrc.org/lua/ \
http://www.tecgraf.puc-rio.br/lua/ftp/
PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
include $(INCLUDE_DIR)/host-build.mk
define Host/Configure
endef
TARGET_CFLAGS += -DLUA_USE_LINUX
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR)/src luac-host
endef
define Host/Install
$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/luac-host $(STAGING_DIR_HOST)/bin/luac
endef
define Host/Clean
$(MAKE) -C $(HOST_BUILD_DIR)/src clean
rm -f $(HOST_BUILD_DIR)/src/luac-host
$(call Host/Clean/Default)
endef
$(eval $(call HostBuild))

File diff suppressed because it is too large Load diff

View file

@ -1,11 +0,0 @@
--- a/src/lua.h
+++ b/src/lua.h
@@ -79,7 +79,7 @@ typedef void * (*lua_Alloc) (void *ud, v
* not acceptable for 5.1, maybe 5.2 onwards?
* 9: greater than existing (5.1) type values.
*/
-#define LUA_TINT (-2)
+#define LUA_TINT 9
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1

View file

@ -1,140 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -42,8 +42,8 @@ PLATS= aix ansi bsd freebsd generic linu
# 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 @@ install: dummy
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:
--- a/src/ldo.h
+++ b/src/ldo.h
@@ -46,7 +46,7 @@ LUAI_FUNC int luaD_pcall (lua_State *L,
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);
--- a/src/lfunc.h
+++ b/src/lfunc.h
@@ -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);
--- a/src/lmem.h
+++ b/src/lmem.h
@@ -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);
--- a/src/lstring.h
+++ b/src/lstring.h
@@ -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
--- a/src/lundump.h
+++ b/src/lundump.h
@@ -17,7 +17,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State*
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 */
--- a/src/Makefile
+++ b/src/Makefile
@@ -23,6 +23,7 @@ MYLIBS=
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_T= lua
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 @@ o: $(ALL_O)
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 @@ generic:
$(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,111 +0,0 @@
--- a/src/ldump.c
+++ b/src/ldump.c
@@ -67,12 +67,12 @@ static void DumpString(const TString* s,
{
if (s==NULL || getstr(s)==NULL)
{
- size_t size=0;
+ unsigned int size=0;
DumpVar(size,D);
}
else
{
- size_t size=s->tsv.len+1; /* include trailing '\0' */
+ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size,D);
}
--- a/src/lundump.c
+++ b/src/lundump.c
@@ -25,6 +25,7 @@ typedef struct {
ZIO* Z;
Mbuffer* b;
const char* name;
+ int swap;
} LoadState;
#ifdef LUAC_TRUST_BINARIES
@@ -40,7 +41,6 @@ static void error(LoadState* S, const ch
}
#endif
-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
#define LoadByte(S) (lu_byte)LoadChar(S)
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
@@ -51,6 +51,49 @@ static void LoadBlock(LoadState* S, void
IF (r!=0, "unexpected end");
}
+static void LoadMem (LoadState* S, void* b, int n, size_t size)
+{
+ LoadBlock(S,b,n*size);
+ if (S->swap)
+ {
+ char* p=(char*) b;
+ char c;
+ switch (size)
+ {
+ case 1:
+ break;
+ case 2:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[1]; p[1]=c;
+ p+=2;
+ }
+ break;
+ case 4:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[3]; p[3]=c;
+ c=p[1]; p[1]=p[2]; p[2]=c;
+ p+=4;
+ }
+ break;
+ case 8:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[7]; p[7]=c;
+ c=p[1]; p[1]=p[6]; p[6]=c;
+ c=p[2]; p[2]=p[5]; p[5]=c;
+ c=p[3]; p[3]=p[4]; p[4]=c;
+ p+=8;
+ }
+ break;
+ default:
+ IF(1, "bad size");
+ break;
+ }
+ }
+}
+
static int LoadChar(LoadState* S)
{
char x;
@@ -82,7 +125,7 @@ static lua_Integer LoadInteger(LoadState
static TString* LoadString(LoadState* S)
{
- size_t size;
+ unsigned int size;
LoadVar(S,size);
if (size==0)
return NULL;
@@ -196,6 +239,7 @@ static void LoadHeader(LoadState* S)
char s[LUAC_HEADERSIZE];
luaU_header(h);
LoadBlock(S,s,LUAC_HEADERSIZE);
+ S->swap=(s[6]!=h[6]); s[6]=h[6];
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
}
@@ -230,7 +274,7 @@ void luaU_header (char* h)
*h++=(char)LUAC_FORMAT;
*h++=(char)*(char*)&x; /* endianness */
*h++=(char)sizeof(int);
- *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(unsigned int);
*h++=(char)sizeof(Instruction);
*h++=(char)sizeof(lua_Number);

View file

@ -1,49 +0,0 @@
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -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)
--- a/src/Makefile
+++ b/src/Makefile
@@ -17,6 +17,7 @@ LIBS= -lm $(MYLIBS)
MYCFLAGS=
MYLDFLAGS=
MYLIBS=
+# USE_READLINE=1
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
@@ -86,7 +87,7 @@ echo:
@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 @@ bsd:
$(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

View file

@ -1,15 +0,0 @@
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -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 @@ static inline int arith_mode( const TVal
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
}
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
}
}
}
- 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 @@ void luaV_execute (lua_State *L, int nex
}
}
}
- 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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
}
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 @@ void luaV_execute (lua_State *L, int nex
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 @@ void luaV_execute (lua_State *L, int nex
pc++;
continue;
}
- case OP_SETLIST: {
+ OPCODE_TARGET(SETLIST) {
int n = GETARG_B(i);
int c = GETARG_C(i);
int last;
@@ -936,11 +990,11 @@ void luaV_execute (lua_State *L, int nex
}
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 @@ void luaV_execute (lua_State *L, int nex
Protect(luaC_checkGC(L));
continue;
}
- case OP_VARARG: {
+ OPCODE_TARGET(VARARG) {
int b = GETARG_B(i) - 1;
int j;
CallInfo *ci = L->ci;