- Destinations.push_back(dest_value(ConstPoolUse(OnVal, this),
- BasicBlockUse(Dest, this)));
-}
-
-void SwitchInst::dropAllReferences() {
- Val = 0;
- DefaultDest = 0;
- Destinations.clear();
-}
-
-const BasicBlock *SwitchInst::getSuccessor(unsigned idx) const {
- if (idx == 0) return DefaultDest;
- if (idx > Destinations.size()) return 0;
- return Destinations[idx-1].second;
-}
-
-unsigned SwitchInst::getNumOperands() const {
- return 2+Destinations.size();
-}
-
-const Value *SwitchInst::getOperand(unsigned i) const {
- if (i == 0) return Val;
- else if (i == 1) return DefaultDest;
-
- unsigned slot = (i-2) >> 1;
- if (slot >= Destinations.size()) return 0;
-
- if (i & 1) return Destinations[slot].second;
- return Destinations[slot].first;
-}
-
-bool SwitchInst::setOperand(unsigned i, Value *V) {
- if (i == 0) { Val = V; return true; }
- else if (i == 1) {
- assert(V->getType() == Type::LabelTy);
- DefaultDest = (BasicBlock*)V;
- return true;
- }
-
- unsigned slot = (i-2) >> 1;
- if (slot >= Destinations.size()) return 0;
-
- if (i & 1) {
- assert(V->getType() == Type::LabelTy);
- Destinations[slot].second = (BasicBlock*)V;
- } else {
- // TODO: assert constant
- Destinations[slot].first = (ConstPoolVal*)V;
- }
- return true;