/* ** Get a global object. */ lua_Object lua_getglobal (char *name) { adjustC(0); getglobal(luaI_findsymbolbyname(name)); CLS_current.base++; /* incorporate object in the stack */ return Ref(top-1); }
/* ** 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)); } }
int lua_call (char *funcname) { Word n = luaI_findsymbolbyname(funcname); open_stack((top-stack)-CLS_current.base); stack[CLS_current.base] = s_object(n); return do_protectedrun(MULT_RET); }
void luaI_initsymbol (void) { int i; lua_maxsymbol = BUFFER_BLOCK; lua_table = newvector(lua_maxsymbol, Symbol); for (i=0; i<INTFUNCSIZE; i++) { Word n = luaI_findsymbolbyname(int_funcs[i].name); s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = int_funcs[i].func; } }
/* ** Store top of the stack at a global variable array field. */ void lua_storeglobal (char *name) { Word n = luaI_findsymbolbyname(name); adjustC(1); s_object(n) = *(--top); }
void lua_rawsetglobal (char *name) { Word n = luaI_findsymbolbyname(name); checkCparams(1); s_object(n) = *(--top); }
void lua_setglobal (char *name) { checkCparams(1); setglobal(luaI_findsymbolbyname(name)); }
lua_Object lua_rawgetglobal (char *name) { return put_luaObject(&lua_table[luaI_findsymbolbyname(name)].object); }
/* ** Get a global object. */ lua_Object lua_getglobal (char *name) { getglobal(luaI_findsymbolbyname(name)); return put_luaObjectonTop(); }