public static void luaG_aritherror(LuaState L, TValue p1, TValue p2) { TValue temp = new TValue(); if (luaV_tonumber(p1, temp) == null) p2 = p1; /* first operand is wrong */ luaG_typeerror(L, p2, "perform arithmetic on"); }
internal static void setuvalue(LuaState L, TValue obj, GCObject x) { obj.value.gc = x; obj.tt = LUA_TUSERDATA; checkliveness(G(L), obj); }
public static void luaG_concaterror(LuaState L, StkId p1, StkId p2) { if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; lua_assert(!ttisstring(p1) && !ttisnumber(p1)); luaG_typeerror(L, p1, "concatenate"); }
public static int lua_isnumber(LuaState L, int idx) { TValue n = new TValue(); TValue o = index2adr(L, idx); return tonumber(ref o, n); }
public static void lua_setfield(LuaState L, int idx, CharPtr k) { StkId t; TValue key = new TValue(); lua_lock(L); api_checknelems(L, 1); t = index2adr(L, idx); api_checkvalidindex(L, t); setsvalue(L, key, luaS_new(L, k)); luaV_settable(L, t, key, L.top - 1); StkId.dec(ref L.top); /* pop value */ lua_unlock(L); }
public static void luaA_pushobject(LuaState L, TValue o) { setobj2s(L, L.top, o); api_incr_top(L); }
public static void lua_getfield(LuaState L, int idx, CharPtr k) { StkId t; TValue key = new TValue(); lua_lock(L); t = index2adr(L, idx); api_checkvalidindex(L, t); setsvalue(L, key, luaS_new(L, k)); luaV_gettable(L, t, key, L.top); api_incr_top(L); lua_unlock(L); }
internal static bool ttistable(TValue o) { return (ttype(o) == LUA_TTABLE); }
internal static bool ttisthread(TValue o) { return (ttype(o) == LUA_TTHREAD); }
internal static bool ttisnumber(TValue o) { return (ttype(o) == LUA_TNUMBER); }
internal static bool ttisstring(TValue o) { return (ttype(o) == LUA_TSTRING); }
/* Macros to test type */ internal static bool ttisnil(TValue o) { return (ttype(o) == LUA_TNIL); }
internal static bool ttisfunction(TValue o) { return (ttype(o) == LUA_TFUNCTION); }
internal static bool ttisboolean(TValue o) { return (ttype(o) == LUA_TBOOLEAN); }
public static lua_Integer lua_tointeger(LuaState L, int idx) { TValue n = new TValue(); TValue o = index2adr(L, idx); if (tonumber(ref o, n) != 0) { lua_Integer res; lua_Number num = nvalue(o); lua_number2integer(out res, num); return res; } else return 0; }
internal static bool ttisuserdata(TValue o) { return (ttype(o) == LUA_TUSERDATA); }
public static lua_Number lua_tonumber(LuaState L, int idx) { TValue n = new TValue(); TValue o = index2adr(L, idx); if (tonumber(ref o, n) != 0) return nvalue(o); else return 0; }
public Node() { this.i_val = new TValue(); this.i_key = new TKey(); }
static CharPtr aux_upvalue(StkId fi, int n, ref TValue val) { Closure f; if (!ttisfunction(fi)) return null; f = clvalue(fi); if (f.c.isC != 0) { if (!(1 <= n && n <= f.c.nupvalues)) return null; val = f.c.upvalue[n - 1]; return ""; } else { Proto p = f.l.p; if (!(1 <= n && n <= p.sizeupvalues)) return null; val = f.l.upvals[n - 1].v; return getstr(p.upvalues[n - 1]); } }
public Node(Node copy) { this.values = copy.values; this.index = copy.index; this.i_val = new TValue(copy.i_val); this.i_key = new TKey(copy.i_key); }
public static CharPtr lua_getupvalue(LuaState L, int funcindex, int n) { CharPtr name; TValue val = new TValue(); lua_lock(L); name = aux_upvalue(index2adr(L, funcindex), n, ref val); if (name != null) { setobj2s(L, L.top, val); api_incr_top(L); } lua_unlock(L); return name; }
public Node(TValue i_val, TKey i_key) { this.values = new Node[] { this }; this.index = 0; this.i_val = i_val; this.i_key = i_key; }
public static void api_checkvalidindex(LuaState L, StkId i) { api_check(L, i != luaO_nilobject); }
public static bool iscfunction(TValue o) { return ((ttype(o) == LUA_TFUNCTION) && (clvalue(o).c.isC != 0)); }
public static void luaG_typeerror(LuaState L, TValue o, CharPtr op) { CharPtr name = null; CharPtr t = luaT_typenames[ttype(o)]; CharPtr kind = (isinstack(L.ci, o)) != 0 ? getobjname(L, L.ci, cast_int(o - L.base_), ref name) : null; if (kind != null) luaG_runerror(L, "attempt to %s %s " + LUA_QS + " (a %s value)", op, kind, name, t); else luaG_runerror(L, "attempt to %s a %s value", op, t); }
public static bool iscollectable(TValue o) { return (ttype(o) >= LUA_TSTRING); }
/* only ANSI way to check whether a pointer points to an array */ private static int isinstack(CallInfo ci, TValue o) { StkId p; for (p = ci.base_; p < ci.top; StkId.inc(ref p)) if (o == p) return 1; return 0; }
public static CharPtr lua_setupvalue(LuaState L, int funcindex, int n) { CharPtr name; TValue val = new TValue(); StkId fi; lua_lock(L); fi = index2adr(L, funcindex); api_checknelems(L, 1); name = aux_upvalue(fi, n, ref val); if (name != null) { StkId.dec(ref L.top); setobj(L, val, L.top); luaC_barrier(L, clvalue(fi), L.top); } lua_unlock(L); return name; }
public static int luaG_ordererror(LuaState L, TValue p1, TValue p2) { CharPtr t1 = luaT_typenames[ttype(p1)]; CharPtr t2 = luaT_typenames[ttype(p2)]; if (t1[2] == t2[2]) luaG_runerror(L, "attempt to compare two %s values", t1); else luaG_runerror(L, "attempt to compare %s with %s", t1, t2); return 0; }
internal static void setthvalue(LuaState L, TValue obj, GCObject x) { obj.value.gc = x; obj.tt = LUA_TTHREAD; checkliveness(G(L), obj); }