本文整理汇总了C++中equalobj函数的典型用法代码示例。如果您正苦于以下问题:C++ equalobj函数的具体用法?C++ equalobj怎么用?C++ equalobj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了equalobj函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_equal
LUA_API int lua_equal (lua_State *L, int index1, int index2) {
StkId o1, o2;
int i;
lua_lock(L); /* may call tag method */
o1 = luaA_indexAcceptable(L, index1);
o2 = luaA_indexAcceptable(L, index2);
i = (o1 == NULL || o2 == NULL) ? 0 /* index out of range */
: equalobj(L, o1, o2);
lua_unlock(L);
return i;
}
示例2: lua_compare
LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
StkId o1, o2;
int i = 0;
lua_lock(L); /* may call tag method */
o1 = index2addr(L, index1);
o2 = index2addr(L, index2);
if (isvalid(o1) && isvalid(o2)) {
switch (op) {
case LUA_OPEQ: i = equalobj(L, o1, o2); break;
case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
default: api_check(L, 0, "invalid option");
}
}
lua_unlock(L);
return i;
}
示例3: luaV_execute
//.........这里部分代码省略.........
Protect(luaV_gettable(L, rb, RKC(i), ra));
continue;
}
case OP_ADD: {
arith_op(luai_numadd, TM_ADD);
continue;
}
case OP_SUB: {
arith_op(luai_numsub, TM_SUB);
continue;
}
case OP_MUL: {
arith_op(luai_nummul, TM_MUL);
continue;
}
case OP_DIV: {
arith_op(luai_numdiv, TM_DIV);
continue;
}
case OP_MOD: {
arith_op(luai_nummod, TM_MOD);
continue;
}
case OP_POW: {
arith_op(luai_numpow, TM_POW);
continue;
}
case OP_UNM: {
TValue *rb = RB(i);
if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb);
setnvalue(ra, luai_numunm(nb));
}
else {
Protect(luaV_arith(L, ra, rb, rb, TM_UNM));
}
continue;
}
case OP_NOT: {
int res = l_isfalse(RB(i)); /* next assignment may change this value */
setbvalue(ra, res);
continue;
}
case OP_LEN: {
const TValue *rb = RB(i);
switch (ttype(rb)) {
case LUA_TTABLE: {
setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
break;
}
case LUA_TSTRING: {
setnvalue(ra, cast_num(tsvalue(rb)->len));
break;
}
default: { /* try metamethod */
Protect(
if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
luaG_typeerror(L, rb, "get length of");
)
}
}
continue;
}
case OP_CONCAT: {
int b = GETARG_B(i);
int c = GETARG_C(i);
Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
setobjs2s(L, RA(i), base+b);
continue;
}
case OP_JMP: {
dojump(L, pc, GETARG_sBx(i));
continue;
}
case OP_EQ: {
TValue *rb = RKB(i);
TValue *rc = RKC(i);
Protect(
if (equalobj(L, rb, rc) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
case OP_LT: {
Protect(
if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
case OP_LE: {
Protect(
if (luaV_lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
示例4: equalobj
int LuaState::Equal(const LuaObject& o1, const LuaObject& o2)
{
int i = equalobj(o1.GetCState(), o1.GetTObject(), o2.GetTObject());
return i;
}
示例5: luaV_execute
//.........这里部分代码省略.........
}
case OP_UNM: {
const TObject *rb = RB(i);
TObject temp;
if (tonumber(rb, &temp)) {
setnvalue(ra, -nvalue(rb));
}
else {
setnilvalue(&temp);
if (!call_binTM(L, RB(i), &temp, ra, TM_UNM))
luaG_aritherror(L, RB(i), &temp);
}
break;
}
case OP_NOT: {
int res = l_isfalse(RB(i)); /* next assignment may change this value */
setbvalue(ra, res);
break;
}
case OP_CONCAT: {
int b = GETARG_B(i);
int c = GETARG_C(i);
luaV_concat(L, c-b+1, c); /* may change `base' (and `ra') */
base = L->base;
setobjs2s(RA(i), base+b);
luaC_checkGC(L);
break;
}
case OP_JMP: {
dojump(pc, GETARG_sBx(i));
break;
}
case OP_EQ: {
if (equalobj(L, RKB(i), RKC(i)) != GETARG_A(i)) pc++;
else dojump(pc, GETARG_sBx(*pc) + 1);
break;
}
case OP_LT: {
if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) pc++;
else dojump(pc, GETARG_sBx(*pc) + 1);
break;
}
case OP_LE: {
if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) pc++;
else dojump(pc, GETARG_sBx(*pc) + 1);
break;
}
case OP_TEST: {
TObject *rb = RB(i);
if (l_isfalse(rb) == GETARG_C(i)) pc++;
else {
setobjs2s(ra, rb);
dojump(pc, GETARG_sBx(*pc) + 1);
}
break;
}
case OP_CALL:
case OP_TAILCALL: {
StkId firstResult;
int b = GETARG_B(i);
int nresults;
if (b != 0) L->top = ra+b; /* else previous instruction set top */
nresults = GETARG_C(i) - 1;
firstResult = luaD_precall(L, ra);
if (firstResult) {
if (firstResult > L->top) { /* yield? */
示例6: Arith
//.........这里部分代码省略.........
TValue *rb = RB(i);
if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb);
setnvalue(ra, luai_numunm(nb));
}
else {
Protect(Arith(L, ra, rb, rb, TM_UNM));
}
continue;
}
case OP_NOT: {
int res = l_isfalse(RB(i)); /* next assignment may change this value */
setbvalue(ra, res);
continue;
}
#if LUA_BITFIELD_OPS
case OP_BAND: {
bit_op(&);
continue;
}
case OP_BOR: {
bit_op(|);
continue;
}
case OP_BXOR: {
bit_op(^);
continue;
}
case OP_BSHL: {
bit_op(<<);
continue;
}
case OP_BSHR: {
bit_op(>>);
continue;
}
#endif /* LUA_BITFIELD_OPS */
case OP_LEN: {
const TValue *rb = RB(i);
switch (ttype(rb)) {
case LUA_TTABLE: {
setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
break;
}
case LUA_TSTRING: {
setnvalue(ra, cast_num(tsvalue(rb)->len));
break;
}
#if LUA_WIDESTRING
case LUA_TWSTRING: {
setnvalue(ra, cast_num(tsvalue(rb)->len));
break;
}
#endif /* LUA_WIDESTRING */
default: { /* try metamethod */
Protect(
if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
luaG_typeerror(L, rb, "get length of");
)
}
}
continue;
}
case OP_CONCAT: {
int b = GETARG_B(i);
int c = GETARG_C(i);
Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
setobjs2s(L, RA(i), base+b);
continue;
}
case OP_JMP: {
dojump(L, pc, GETARG_sBx(i));
continue;
}
case OP_EQ: {
TValue *rb = RKB(i);
TValue *rc = RKC(i);
Protect(
if (equalobj(L, rb, rc) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
case OP_LT: {
Protect(
if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
case OP_LE: {
Protect(
if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
示例7: luaV_execute
//.........这里部分代码省略.........
const TValue *rb = RB(i);
switch (ttype(rb)) {
case LUA_TTABLE: {
setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
break;
}
case LUA_TSTRING: {
setnvalue(ra, cast_num(tsvalue(rb)->len));
break;
}
default: { /* try metamethod */
Protect(
if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
luaG_typeerror(L, rb, "get length of");
)
}
}
continue;
}
// 功能:实现字符串拼接运算符 ..
// iABC:A拼接后存放结果的参数栈索引,B第一个要拼接的变量的参数栈索引,C最后一个要拼接的变量的参数栈索引
// 要执行这个指令,对参数栈有特殊要求:
// ... -> string1 -> string2 ... -> stringN -> ...
// ^ ^
// RB RC
case OP_CONCAT: {
// 类似OP_LOADNIL,只不过,这次范围是[rb,rc],loadnil是[ra,rb]
// local b, c, d, a = "hello", "world", "!"
// a = b .. c .. d -----> index(a) = 4, index(b~d) = 1~3
// >----> OP_CONCAT 4 1 3
// 问题是如果b~d不能保证是连续的怎么办?答案是一个个MOVE上去在OP_CONCAT...
int b = GETARG_B(i);
int c = GETARG_C(i);
Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
setobjs2s(L, RA(i), base+b);
continue;
}
//---------------------------------------------------------------------------跳转指令
// 功能:无条件跳转
// iAsBx:A不使用,sBx跳转偏移
// 一般这个语句不单独出现,都是在一些条件控制中和其他的条件跳转指令配合使用的。
case OP_JMP: {
// 无条件跳转指令。由于跳转偏移总是有正向和反向之分的,所以需要用到
// 负数。那就只能用iAsBx类型的指令了。而sBx是有长度限制的!
// 所以,如果生成的指令很多,超过了sBx的长度限制,可能就会编译失败
dojump(L, pc, GETARG_sBx(i));
continue;
}
// 功能:检查两个变量是否相等,满足预期则跳转。配合OP_JMP使用。
// iABC:A纯数字,对比较结果的预期,满足预期则跳转,B参数1的索引,C参数2的索引
case OP_EQ: {
// if a == b then -----> index(a) = 1, index(b) = 2
// >----> 这里将生成两行指令:
// >----> OP_EQ 0 1 2 // 用0,因为成立的话跳过,不成立才执行
// >----> OP_JMP N // N 表示then ... end中间的指令数量
// >----> ... // Instructions between "then" and "end"
TValue *rb = RKB(i);
TValue *rc = RKC(i);
Protect(
if (equalobj(L, rb, rc) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
// 功能:检查两个变量是否小于,满足预期则跳转。配合OP_JMP使用。
// iABC:A纯数字,对比较结果的预期,满足预期则跳转,B参数1的索引,C参数2的索引
case OP_LT: {
// if a < b then -----> index(a) = 1, index(b) = 2
// >----> 这里将生成两行指令:
// >----> OP_LT 0 1 2 // 用0,因为成立的话跳过,不成立才执行
// >----> OP_JMP N // N 表示then ... end中间的指令数量
// >----> ... // Instructions between "then" and "end"
Protect(
if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
// 功能:检查两个变量是否小于等于,满足预期则跳转。配合OP_JMP使用。
// iABC:A纯数字,对比较结果的预期,满足预期则跳转,B参数1的索引,C参数2的索引
case OP_LE: {
// if a <= b then -----> index(a) = 1, index(b) = 2
// >----> 这里将生成两行指令:
// >----> OP_LE 0 1 2 // 用0,因为成立的话跳过,不成立才执行
// >----> OP_JMP N // N 表示then ... end中间的指令数量
// >----> ... // Instructions between "then" and "end"
Protect(
if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
dojump(L, pc, GETARG_sBx(*pc));
)
pc++;
continue;
}
示例8: ktap_execute
//.........这里部分代码省略.........
kp_error(ks, "ktap don't support pow arith in kernel\n");
return;
case OP_UNM: {
ktap_value *rb = RB(instr);
if (ttisnumber(rb)) {
ktap_number nb = nvalue(rb);
setnvalue(ra, NUMUNM(nb));
}
break;
}
case OP_NOT:
res = isfalse(RB(instr));
setbvalue(ra, res);
break;
case OP_LEN: {
int len = kp_objlen(ks, RB(instr));
if (len < 0)
return;
setnvalue(ra, len);
break;
}
case OP_CONCAT: {
int b = GETARG_B(instr);
int c = GETARG_C(instr);
ktap_concat(ks, b, c);
break;
}
case OP_JMP:
dojump(ci, instr, 0);
break;
case OP_EQ: {
ktap_value *rb = RKB(instr);
ktap_value *rc = RKC(instr);
if ((int)equalobj(ks, rb, rc) != GETARG_A(instr))
ci->u.l.savedpc++;
else
donextjump(ci);
base = ci->u.l.base;
break;
}
case OP_LT:
if (lessthan(ks, RKB(instr), RKC(instr)) != GETARG_A(instr))
ci->u.l.savedpc++;
else
donextjump(ci);
base = ci->u.l.base;
break;
case OP_LE:
if (lessequal(ks, RKB(instr), RKC(instr)) != GETARG_A(instr))
ci->u.l.savedpc++;
else
donextjump(ci);
base = ci->u.l.base;
break;
case OP_TEST:
if (GETARG_C(instr) ? isfalse(ra) : !isfalse(ra))
ci->u.l.savedpc++;
else
donextjump(ci);
break;
case OP_TESTSET: {
ktap_value *rb = RB(instr);
if (GETARG_C(instr) ? isfalse(rb) : !isfalse(rb))
ci->u.l.savedpc++;
else {