/* ** fallback.c ** TecCGraf - PUC-Rio */ char *rcs_fallback="$Id: fallback.c,v 1.18 1996/01/30 15:25:23 roberto Exp roberto $"; #include #include #include "mem.h" #include "fallback.h" #include "opcode.h" #include "lua.h" static void errorFB (void); static void indexFB (void); static void gettableFB (void); static void arithFB (void); static void concatFB (void); static void orderFB (void); static void GDFB (void); static void funcFB (void); /* ** Warning: This list must be in the same order as the #define's */ struct FB luaI_fallBacks[] = { {"error", {LUA_T_CFUNCTION, {errorFB}}, 1, 0}, {"index", {LUA_T_CFUNCTION, {indexFB}}, 2, 1}, {"gettable", {LUA_T_CFUNCTION, {gettableFB}}, 2, 1}, {"arith", {LUA_T_CFUNCTION, {arithFB}}, 3, 1}, {"order", {LUA_T_CFUNCTION, {orderFB}}, 3, 1}, {"concat", {LUA_T_CFUNCTION, {concatFB}}, 2, 1}, {"settable", {LUA_T_CFUNCTION, {gettableFB}}, 3, 0}, {"gc", {LUA_T_CFUNCTION, {GDFB}}, 1, 0}, {"function", {LUA_T_CFUNCTION, {funcFB}}, -1, -1}, /* no fixed number of params or results */ {"getglobal", {LUA_T_CFUNCTION, {indexFB}}, 1, 1} /* same default behavior of index FB */ }; #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_error("incorrect argument to function `setfallback'"); for (i=0; i= 0 && ref < lockSize) tag(&lockArray[ref]) = LUA_T_NIL; } Object *luaI_getlocked (int ref) { static Object nul = {LUA_T_NIL, {0}}; if (ref >= 0 && ref < lockSize) return &lockArray[ref]; else return &nul; } void luaI_travlock (int (*fn)(Object *)) { Word i; for (i=0; i