/// <summary> /// 对指定索引处的两个值进行比较,返回结果 /// </summary> public bool Compare(int idx1, int idx2, ECompOp op) { if (!_stack.IsValid(idx1) || !_stack.IsValid(idx2)) { return(false); } var a = _stack[idx1]; var b = _stack[idx2]; switch (op) { case ECompOp.Eq: return(Eq(a, b, this)); case ECompOp.Lt: return(Lt(a, b, this)); case ECompOp.Le: return(Le(a, b, this)); default: Debug.Panic("invalid compare op!"); return(false); } }
/// <summary> /// if ((RK(B) op RK(C)) != A) /// pc++ /// </summary> private static void Compare(Instruction ins, ILuaVM vm, ECompOp op) { ins.ABC(out var a, out var b, out var c); vm.GetRK(b); vm.GetRK(c); if (vm.Compare(-2, -1, op) != (a != 0)) { vm.AddPC(1); } vm.Pop(2); }