com.android.dx.rop.type.TypeBearer Java Examples

The following examples show how to use com.android.dx.rop.type.TypeBearer. 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 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 #2
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 #3
Source File: Rops.java    From Box 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 #4
Source File: Rops.java    From buck 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 #5
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code new-array} rop for the given
 * type. The result is a shared instance.
 *
 * @param arrayType {@code non-null;} array type of array being created
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opNewArray(TypeBearer arrayType) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    switch (elementType.getBasicType()) {
        case Type.BT_INT:     return NEW_ARRAY_INT;
        case Type.BT_LONG:    return NEW_ARRAY_LONG;
        case Type.BT_FLOAT:   return NEW_ARRAY_FLOAT;
        case Type.BT_DOUBLE:  return NEW_ARRAY_DOUBLE;
        case Type.BT_BOOLEAN: return NEW_ARRAY_BOOLEAN;
        case Type.BT_BYTE:    return NEW_ARRAY_BYTE;
        case Type.BT_CHAR:    return NEW_ARRAY_CHAR;
        case Type.BT_SHORT:   return NEW_ARRAY_SHORT;
        case Type.BT_OBJECT: {
            return new Rop(RegOps.NEW_ARRAY, type, StdTypeList.INT,
                    Exceptions.LIST_Error_NegativeArraySizeException,
                    "new-array-object");
        }
    }

    return throwBadType(type);
}
 
Example #6
Source File: ExecutionStack.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Changes an element already on a stack. This method is useful in limited
 * contexts, particularly when merging two instances. As such, it places
 * the following restriction on its behavior: You may only replace
 * values with other values of the same category.
 *
 * @param n {@code >= 0;} which element to change, where {@code 0} is
 * the top element of the stack
 * @param type {@code non-null;} type of the new value
 * @throws SimException thrown if {@code n >= size()} or
 * the action is otherwise prohibited
 */
public void change(int n, TypeBearer type) {
    throwIfImmutable();

    try {
        type = type.getFrameType();
    } catch (NullPointerException ex) {
        // Elucidate the exception.
        throw new NullPointerException("type == null");
    }

    int idx = stackPtr - n - 1;
    TypeBearer orig = stack[idx];

    if ((orig == null) ||
        (orig.getType().getCategory() != type.getType().getCategory())) {
        throwSimException("incompatible substitution: " +
                          stackElementString(orig) + " -> " +
                          stackElementString(type));
    }

    stack[idx] = type;
}
 
Example #7
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 #8
Source File: OneLocalsArray.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public TypeBearer getCategory1(int idx) {
       TypeBearer result = get(idx);
       Type type = result.getType();

       if (type.isUninitialized()) {
           return throwSimException(idx, "uninitialized instance");
       }

       if (type.isCategory2()) {
           return throwSimException(idx, "category-2");
       }

       return result;
   }
 
Example #9
Source File: Rops.java    From buck 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 #10
Source File: Rops.java    From buck 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 #11
Source File: Rops.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code new-array} rop for the given
 * type. The result is a shared instance.
 *
 * @param arrayType {@code non-null;} array type of array being created
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opNewArray(TypeBearer arrayType) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    switch (elementType.getBasicType()) {
        case Type.BT_INT:     return NEW_ARRAY_INT;
        case Type.BT_LONG:    return NEW_ARRAY_LONG;
        case Type.BT_FLOAT:   return NEW_ARRAY_FLOAT;
        case Type.BT_DOUBLE:  return NEW_ARRAY_DOUBLE;
        case Type.BT_BOOLEAN: return NEW_ARRAY_BOOLEAN;
        case Type.BT_BYTE:    return NEW_ARRAY_BYTE;
        case Type.BT_CHAR:    return NEW_ARRAY_CHAR;
        case Type.BT_SHORT:   return NEW_ARRAY_SHORT;
        case Type.BT_OBJECT: {
            return new Rop(RegOps.NEW_ARRAY, type, StdTypeList.INT,
                    Exceptions.LIST_Error_NegativeArraySizeException,
                    "new-array-object");
        }
    }

    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 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 #13
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, int count) {
       ExecutionStack stack = frame.getStack();

       clearArgs();

       if (count > args.length) {
           // Grow args, and add a little extra room to grow even more.
           args = new TypeBearer[count + 10];
       }

       for (int i = count - 1; i >= 0; i--) {
           args[i] = stack.pop();
       }

       argCount = count;
   }
 
