示例#1
0
 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");
 }
示例#2
0
 internal static void setuvalue(LuaState L, TValue obj, GCObject x)
 {
     obj.value.gc = x;
     obj.tt = LUA_TUSERDATA;
     checkliveness(G(L), obj);
 }
示例#3
0
 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");
 }
示例#4
0
文件: lapi.cs 项目: zeta945/SharpLua
 public static int lua_isnumber(LuaState L, int idx)
 {
     TValue n = new TValue();
     TValue o = index2adr(L, idx);
     return tonumber(ref o, n);
 }
示例#5
0
文件: lapi.cs 项目: zeta945/SharpLua
 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);
 }
示例#6
0
文件: lapi.cs 项目: zeta945/SharpLua
 public static void luaA_pushobject(LuaState L, TValue o)
 {
     setobj2s(L, L.top, o);
     api_incr_top(L);
 }
示例#7
0
文件: lapi.cs 项目: zeta945/SharpLua
 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);
 }
示例#8
0
 internal static bool ttistable(TValue o)
 {
     return (ttype(o) == LUA_TTABLE);
 }
示例#9
0
 internal static bool ttisthread(TValue o)
 {
     return (ttype(o) == LUA_TTHREAD);
 }
示例#10
0
 internal static bool ttisnumber(TValue o)
 {
     return (ttype(o) == LUA_TNUMBER);
 }
示例#11
0
 internal static bool ttisstring(TValue o)
 {
     return (ttype(o) == LUA_TSTRING);
 }
示例#12
0
 /* Macros to test type */
 internal static bool ttisnil(TValue o)
 {
     return (ttype(o) == LUA_TNIL);
 }
示例#13
0
 internal static bool ttisfunction(TValue o)
 {
     return (ttype(o) == LUA_TFUNCTION);
 }
示例#14
0
 internal static bool ttisboolean(TValue o)
 {
     return (ttype(o) == LUA_TBOOLEAN);
 }
示例#15
0
文件: lapi.cs 项目: zeta945/SharpLua
 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;
 }
示例#16
0
 internal static bool ttisuserdata(TValue o)
 {
     return (ttype(o) == LUA_TUSERDATA);
 }
示例#17
0
文件: lapi.cs 项目: zeta945/SharpLua
 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;
 }
示例#18
0
 public Node()
 {
     this.i_val = new TValue();
     this.i_key = new TKey();
 }
示例#19
0
文件: lapi.cs 项目: zeta945/SharpLua
 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]);
     }
 }
示例#20
0
 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);
 }
示例#21
0
文件: lapi.cs 项目: zeta945/SharpLua
 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;
 }
示例#22
0
 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;
 }
示例#23
0
文件: lapi.cs 项目: zeta945/SharpLua
 public static void api_checkvalidindex(LuaState L, StkId i)
 {
     api_check(L, i != luaO_nilobject);
 }
示例#24
0
 public static bool iscfunction(TValue o)
 {
     return ((ttype(o) == LUA_TFUNCTION) && (clvalue(o).c.isC != 0));
 }
示例#25
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);
 }
示例#26
0
 public static bool iscollectable(TValue o)
 {
     return (ttype(o) >= LUA_TSTRING);
 }
示例#27
0
 /* 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;
 }
示例#28
0
文件: lapi.cs 项目: zeta945/SharpLua
 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;
 }
示例#29
0
 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;
 }
示例#30
0
 internal static void setthvalue(LuaState L, TValue obj, GCObject x)
 {
     obj.value.gc = x;
     obj.tt = LUA_TTHREAD;
     checkliveness(G(L), obj);
 }