本文整理汇总了C#中KopiLua.Lua.LuaTypeValue类的典型用法代码示例。如果您正苦于以下问题:C# Lua.LuaTypeValue类的具体用法?C# Lua.LuaTypeValue怎么用?C# Lua.LuaTypeValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lua.LuaTypeValue类属于KopiLua命名空间,在下文中一共展示了Lua.LuaTypeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LuaGArithError
public static void LuaGArithError(LuaState L, TValue p1, TValue p2)
{
TValue temp = new LuaTypeValue();
if (luaV_tonumber(p1, temp) == null)
p2 = p1; /* first operand is wrong */
LuaGTypeError(L, p2, "perform arithmetic on");
}
示例2: Arith
public static void Arith(LuaState L, StkId ra, TValue rb,
TValue rc, TMS op)
{
TValue tempb = new LuaTypeValue(), tempc = new LuaTypeValue();
TValue b, c;
if ((b = luaV_tonumber(rb, tempb)) != null &&
(c = luaV_tonumber(rc, tempc)) != null) {
lua_Number nb = NValue(b), nc = NValue(c);
switch (op) {
case TMS.TM_ADD: SetNValue(ra, luai_numadd(nb, nc)); break;
case TMS.TM_SUB: SetNValue(ra, luai_numsub(nb, nc)); break;
case TMS.TM_MUL: SetNValue(ra, luai_nummul(nb, nc)); break;
case TMS.TM_DIV: SetNValue(ra, luai_numdiv(nb, nc)); break;
case TMS.TM_MOD: SetNValue(ra, luai_nummod(nb, nc)); break;
case TMS.TM_POW: SetNValue(ra, luai_numpow(nb, nc)); break;
case TMS.TM_UNM: SetNValue(ra, luai_numunm(nb)); break;
default: LuaAssert(false); break;
}
}
else if (call_binTM(L, rb, rc, ra, op) == 0)
LuaGArithError(L, rb, rc);
}
示例3: LuaFindUpVal
public static UpVal LuaFindUpVal(LuaState L, StkId level)
{
GlobalState g = G(L);
GCObjectRef pp = new OpenValRef(L);
UpVal p;
UpVal uv;
while (pp.get() != null && (p = ngcotouv(pp.get())).v >= level)
{
LuaAssert(p.v != p.u.value);
if (p.v == level)
{ /* found a corresponding upvalue? */
if (IsDead(g, obj2gco(p))) /* is it dead? */
ChangeWhite(obj2gco(p)); /* ressurect it */
return p;
}
pp = new NextRef(p);
}
uv = LuaMNew<UpVal>(L); /* not found: create a new one */
uv.tt = LUATUPVAL;
uv.marked = LuaCWhite(g);
uv.v = level; /* current value lives in the stack */
uv.next = pp.get(); /* chain it in the proper position */
pp.set(obj2gco(uv));
uv.u.l.prev = g.uvhead; /* double link it in `uvhead' list */
uv.u.l.next = g.uvhead.u.l.next;
uv.u.l.next.u.l.prev = uv;
g.uvhead.u.l.next = uv;
LuaAssert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
return uv;
}
示例4: LuaFClose
public static void LuaFClose(LuaState L, StkId level)
{
UpVal uv;
GlobalState g = G(L);
while (L.openupval != null && (uv = ngcotouv(L.openupval)).v >= level) {
GCObject o = obj2gco(uv);
LuaAssert(!IsBlack(o) && uv.v != uv.u.value);
L.openupval = uv.next; /* remove from `open' list */
if (IsDead(g, o))
LuaFreeUpVal(L, uv); /* free upvalue */
else {
UnlinkUpVal(uv);
SetObj(L, uv.u.value, uv.v);
uv.v = uv.u.value; /* now current value lives here */
LuaCLinkUpVal(L, uv); /* link upvalue into `gcroot' list */
}
}
}
示例5: arith_op
public static void arith_op(LuaState L, op_delegate op, TMS tm, StkId base_, Instruction i, TValue[] k, StkId ra, InstructionPtr pc)
{
TValue rb = RKB(L, base_, i, k);
TValue rc = RKC(L, base_, i, k);
if (TTIsNumber(rb) && TTIsNumber(rc))
{
lua_Number nb = NValue(rb), nc = NValue(rc);
SetNValue(ra, op(nb, nc));
}
else
{
//Protect(
L.savedpc = InstructionPtr.Assign(pc);
Arith(L, ra, rb, rc, tm);
base_ = L.base_;
//);
}
}
示例6: luaT_gettmbyobj
public static TValue luaT_gettmbyobj(LuaState L, TValue o, TMS event_)
{
Table mt;
switch (TType(o))
{
case LUA_TTABLE:
mt = HValue(o).metatable;
break;
case LUA_TUSERDATA:
mt = UValue(o).metatable;
break;
default:
mt = G(L).mt[TType(o)];
break;
}
return ((mt != null) ? luaH_getstr(mt, G(L).tmname[(int)event_]) : LuaONilObject);
}
示例7: luaH_get
/*
** main search function
*/
public static TValue luaH_get(Table t, TValue key)
{
switch (TType(key))
{
case LUA_TNIL: return LuaONilObject;
case LUA_TSTRING: return luaH_getstr(t, RawTSValue(key));
case LUA_TNUMBER:
{
int k;
lua_Number n = NValue(key);
lua_number2int(out k, n);
if (luai_numeq(CastNum(k), NValue(key))) /* index is int? */
return luaH_getnum(t, k); /* use specialized version */
/* else go through ... actually on second thoughts don't, because this is C#*/
Node node = mainposition(t, key);
do
{ /* check whether `key' is somewhere in the chain */
if (LuaORawEqualObj(key2tval(node), key) != 0)
return gval(node); /* that's it */
else node = gnext(node);
} while (node != null);
return LuaONilObject;
}
default:
{
Node node = mainposition(t, key);
do
{ /* check whether `key' is somewhere in the chain */
if (LuaORawEqualObj(key2tval(node), key) != 0)
return gval(node); /* that's it */
else node = gnext(node);
} while (node != null);
return LuaONilObject;
}
}
}
示例8: Node
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;
}
示例9: TTIsThread
internal static bool TTIsThread(TValue o)
{
return (TType(o) == LUA_TTHREAD);
}
示例10: TTIsString
internal static bool TTIsString(TValue o)
{
return (TType(o) == LUA_TSTRING);
}
示例11: TTIsNil
/* Macros to test type */
internal static bool TTIsNil(TValue o)
{
return (TType(o) == LUA_TNIL);
}
示例12: TTIsBoolean
internal static bool TTIsBoolean(TValue o)
{
return (TType(o) == LUA_TBOOLEAN);
}
示例13: SetNValue
internal static void SetNValue(TValue obj, LuaNumberType x)
{
obj.value.n = x;
obj.tt = LUA_TNUMBER;
}
示例14: SetNilValue
/* Macros to set values */
internal static void SetNilValue(TValue obj)
{
obj.tt=LUA_TNIL;
}
示例15: SetTType
internal static void SetTType(TValue obj, int tt)
{
obj.tt = tt;
}