Example #14
Source File: OneLocalsArray.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public TypeBearer getCategory1(int idx) {
    TypeBearer result = get(idx);
    Type type = result.getType();

    if (type.isUninitialized()) {
        return throwSimException(idx, "uninitialized instance");
    }

    if (type.isCategory2()) {
        return throwSimException(idx, "category-2");
    }

    return result;
}
 
Example #15
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 #16
Source File: ExecutionStack.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Changes an element already on a stack. This method is useful in limited
 * contexts, particularly when merging two instances. As such, it places
 * the following restriction on its behavior: You may only replace
 * values with other values of the same category.
 *
 * @param n {@code >= 0;} which element to change, where {@code 0} is
 * the top element of the stack
 * @param type {@code non-null;} type of the new value
 * @throws SimException thrown if {@code n >= size()} or
 * the action is otherwise prohibited
 */
public void change(int n, TypeBearer type) {
    throwIfImmutable();

    try {
        type = type.getFrameType();
    } catch (NullPointerException ex) {
        // Elucidate the exception.
        throw new NullPointerException("type == null");
    }

    int idx = stackPtr - n - 1;
    TypeBearer orig = stack[idx];

    if ((orig == null) ||
        (orig.getType().getCategory() != type.getType().getCategory())) {
        throwSimException("incompatible substitution: " +
                          stackElementString(orig) + " -> " +
                          stackElementString(type));
    }

    stack[idx] = type;
}
 
Example #17
Source File: OneLocalsArray.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
   @Override
public TypeBearer getCategory2(int idx) {
       TypeBearer result = get(idx);

       if (result.getType().isCategory1()) {
           return throwSimException(idx, "category-1");
       }

       return result;
   }
 
Example #18
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code mark-local} rop for the given type.
 * The result is a shared instance.
 *
 * @param type {@code non-null;} type of value being marked
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opMarkLocal(TypeBearer type) {
    switch (type.getBasicFrameType()) {
        case Type.BT_INT:    return MARK_LOCAL_INT;
        case Type.BT_LONG:   return MARK_LOCAL_LONG;
        case Type.BT_FLOAT:  return MARK_LOCAL_FLOAT;
        case Type.BT_DOUBLE: return MARK_LOCAL_DOUBLE;
        case Type.BT_OBJECT: return MARK_LOCAL_OBJECT;
    }

    return throwBadType(type);
}
 
Example #19
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String toHuman() {
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < locals.length; i++) {
        TypeBearer type = locals[i];
        String s = (type == null) ? "<invalid>" : type.toString();
        sb.append("locals[" + Hex.u2(i) + "]: " + s + "\n");
    }

    return sb.toString();
}
 
Example #20
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void annotate(ExceptionWithContext ex) {
    for (int i = 0; i < locals.length; i++) {
        TypeBearer type = locals[i];
        String s = (type == null) ? "<invalid>" : type.toString();
        ex.addContext("locals[" + Hex.u2(i) + "]: " + s);
    }
}
 
Example #21
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code return} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being returned
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opReturn(TypeBearer type) {
    switch (type.getBasicFrameType()) {
        case Type.BT_INT:    return RETURN_INT;
        case Type.BT_LONG:   return RETURN_LONG;
        case Type.BT_FLOAT:  return RETURN_FLOAT;
        case Type.BT_DOUBLE: return RETURN_DOUBLE;
        case Type.BT_OBJECT: return RETURN_OBJECT;
        case Type.BT_VOID:   return RETURN_VOID;
    }

    return throwBadType(type);
}
 
Example #22
Source File: RegisterSpec.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This constructor is private. Use
 * {@link #make}.
 *
 * @param reg {@code >= 0;} the register number
 * @param type {@code non-null;} the type (or possibly actual value) which
 * is loaded from or stored to the indicated register
 * @param local {@code null-ok;} the associated local variable, if any
 */
private RegisterSpec(int reg, TypeBearer type, LocalItem local) {
    if (reg < 0) {
        throw new IllegalArgumentException("reg < 0");
    }

    if (type == null) {
        throw new NullPointerException("type == null");
    }

    this.reg = reg;
    this.type = type;
    this.local = local;
}
 
Example #23
Source File: ExecutionStack.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Pushes a value of the given type onto the stack.
 *
 * @param type {@code non-null;} type of the value
 * @throws SimException thrown if there is insufficient room on the
 * stack for the value
 */
public void push(TypeBearer type) {
    throwIfImmutable();

    int category;

    try {
        type = type.getFrameType();
        category = type.getType().getCategory();
    } catch (NullPointerException ex) {
        // Elucidate the exception.
        throw new NullPointerException("type == null");
    }

    if ((stackPtr + category) > stack.length) {
        throwSimException("overflow");
        return;
    }

    if (category == 2) {
        stack[stackPtr] = null;
        stackPtr++;
    }

    stack[stackPtr] = type;
    stackPtr++;
}
 
Example #24
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 #25
Source File: Rops.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code move} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being moved
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opMove(TypeBearer type) {
    switch (type.getBasicFrameType()) {
        case Type.BT_INT:    return MOVE_INT;
        case Type.BT_LONG:   return MOVE_LONG;
        case Type.BT_FLOAT:  return MOVE_FLOAT;
        case Type.BT_DOUBLE: return MOVE_DOUBLE;
        case Type.BT_OBJECT: return MOVE_OBJECT;
        case Type.BT_ADDR:   return MOVE_RETURN_ADDRESS;
    }

    return throwBadType(type);
}
 
