Java Code Examples for com.android.dx.rop.type.TypeBearer#getBasicType()

The following examples show how to use com.android.dx.rop.type.TypeBearer#getBasicType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code get-static} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opGetStatic(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return GET_STATIC_INT;
        case Type.BT_LONG:    return GET_STATIC_LONG;
        case Type.BT_FLOAT:   return GET_STATIC_FLOAT;
        case Type.BT_DOUBLE:  return GET_STATIC_DOUBLE;
        case Type.BT_OBJECT:  return GET_STATIC_OBJECT;
        case Type.BT_BOOLEAN: return GET_STATIC_BOOLEAN;
        case Type.BT_BYTE:    return GET_STATIC_BYTE;
        case Type.BT_CHAR:    return GET_STATIC_CHAR;
        case Type.BT_SHORT:   return GET_STATIC_SHORT;
    }

    return throwBadType(type);
}
 
Example 2
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aput} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAput(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return APUT_INT;
        case Type.BT_LONG:    return APUT_LONG;
        case Type.BT_FLOAT:   return APUT_FLOAT;
        case Type.BT_DOUBLE:  return APUT_DOUBLE;
        case Type.BT_OBJECT:  return APUT_OBJECT;
        case Type.BT_BOOLEAN: return APUT_BOOLEAN;
        case Type.BT_BYTE:    return APUT_BYTE;
        case Type.BT_CHAR:    return APUT_CHAR;
        case Type.BT_SHORT:   return APUT_SHORT;
    }

    return throwBadType(type);
}
 
Example 3
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code get-field} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opGetField(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return GET_FIELD_INT;
        case Type.BT_LONG:    return GET_FIELD_LONG;
        case Type.BT_FLOAT:   return GET_FIELD_FLOAT;
        case Type.BT_DOUBLE:  return GET_FIELD_DOUBLE;
        case Type.BT_OBJECT:  return GET_FIELD_OBJECT;
        case Type.BT_BOOLEAN: return GET_FIELD_BOOLEAN;
        case Type.BT_BYTE:    return GET_FIELD_BYTE;
        case Type.BT_CHAR:    return GET_FIELD_CHAR;
        case Type.BT_SHORT:   return GET_FIELD_SHORT;
    }

    return throwBadType(type);
}
 
Example 4
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aput} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAput(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return APUT_INT;
        case Type.BT_LONG:    return APUT_LONG;
        case Type.BT_FLOAT:   return APUT_FLOAT;
        case Type.BT_DOUBLE:  return APUT_DOUBLE;
        case Type.BT_OBJECT:  return APUT_OBJECT;
        case Type.BT_BOOLEAN: return APUT_BOOLEAN;
        case Type.BT_BYTE:    return APUT_BYTE;
        case Type.BT_CHAR:    return APUT_CHAR;
        case Type.BT_SHORT:   return APUT_SHORT;
    }

    return throwBadType(type);
}
 
Example 5
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code get-static} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opGetStatic(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return GET_STATIC_INT;
        case Type.BT_LONG:    return GET_STATIC_LONG;
        case Type.BT_FLOAT:   return GET_STATIC_FLOAT;
        case Type.BT_DOUBLE:  return GET_STATIC_DOUBLE;
        case Type.BT_OBJECT:  return GET_STATIC_OBJECT;
        case Type.BT_BOOLEAN: return GET_STATIC_BOOLEAN;
        case Type.BT_BYTE:    return GET_STATIC_BYTE;
        case Type.BT_CHAR:    return GET_STATIC_CHAR;
        case Type.BT_SHORT:   return GET_STATIC_SHORT;
    }

    return throwBadType(type);
}
 
Example 6
Source File: Rops.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aget} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAget(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return AGET_INT;
        case Type.BT_LONG:    return AGET_LONG;
        case Type.BT_FLOAT:   return AGET_FLOAT;
        case Type.BT_DOUBLE:  return AGET_DOUBLE;
        case Type.BT_OBJECT:  return AGET_OBJECT;
        case Type.BT_BOOLEAN: return AGET_BOOLEAN;
        case Type.BT_BYTE:    return AGET_BYTE;
        case Type.BT_CHAR:    return AGET_CHAR;
        case Type.BT_SHORT:   return AGET_SHORT;
    }

    return throwBadType(type);
}
 
