Exemple #1
0
  /** {@inheritDoc} */
  @Override
  public DalvInsn withRegisters(RegisterSpecList registers) {
    CstInsn result = new CstInsn(getOpcode(), getPosition(), registers, constant);

    if (index >= 0) {
      result.setIndex(index);
    }

    if (classIndex >= 0) {
      result.setClassIndex(classIndex);
    }

    return result;
  }
Exemple #2
0
  /** {@inheritDoc} */
  @Override
  public DalvInsn withOpcode(Dop opcode) {
    CstInsn result = new CstInsn(opcode, getPosition(), getRegisters(), constant);

    if (index >= 0) {
      result.setIndex(index);
    }

    if (classIndex >= 0) {
      result.setClassIndex(classIndex);
    }

    return result;
  }
Exemple #3
0
  /** {@inheritDoc} */
  @Override
  public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
      return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec reg;

    switch (regs.size()) {
      case 1:
        {
          reg = regs.get(0);
          break;
        }
      case 2:
        {
          /*
           * This format is allowed for ops that are effectively
           * 2-arg but where the two args are identical.
           */
          reg = regs.get(0);
          if (reg.getReg() != regs.get(1).getReg()) {
            return false;
          }
          break;
        }
      default:
        {
          return false;
        }
    }

    if (!unsignedFitsInByte(reg.getReg())) {
      return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

    if (!unsignedFitsInShort(cpi)) {
      return false;
    }

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
  }