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

The following examples show how to use com.android.dx.rop.type.TypeBearer#getFrameType() . 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: ExecutionStack.java    From Box 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 2
Source File: ExecutionStack.java    From Box 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 3
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 4
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 5
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void set(int idx, TypeBearer type) {
    throwIfImmutable();

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

    if (idx < 0) {
        throw new IndexOutOfBoundsException("idx < 0");
    }

    // Make highest possible out-of-bounds check happen first.
    if (type.getType().isCategory2()) {
        locals[idx + 1] = null;
    }

    locals[idx] = type;

    if (idx != 0) {
        TypeBearer prev = locals[idx - 1];
        if ((prev != null) && prev.getType().isCategory2()) {
            locals[idx - 1] = null;
        }
    }
}
 
Example 6
Source File: ExecutionStack.java    From Box 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 7
Source File: OneLocalsArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void set(int idx, TypeBearer type) {
    throwIfImmutable();

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

    if (idx < 0) {
        throw new IndexOutOfBoundsException("idx < 0");
    }

    // Make highest possible out-of-bounds check happen first.
    if (type.getType().isCategory2()) {
        locals[idx + 1] = null;
    }

    locals[idx] = type;

    if (idx != 0) {
        TypeBearer prev = locals[idx - 1];
        if ((prev != null) && prev.getType().isCategory2()) {
            locals[idx - 1] = null;
        }
    }
}
 
Example 8
Source File: ExecutionStack.java    From Box 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 9
Source File: OneLocalsArray.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
   @Override
public void set(int idx, TypeBearer type) {
       throwIfImmutable();

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

       if (idx < 0) {
           throw new IndexOutOfBoundsException("idx < 0");
       }

       // Make highest possible out-of-bounds check happen first.
       if (type.getType().isCategory2()) {
           locals[idx + 1] = null;
       }

       locals[idx] = type;

       if (idx != 0) {
           TypeBearer prev = locals[idx - 1];
           if ((prev != null) && prev.getType().isCategory2()) {
               locals[idx - 1] = null;
           }
       }
   }
 
Example 10
Source File: ExecutionStack.java    From J2ME-Loader 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 11
Source File: OneLocalsArray.java    From buck with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void set(int idx, TypeBearer type) {
    throwIfImmutable();

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

    if (idx < 0) {
        throw new IndexOutOfBoundsException("idx < 0");
    }

    // Make highest possible out-of-bounds check happen first.
    if (type.getType().isCategory2()) {
        locals[idx + 1] = null;
    }

    locals[idx] = type;

    if (idx != 0) {
        TypeBearer prev = locals[idx - 1];
        if ((prev != null) && prev.getType().isCategory2()) {
            locals[idx - 1] = null;
        }
    }
}
 
Example 12
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++;
}