Example 7
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code put-static} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opPutStatic(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return PUT_STATIC_INT;
        case Type.BT_LONG:    return PUT_STATIC_LONG;
        case Type.BT_FLOAT:   return PUT_STATIC_FLOAT;
        case Type.BT_DOUBLE:  return PUT_STATIC_DOUBLE;
        case Type.BT_OBJECT:  return PUT_STATIC_OBJECT;
        case Type.BT_BOOLEAN: return PUT_STATIC_BOOLEAN;
        case Type.BT_BYTE:    return PUT_STATIC_BYTE;
        case Type.BT_CHAR:    return PUT_STATIC_CHAR;
        case Type.BT_SHORT:   return PUT_STATIC_SHORT;
    }

    return throwBadType(type);
}
 
Example 8
Source File: Rops.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code put-static} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opPutStatic(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return PUT_STATIC_INT;
        case Type.BT_LONG:    return PUT_STATIC_LONG;
        case Type.BT_FLOAT:   return PUT_STATIC_FLOAT;
        case Type.BT_DOUBLE:  return PUT_STATIC_DOUBLE;
        case Type.BT_OBJECT:  return PUT_STATIC_OBJECT;
        case Type.BT_BOOLEAN: return PUT_STATIC_BOOLEAN;
        case Type.BT_BYTE:    return PUT_STATIC_BYTE;
        case Type.BT_CHAR:    return PUT_STATIC_CHAR;
        case Type.BT_SHORT:   return PUT_STATIC_SHORT;
    }

    return throwBadType(type);
}
 
Example 9
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aget} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAget(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return AGET_INT;
        case Type.BT_LONG:    return AGET_LONG;
        case Type.BT_FLOAT:   return AGET_FLOAT;
        case Type.BT_DOUBLE:  return AGET_DOUBLE;
        case Type.BT_OBJECT:  return AGET_OBJECT;
        case Type.BT_BOOLEAN: return AGET_BOOLEAN;
        case Type.BT_BYTE:    return AGET_BYTE;
        case Type.BT_CHAR:    return AGET_CHAR;
        case Type.BT_SHORT:   return AGET_SHORT;
    }

    return throwBadType(type);
}
 
Example 10
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aget} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAget(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return AGET_INT;
        case Type.BT_LONG:    return AGET_LONG;
        case Type.BT_FLOAT:   return AGET_FLOAT;
        case Type.BT_DOUBLE:  return AGET_DOUBLE;
        case Type.BT_OBJECT:  return AGET_OBJECT;
        case Type.BT_BOOLEAN: return AGET_BOOLEAN;
        case Type.BT_BYTE:    return AGET_BYTE;
        case Type.BT_CHAR:    return AGET_CHAR;
        case Type.BT_SHORT:   return AGET_SHORT;
    }

    return throwBadType(type);
}
 
Example 11
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code aput} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} element type of array being accessed
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opAput(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return APUT_INT;
        case Type.BT_LONG:    return APUT_LONG;
        case Type.BT_FLOAT:   return APUT_FLOAT;
        case Type.BT_DOUBLE:  return APUT_DOUBLE;
        case Type.BT_OBJECT:  return APUT_OBJECT;
        case Type.BT_BOOLEAN: return APUT_BOOLEAN;
        case Type.BT_BYTE:    return APUT_BYTE;
        case Type.BT_CHAR:    return APUT_CHAR;
        case Type.BT_SHORT:   return APUT_SHORT;
    }

    return throwBadType(type);
}
 
Example 12
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code put-field} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the field in question
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opPutField(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_INT:     return PUT_FIELD_INT;
        case Type.BT_LONG:    return PUT_FIELD_LONG;
        case Type.BT_FLOAT:   return PUT_FIELD_FLOAT;
        case Type.BT_DOUBLE:  return PUT_FIELD_DOUBLE;
        case Type.BT_OBJECT:  return PUT_FIELD_OBJECT;
        case Type.BT_BOOLEAN: return PUT_FIELD_BOOLEAN;
        case Type.BT_BYTE:    return PUT_FIELD_BYTE;
        case Type.BT_CHAR:    return PUT_FIELD_CHAR;
        case Type.BT_SHORT:   return PUT_FIELD_SHORT;
    }

    return throwBadType(type);
}
 
