From 9deac27704eee47f858f6b41a386c3198bc49587 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 10 Nov 1994 15:11:52 -0200 Subject: fallback list moved from opcode.c to fallback.c --- fallback.c | 42 ++++++++++++++++++++++++++++++++++- fallback.h | 17 ++++++++++++++- opcode.c | 74 ++++++++++---------------------------------------------------- opcode.h | 3 +-- 4 files changed, 69 insertions(+), 67 deletions(-) diff --git a/fallback.c b/fallback.c index c8bd9736..eee16c28 100644 --- a/fallback.c +++ b/fallback.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_fallback="$Id: fallback.c,v 1.2 1994/11/08 19:56:39 roberto Exp roberto $"; +char *rcs_fallback="$Id: fallback.c,v 1.3 1994/11/09 18:12:42 roberto Exp roberto $"; #include #include @@ -14,6 +14,46 @@ char *rcs_fallback="$Id: fallback.c,v 1.2 1994/11/08 19:56:39 roberto Exp robert #include "lua.h" +/* +** Warning: This list must be in the same order as the #define's +*/ +struct FB luaI_fallBacks[] = { +{"error", {LUA_T_CFUNCTION, luaI_errorFB}}, +{"index", {LUA_T_CFUNCTION, luaI_indexFB}}, +{"gettable", {LUA_T_CFUNCTION, luaI_gettableFB}}, +{"arith", {LUA_T_CFUNCTION, luaI_arithFB}}, +{"order", {LUA_T_CFUNCTION, luaI_orderFB}}, +{"concat", {LUA_T_CFUNCTION, luaI_concatFB}}, +{"unminus", {LUA_T_CFUNCTION, luaI_arithFB}}, +{"settable", {LUA_T_CFUNCTION, luaI_gettableFB}} +}; + +#define N_FB (sizeof(luaI_fallBacks)/sizeof(struct FB)) + +void luaI_setfallback (void) +{ + int i; + char *name = lua_getstring(lua_getparam(1)); + lua_Object func = lua_getparam(2); + if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func))) + { + lua_pushnil(); + return; + } + for (i=0; i #include @@ -50,65 +50,13 @@ static int lua_execute (Byte *pc, int base); static void do_call (Object *func, int base, int nResults, int whereRes); + Object *luaI_Address (lua_Object o) { return Address(o); } -/* -** Fallbacks -*/ - -static struct FB { - char *kind; - Object function; -} fallBacks[] = { -#define FB_ERROR 0 -{"error", {LUA_T_CFUNCTION, luaI_errorFB}}, -#define FB_INDEX 1 -{"index", {LUA_T_CFUNCTION, luaI_indexFB}}, -#define FB_GETTABLE 2 -{"gettable", {LUA_T_CFUNCTION, luaI_gettableFB}}, -#define FB_ARITH 3 -{"arith", {LUA_T_CFUNCTION, luaI_arithFB}}, -#define FB_ORDER 4 -{"order", {LUA_T_CFUNCTION, luaI_orderFB}}, -#define FB_CONCAT 5 -{"concat", {LUA_T_CFUNCTION, luaI_concatFB}}, -#define FB_UNMINUS 6 -{"unminus", {LUA_T_CFUNCTION, luaI_arithFB}}, -#define FB_SETTABLE 7 -{"settable", {LUA_T_CFUNCTION, luaI_gettableFB}} -}; - -#define N_FB (sizeof(fallBacks)/sizeof(struct FB)) - - -void luaI_setfallback (void) -{ - int i; - char *name = lua_getstring(lua_getparam(1)); - lua_Object func = lua_getparam(2); - if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func))) - { - lua_pushnil(); - return; - } - for (i=0; i