bool Query::internalCheck() { int i; Search::Operator op; Search *s = NULL; ElementTypeList::iterator elementIter; if (count() != (countOperands() + countOperators())) { return false; } for (elementIter = m_elementType.begin(), i = 0; elementIter != m_elementType.end(); ++elementIter, ++i) { switch (*elementIter) { case SearchElement : s = search(i); if (s == NULL) { return false; } switch (s->type()) { case Search::NullSearch : case Search::PositionSearch : case Search::EloSearch : break; default : // undefined search return false; } break; case OperatorElement : op = searchOperator(i); switch (op) { case Search::And : case Search::Or : case Search::Remove : case Search::Not : case Search::NullOperator : break; default : // Undefined operator return false; } break; default : // Undefined element return false; } } return true; }
int64_t getStackPopped(PC pc) { auto const op = peek_op(pc); switch (op) { case Op::FCall: return getImm(pc, 0).u_IVA + kNumActRecCells; case Op::FCallD: return getImm(pc, 0).u_IVA + kNumActRecCells; case Op::FCallAwait: return getImm(pc, 0).u_IVA + kNumActRecCells; case Op::FCallArray: return kNumActRecCells + 1; case Op::QueryM: case Op::VGetM: case Op::IncDecM: case Op::UnsetM: case Op::NewPackedArray: case Op::NewVecArray: case Op::NewKeysetArray: case Op::ConcatN: case Op::FCallBuiltin: case Op::CreateCl: return getImm(pc, 0).u_IVA; case Op::FPassM: // imm[0] is argument index return getImm(pc, 1).u_IVA; case Op::SetM: case Op::SetOpM: case Op::BindM: return getImm(pc, 0).u_IVA + 1; case Op::NewStructArray: return getImmVector(pc).size(); case Op::BaseSC: case Op::BaseSL: return getImm(pc, 1).u_IVA + 1; default: break; } uint64_t mask = getInstrInfo(op).in; int64_t count = 0; // All instructions with these properties are handled above assertx((mask & (StackN | BStackN)) == 0); return count + countOperands(mask); }
int64_t getStackPushed(PC pc) { auto const op = peek_op(pc); if (op == Op::BaseSC || op == Op::BaseSL) return getImm(pc, 1).u_IVA; return countOperands(getInstrInfo(op).out); }