Java Code Examples for com.android.dx.rop.type.Type#toHuman()

The following examples show how to use com.android.dx.rop.type.Type#toHuman() . 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: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public final void popArgs(Frame frame, Type type1, Type type2) {
    // Use the above method to do the actual popping...
    popArgs(frame, 2);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }
}
 
Example 2
Source File: Zeroes.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the "zero" (or {@code null}) value for the given type.
 *
 * @param type {@code non-null;} the type in question
 * @return {@code non-null;} its "zero" value
 */
public static Constant zeroFor(Type type) {
    switch (type.getBasicType()) {
        case Type.BT_BOOLEAN: return CstBoolean.VALUE_FALSE;
        case Type.BT_BYTE:    return CstByte.VALUE_0;
        case Type.BT_CHAR:    return CstChar.VALUE_0;
        case Type.BT_DOUBLE:  return CstDouble.VALUE_0;
        case Type.BT_FLOAT:   return CstFloat.VALUE_0;
        case Type.BT_INT:     return CstInteger.VALUE_0;
        case Type.BT_LONG:    return CstLong.VALUE_0;
        case Type.BT_SHORT:   return CstShort.VALUE_0;
        case Type.BT_OBJECT:  return CstKnownNull.THE_ONE;
        default: {
            throw new UnsupportedOperationException("no zero for type: " +
                    type.toHuman());
        }
    }
}
 
Example 3
Source File: BaseMachine.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public final void popArgs(Frame frame, Type type1, Type type2,
        Type type3) {
    // Use the above method to do the actual popping...
    popArgs(frame, 3);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type3, args[2])) {
        throw new SimException("expected type " + type3.toHuman() +
                " but found " + args[2].getType().toHuman());
    }
}
 
Example 4
Source File: BaseMachine.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public final void popArgs(Frame frame, Type type1, Type type2) {
    // Use the above method to do the actual popping...
    popArgs(frame, 2);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }
}
 
Example 5
Source File: Simulator.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the prototype is compatible with returning the
 * given type, and throws if not.
 *
 * @param encountered {@code non-null;} the encountered return type
 */
private void checkReturnType(Type encountered) {
    Type returnType = machine.getPrototype().getReturnType();

    /*
     * Check to see if the prototype's return type is
     * possibly assignable from the type we encountered. This
     * takes care of all the salient cases (types are the same,
     * they're compatible primitive types, etc.).
     */
    if (!Merger.isPossiblyAssignableFrom(returnType, encountered)) {
        throw new SimException("return type mismatch: prototype " +
                "indicates " + returnType.toHuman() +
                ", but encountered type " + encountered.toHuman());
    }
}
 
Example 6
Source File: Zeroes.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the "zero" (or {@code null}) value for the given type.
 *
 * @param type {@code non-null;} the type in question
 * @return {@code non-null;} its "zero" value
 */
public static Constant zeroFor(Type type) {
    switch (type.getBasicType()) {
        case Type.BT_BOOLEAN: return CstBoolean.VALUE_FALSE;
        case Type.BT_BYTE:    return CstByte.VALUE_0;
        case Type.BT_CHAR:    return CstChar.VALUE_0;
        case Type.BT_DOUBLE:  return CstDouble.VALUE_0;
        case Type.BT_FLOAT:   return CstFloat.VALUE_0;
        case Type.BT_INT:     return CstInteger.VALUE_0;
        case Type.BT_LONG:    return CstLong.VALUE_0;
        case Type.BT_SHORT:   return CstShort.VALUE_0;
        case Type.BT_OBJECT:  return CstKnownNull.THE_ONE;
        default: {
            throw new UnsupportedOperationException("no zero for type: " +
                    type.toHuman());
        }
    }
}
 
Example 7
Source File: BaseMachine.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public final void popArgs(Frame frame, Type type1, Type type2,
						  Type type3) {
       // Use the above method to do the actual popping...
       popArgs(frame, 3);

       // ...and then verify the popped types.

       if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
           throw new SimException("expected type " + type1.toHuman() +
                   " but found " + args[0].getType().toHuman());
       }

       if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
           throw new SimException("expected type " + type2.toHuman() +
                   " but found " + args[1].getType().toHuman());
       }

       if (! Merger.isPossiblyAssignableFrom(type3, args[2])) {
           throw new SimException("expected type " + type3.toHuman() +
                   " but found " + args[2].getType().toHuman());
       }
   }
 
Example 8
Source File: BaseMachine.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public final void popArgs(Frame frame, Type type1, Type type2) {
       // Use the above method to do the actual popping...
       popArgs(frame, 2);

       // ...and then verify the popped types.

       if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
           throw new SimException("expected type " + type1.toHuman() +
                   " but found " + args[0].getType().toHuman());
       }

       if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
           throw new SimException("expected type " + type2.toHuman() +
                   " but found " + args[1].getType().toHuman());
       }
   }
 
Example 9
Source File: Simulator.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the prototype is compatible with returning the
 * given type, and throws if not.
 *
 * @param encountered {@code non-null;} the encountered return type
 */
private void checkReturnType(Type encountered) {
    Type returnType = machine.getPrototype().getReturnType();

    /*
     * Check to see if the prototype's return type is
     * possibly assignable from the type we encountered. This
     * takes care of all the salient cases (types are the same,
     * they're compatible primitive types, etc.).
     */
    if (!Merger.isPossiblyAssignableFrom(returnType, encountered)) {
        throw new SimException("return type mismatch: prototype " +
                "indicates " + returnType.toHuman() +
                ", but encountered type " + encountered.toHuman());
    }
}
 