Example #26
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public TypeBearer getCategory2(int idx) {
    TypeBearer result = get(idx);

    if (result.getType().isCategory1()) {
        return throwSimException(idx, "category-1");
    }

    return result;
}
 
Example #27
Source File: LocalsArraySet.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void set(int idx, TypeBearer type) {
    throwIfImmutable();

    primary.set(idx, type);

    for (LocalsArray la : secondaries) {
        if (la != null) {
            la.set(idx, type);
        }
    }
}
 
Example #28
Source File: RegisterSpec.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an instance that is the intersection between this instance
 * and the given one, if any. The intersection is defined as follows:
 *
 * <ul>
 *   <li>If {@code other} is {@code null}, then the result
 *     is {@code null}.
 *   <li>If the register numbers don't match, then the intersection
 *     is {@code null}. Otherwise, the register number of the
 *     intersection is the same as the one in the two instances.</li>
 *   <li>If the types returned by {@code getType()} are not
 *     {@code equals()}, then the intersection is null.</li>
 *   <li>If the type bearers returned by {@code getTypeBearer()}
 *     are {@code equals()}, then the intersection's type bearer
 *     is the one from this instance. Otherwise, the intersection's
 *     type bearer is the {@code getType()} of this instance.</li>
 *   <li>If the locals are {@code equals()}, then the local info
 *     of the intersection is the local info of this instance. Otherwise,
 *     the local info of the intersection is {@code null}.</li>
 * </ul>
 *
 * @param other {@code null-ok;} instance to intersect with (or {@code null})
 * @param localPrimary whether local variables are primary to the
 * intersection; if {@code true}, then the only non-null
 * results occur when registers being intersected have equal local
 * infos (or both have {@code null} local infos)
 * @return {@code null-ok;} the intersection
 */
public RegisterSpec intersect(RegisterSpec other, boolean localPrimary) {
    if (this == other) {
        // Easy out.
        return this;
    }

    if ((other == null) || (reg != other.getReg())) {
        return null;
    }

    LocalItem resultLocal =
        ((local == null) || !local.equals(other.getLocalItem()))
        ? null : local;
    boolean sameName = (resultLocal == local);

    if (localPrimary && !sameName) {
        return null;
    }

    Type thisType = getType();
    Type otherType = other.getType();

    // Note: Types are always interned.
    if (thisType != otherType) {
        return null;
    }

    TypeBearer resultTypeBearer =
        type.equals(other.getTypeBearer()) ? type : thisType;

    if ((resultTypeBearer == type) && sameName) {
        // It turns out that the intersection is "this" after all.
        return this;
    }

    return (resultLocal == null) ? make(reg, resultTypeBearer) :
        make(reg, resultTypeBearer, resultLocal);
}
 
Example #29
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void annotate(ExceptionWithContext ex) {
    for (int i = 0; i < locals.length; i++) {
        TypeBearer type = locals[i];
        String s = (type == null) ? "<invalid>" : type.toString();
        ex.addContext("locals[" + Hex.u2(i) + "]: " + s);
    }
}
 
Example #30
Source File: BaseMachine.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Throws an exception that indicates a mismatch in local variable
 * types.
 *
 * @param found {@code non-null;} the encountered type
 * @param local {@code non-null;} the local variable's claimed type
 */
public static void throwLocalMismatch(TypeBearer found,
        TypeBearer local) {
    throw new SimException("local variable type mismatch: " +
            "attempt to set or access a value of type " +
            found.toHuman() +
            " using a local variable of type " +
            local.toHuman() +
            ". This is symptomatic of .class transformation tools " +
            "that ignore local variable information.");
}