Example 13
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpl} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpl(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_LONG:   return CMPL_LONG;
        case Type.BT_FLOAT:  return CMPL_FLOAT;
        case Type.BT_DOUBLE: return CMPL_DOUBLE;
    }

    return throwBadType(type);
}
 
Example 14
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpl} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpl(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_LONG:   return CMPL_LONG;
        case Type.BT_FLOAT:  return CMPL_FLOAT;
        case Type.BT_DOUBLE: return CMPL_DOUBLE;
    }

    return throwBadType(type);
}
 
Example 15
Source File: Rops.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpg} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpg(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_FLOAT:  return CMPG_FLOAT;
        case Type.BT_DOUBLE: return CMPG_DOUBLE;
    }

    return throwBadType(type);
}
 
Example 16
Source File: LiteralOpUpgrader.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to replace an instruction with a const instruction. The given
 * instruction must have a constant result for it to be replaced.
 *
 * @param insn {@code non-null;} instruction to try to replace
 * @return true if the instruction was replaced
 */
private boolean tryReplacingWithConstant(NormalSsaInsn insn) {
    Insn originalRopInsn = insn.getOriginalRopInsn();
    Rop opcode = originalRopInsn.getOpcode();
    RegisterSpec result = insn.getResult();

    if (result != null && !ssaMeth.isRegALocal(result) &&
            opcode.getOpcode() != RegOps.CONST) {
        TypeBearer type = insn.getResult().getTypeBearer();
        if (type.isConstant() && type.getBasicType() == Type.BT_INT) {
            // Replace the instruction with a constant
            replacePlainInsn(insn, RegisterSpecList.EMPTY,
                    RegOps.CONST, (Constant) type);

            // Remove the source as well if this is a move-result-pseudo
            if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
                int pred = insn.getBlock().getPredecessors().nextSetBit(0);
                ArrayList<SsaInsn> predInsns =
                        ssaMeth.getBlocks().get(pred).getInsns();
                NormalSsaInsn sourceInsn =
                        (NormalSsaInsn) predInsns.get(predInsns.size()-1);
                replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY,
                        RegOps.GOTO, null);
            }
            return true;
        }
    }
    return false;
}
 
Example 17
Source File: LiteralOpUpgrader.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to replace an instruction with a const instruction. The given
 * instruction must have a constant result for it to be replaced.
 *
 * @param insn {@code non-null;} instruction to try to replace
 * @return true if the instruction was replaced
 */
private boolean tryReplacingWithConstant(NormalSsaInsn insn) {
    Insn originalRopInsn = insn.getOriginalRopInsn();
    Rop opcode = originalRopInsn.getOpcode();
    RegisterSpec result = insn.getResult();

    if (result != null && !ssaMeth.isRegALocal(result) &&
            opcode.getOpcode() != RegOps.CONST) {
        TypeBearer type = insn.getResult().getTypeBearer();
        if (type.isConstant() && type.getBasicType() == Type.BT_INT) {
            // Replace the instruction with a constant
            replacePlainInsn(insn, RegisterSpecList.EMPTY,
                    RegOps.CONST, (Constant) type);

            // Remove the source as well if this is a move-result-pseudo
            if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
                int pred = insn.getBlock().getPredecessors().nextSetBit(0);
                ArrayList<SsaInsn> predInsns =
                        ssaMeth.getBlocks().get(pred).getInsns();
                NormalSsaInsn sourceInsn =
                        (NormalSsaInsn) predInsns.get(predInsns.size()-1);
                replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY,
                        RegOps.GOTO, null);
            }
            return true;
        }
    }
    return false;
}
 
Example 18
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpg} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpg(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_FLOAT:  return CMPG_FLOAT;
        case Type.BT_DOUBLE: return CMPG_DOUBLE;
    }

    return throwBadType(type);
}
 
Example 19
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpg} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpg(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_FLOAT:  return CMPG_FLOAT;
        case Type.BT_DOUBLE: return CMPG_DOUBLE;
    }

    return throwBadType(type);
}
 
Example 20
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code cmpl} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being compared
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opCmpl(TypeBearer type) {
    switch (type.getBasicType()) {
        case Type.BT_LONG:   return CMPL_LONG;
        case Type.BT_FLOAT:  return CMPL_FLOAT;
        case Type.BT_DOUBLE: return CMPL_DOUBLE;
    }

    return throwBadType(type);
}