Exemple #1
0
MethodBlock* MethodBlock::switch_op(Location test,
                                    std::map<int, MethodBlock*>& cases) {
  auto sw_opcode = new IRInstruction(OPCODE_PACKED_SWITCH);
  sw_opcode->set_src(0, test.get_reg());
  // Convert to SwitchIndices map.
  std::map<SwitchIndices, MethodBlock*> indices_cases;
  for (auto it : cases) {
    SwitchIndices indices = {it.first};
    indices_cases[indices] = it.second;
  }
  auto mb = make_switch_block(sw_opcode, indices_cases);
  // Copy initialized case blocks back.
  for (auto it : indices_cases) {
    SwitchIndices indices = it.first;
    always_assert(indices.size());
    int idx = *indices.begin();
    cases[idx] = it.second;
  }
  return mb;
}
Exemple #2
0
MethodBlock* MethodBlock::switch_op(Location test,
                                    std::map<int, MethodBlock*>& cases) {
  auto sw_opcode = new DexInstruction(OPCODE_PACKED_SWITCH);
  sw_opcode->set_src(0, reg_num(test));
  return make_switch_block(sw_opcode, cases);
}
Exemple #3
0
MethodBlock* MethodBlock::switch_op(
    Location test, std::map<SwitchIndices, MethodBlock*>& cases) {
  auto sw_opcode = new IRInstruction(OPCODE_PACKED_SWITCH);
  sw_opcode->set_src(0, test.get_reg());
  return make_switch_block(sw_opcode, cases);
}