/* ** Internal function to manipulate arrays. ** Given an array object and a reference value, return the next element ** in the hash. ** This function pushs the element value and its reference to the stack. */ static void hashnext (Hash *t, int i) { if (i >= nhash(t)) return; while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL) { if (++i >= nhash(t)) return; } luaI_pushobject(ref(node(t,i))); luaI_pushobject(val(node(t,i))); }
/* ** Internal function to manipulate arrays. ** Given an array object and a reference value, return the next element ** in the hash. ** This function pushs the element value and its reference to the stack. */ static void hashnext (Hash *t, int i) { Node *n; int tsize = nhash(t); if (i >= tsize) return; n = node(t, i); while (ttype(ref(n)) == LUA_T_NIL || ttype(val(n)) == LUA_T_NIL) { if (++i >= tsize) return; n = node(t, i); } luaI_pushobject(ref(node(t,i))); luaI_pushobject(val(node(t,i))); }
void lua_pushref (int ref) { Object *o = luaI_getref(ref); if (o == NULL) lua_error("access to invalid (possibly garbage collected) reference"); luaI_pushobject(o); }
/* ** Internal function: return next global variable */ static void lua_nextvar (void) { Word next; lua_Object o = lua_getparam(1); if (o == LUA_NOOBJECT) lua_error("too few arguments to function `nextvar'"); if (lua_getparam(2) != LUA_NOOBJECT) lua_error("too many arguments to function `nextvar'"); if (lua_isnil(o)) next = 0; else if (!lua_isstring(o)) { lua_error("incorrect argument to function `nextvar'"); return; /* to avoid warnings */ } else next = luaI_findsymbolbyname(lua_getstring(o)) + 1; while (next < lua_ntable && s_tag(next) == LUA_T_NIL) next++; if (next >= lua_ntable) { lua_pushnil(); lua_pushnil(); } else { lua_pushstring(lua_table[next].varname->str); luaI_pushobject(&s_object(next)); } }
lua_Object lua_getref (int ref) { Object *o = luaI_getref(ref); if (o == NULL) return LUA_NOOBJECT; adjustC(0); luaI_pushobject(o); CLS_current.base++; /* incorporate object in the stack */ return Ref(top-1); }
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<N_FB; i++) { if (strcmp(luaI_fallBacks[i].kind, name) == 0) { luaI_pushobject(&luaI_fallBacks[i].function); luaI_fallBacks[i].function = *luaI_Address(func); return; } } /* name not found */ lua_error("incorrect argument to function `setfallback'"); }