Example 10
Source File: Zeroes.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the "zero" (or {@code null}) value for the given type.
 *
 * @param type {@code non-null;} the type in question
 * @return {@code non-null;} its "zero" value
 */
public static Constant zeroFor(Type type) {
    switch (type.getBasicType()) {
        case Type.BT_BOOLEAN: return CstBoolean.VALUE_FALSE;
        case Type.BT_BYTE:    return CstByte.VALUE_0;
        case Type.BT_CHAR:    return CstChar.VALUE_0;
        case Type.BT_DOUBLE:  return CstDouble.VALUE_0;
        case Type.BT_FLOAT:   return CstFloat.VALUE_0;
        case Type.BT_INT:     return CstInteger.VALUE_0;
        case Type.BT_LONG:    return CstLong.VALUE_0;
        case Type.BT_SHORT:   return CstShort.VALUE_0;
        case Type.BT_OBJECT:  return CstKnownNull.THE_ONE;
        default: {
            throw new UnsupportedOperationException("no zero for type: " +
                    type.toHuman());
        }
    }
}
 
Example 11
Source File: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public final void popArgs(Frame frame, Type type1, Type type2,
        Type type3) {
    // Use the above method to do the actual popping...
    popArgs(frame, 3);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type3, args[2])) {
        throw new SimException("expected type " + type3.toHuman() +
                " but found " + args[2].getType().toHuman());
    }
}
 
Example 12
Source File: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public final void popArgs(Frame frame, Type type1, Type type2) {
    // Use the above method to do the actual popping...
    popArgs(frame, 2);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }
}
 
Example 13
Source File: Zeroes.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the "zero" (or {@code null}) value for the given type.
 *
 * @param type {@code non-null;} the type in question
 * @return {@code non-null;} its "zero" value
 */
public static Constant zeroFor(Type type) {
    switch (type.getBasicType()) {
        case Type.BT_BOOLEAN: return CstBoolean.VALUE_FALSE;
        case Type.BT_BYTE:    return CstByte.VALUE_0;
        case Type.BT_CHAR:    return CstChar.VALUE_0;
        case Type.BT_DOUBLE:  return CstDouble.VALUE_0;
        case Type.BT_FLOAT:   return CstFloat.VALUE_0;
        case Type.BT_INT:     return CstInteger.VALUE_0;
        case Type.BT_LONG:    return CstLong.VALUE_0;
        case Type.BT_SHORT:   return CstShort.VALUE_0;
        case Type.BT_OBJECT:  return CstKnownNull.THE_ONE;
        default: {
            throw new UnsupportedOperationException("no zero for type: " +
                    type.toHuman());
        }
    }
}
 
Example 14
Source File: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public final void popArgs(Frame frame, Type type1, Type type2,
        Type type3) {
    // Use the above method to do the actual popping...
    popArgs(frame, 3);

    // ...and then verify the popped types.

    if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
        throw new SimException("expected type " + type1.toHuman() +
                " but found " + args[0].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
        throw new SimException("expected type " + type2.toHuman() +
                " but found " + args[1].getType().toHuman());
    }

    if (! Merger.isPossiblyAssignableFrom(type3, args[2])) {
        throw new SimException("expected type " + type3.toHuman() +
                " but found " + args[2].getType().toHuman());
    }
}
 
Example 15
Source File: BaseMachine.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
@Override
public final void popArgs(Frame frame, Type type) {
       // Use the above method to do the actual popping...
       popArgs(frame, 1);

       // ...and then verify the popped type.
       if (! Merger.isPossiblyAssignableFrom(type, args[0])) {
           throw new SimException("expected type " + type.toHuman() +
                   " but found " + args[0].getType().toHuman());
       }
   }
 
Example 16
Source File: BaseMachine.java    From Box with Apache License 2.0 5 votes vote down vote up
@Override
public final void popArgs(Frame frame, Type type) {
    // Use the above method to do the actual popping...
    popArgs(frame, 1);

    // ...and then verify the popped type.
    if (! Merger.isPossiblyAssignableFrom(type, args[0])) {
        throw new SimException("expected type " + type.toHuman() +
                " but found " + args[0].getType().toHuman());
    }
}
 
Example 17
Source File: BaseMachine.java    From buck with Apache License 2.0 5 votes vote down vote up
public final void popArgs(Frame frame, Type type) {
    // Use the above method to do the actual popping...
    popArgs(frame, 1);

    // ...and then verify the popped type.
    if (! Merger.isPossiblyAssignableFrom(type, args[0])) {
        throw new SimException("expected type " + type.toHuman() +
                " but found " + args[0].getType().toHuman());
    }
}
 
Example 18
Source File: BaseMachine.java    From Box with Apache License 2.0 5 votes vote down vote up
@Override
public final void popArgs(Frame frame, Type type) {
    // Use the above method to do the actual popping...
    popArgs(frame, 1);

    // ...and then verify the popped type.
    if (! Merger.isPossiblyAssignableFrom(type, args[0])) {
        throw new SimException("expected type " + type.toHuman() +
                " but found " + args[0].getType().toHuman());
    }
}