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

The following examples show how to use com.android.dx.rop.type.Type. 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: CodeItem.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void addContents(DexFile file) {
    MixedItemSection byteData = file.getByteData();
    TypeIdsSection typeIds = file.getTypeIds();

    if (code.hasPositions() || code.hasLocals()) {
        debugInfo = new DebugInfoItem(code, isStatic, ref);
        byteData.add(debugInfo);
    }

    if (code.hasAnyCatches()) {
        for (Type type : code.getCatchTypes()) {
            typeIds.intern(type);
        }
        catches = new CatchStructs(code);
    }

    for (Constant c : code.getInsnConstants()) {
        file.internIfAppropriate(c);
    }
}
 
Example #2
Source File: ClassDefsSection.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int sz = classDefs.size();
    int idx = 0;

    orderedDefs = new ArrayList<ClassDefItem>(sz);

    /*
     * Iterate over all the classes, recursively assigning an
     * index to each, implicitly skipping the ones that have
     * already been assigned by the time this (top-level)
     * iteration reaches them.
     */
    for (Type type : classDefs.keySet()) {
        idx = orderItems0(type, idx, sz - idx);
    }
}
 
Example #3
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 #4
Source File: ClassDefsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    Type type = ((CstType) cst).getClassType();
    IndexedItem result = classDefs.get(type);

    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
Example #5
Source File: CstType.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an instance of this class that represents the wrapper
 * class corresponding to a given primitive type. For example, if
 * given {@link Type#INT}, this method returns the class reference
 * {@code java.lang.Integer}.
 *
 * @param primitiveType {@code non-null;} the primitive type
 * @return {@code non-null;} the corresponding wrapper class
 */
public static CstType forBoxedPrimitiveType(Type primitiveType) {
    switch (primitiveType.getBasicType()) {
        case Type.BT_BOOLEAN: return BOOLEAN;
        case Type.BT_BYTE:    return BYTE;
        case Type.BT_CHAR:    return CHARACTER;
        case Type.BT_DOUBLE:  return DOUBLE;
        case Type.BT_FLOAT:   return FLOAT;
        case Type.BT_INT:     return INTEGER;
        case Type.BT_LONG:    return LONG;
        case Type.BT_SHORT:   return SHORT;
        case Type.BT_VOID:    return VOID;
    }

    throw new IllegalArgumentException("not primitive: " + primitiveType);
}
 
Example #6
Source File: TypeListItem.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void writeTo0(DexFile file, AnnotatedOutput out) {
    TypeIdsSection typeIds = file.getTypeIds();
    int sz = list.size();

    if (out.annotates()) {
        out.annotate(0, offsetString() + " type_list");
        out.annotate(HEADER_SIZE, "  size: " + Hex.u4(sz));
        for (int i = 0; i < sz; i++) {
            Type one = list.getType(i);
            int idx = typeIds.indexOf(one);
            out.annotate(ELEMENT_SIZE,
                         "  " + Hex.u2(idx) + " // " + one.toHuman());
        }
    }

    out.writeInt(sz);

    for (int i = 0; i < sz; i++) {
        out.writeShort(typeIds.indexOf(list.getType(i)));
    }
}
 
Example #7
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 #8
Source File: ExecutionStack.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Replaces all the occurrences of the given uninitialized type in
 * this stack with its initialized equivalent.
 *
 * @param type {@code non-null;} type to replace
 */
public void makeInitialized(Type type) {
    if (stackPtr == 0) {
        // We have to check for this before checking for immutability.
        return;
    }

    throwIfImmutable();

    Type initializedType = type.getInitializedType();

    for (int i = 0; i < stackPtr; i++) {
        if (stack[i] == type) {
            stack[i] = initializedType;
        }
    }
}
 
Example #9
Source File: ExecutionStack.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Replaces all the occurrences of the given uninitialized type in
 * this stack with its initialized equivalent.
 *
 * @param type {@code non-null;} type to replace
 */
public void makeInitialized(Type type) {
    if (stackPtr == 0) {
        // We have to check for this before checking for immutability.
        return;
    }

    throwIfImmutable();

    Type initializedType = type.getInitializedType();

    for (int i = 0; i < stackPtr; i++) {
        if (stack[i] == type) {
            stack[i] = initializedType;
        }
    }
}
 
Example #10
Source File: EscapeAnalysis.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
Example #11
Source File: ExecutionStack.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Replaces all the occurrences of the given uninitialized type in
 * this stack with its initialized equivalent.
 *
 * @param type {@code non-null;} type to replace
 */
public void makeInitialized(Type type) {
    if (stackPtr == 0) {
        // We have to check for this before checking for immutability.
        return;
    }

    throwIfImmutable();

    Type initializedType = type.getInitializedType();

    for (int i = 0; i < stackPtr; i++) {
        if (stack[i] == type) {
            stack[i] = initializedType;
        }
    }
}
 
Example #12
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 #13
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code const} rop for the given
 * type. The result is a shared instance.
 *
 * @param type {@code non-null;} type of the constant
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opConst(TypeBearer type) {
    if (type.getType() == Type.KNOWN_NULL) {
        return CONST_OBJECT_NOTHROW;
    }

    switch (type.getBasicFrameType()) {
        case Type.BT_INT:    return CONST_INT;
        case Type.BT_LONG:   return CONST_LONG;
        case Type.BT_FLOAT:  return CONST_FLOAT;
        case Type.BT_DOUBLE: return CONST_DOUBLE;
        case Type.BT_OBJECT: return CONST_OBJECT;
    }

    return throwBadType(type);
}
 
Example #14
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 #15
Source File: SsaRenamer.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public RegisterSpec map(RegisterSpec registerSpec) {
    if (registerSpec == null) return null;

    int reg = registerSpec.getReg();

    // For debugging: assert that the mapped types are compatible.
    if (DEBUG) {
        RegisterSpec newVersion = currentMapping[reg];
        if (newVersion.getBasicType() != Type.BT_VOID
                && registerSpec.getBasicFrameType()
                    != newVersion.getBasicFrameType()) {

            throw new RuntimeException(
                    "mapping registers of incompatible types! "
                    + registerSpec
                    + " " + currentMapping[reg]);
        }
    }

    return registerSpec.withReg(currentMapping[reg].getReg());
}
 
Example #16
Source File: TypeIdsSection.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    Type type = ((CstType) cst).getClassType();
    IndexedItem result = typeIds.get(type);

    if (result == null) {
        throw new IllegalArgumentException("not found: " + cst);
    }

    return result;
}
 
Example #17
Source File: OutputFinisher.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #getAllConstants} which adds all the info for
 * a single {@code RegisterSpec}.
 *
 * @param result {@code non-null;} result set to add to
 * @param spec {@code null-ok;} register spec to add
 */
private static void addConstants(HashSet<Constant> result,
        RegisterSpec spec) {
    if (spec == null) {
        return;
    }

    LocalItem local = spec.getLocalItem();
    CstString name = local.getName();
    CstString signature = local.getSignature();
    Type type = spec.getType();

    if (type != Type.KNOWN_NULL) {
        result.add(CstType.intern(type));
    }

    if (name != null) {
        result.add(name);
    }

    if (signature != null) {
        result.add(signature);
    }
}
 
Example #18
Source File: TypeIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Interns an element into this instance.
 *
 * @param type {@code non-null;} the type to intern
 * @return {@code non-null;} the interned reference
 */
public synchronized TypeIdItem intern(Type type) {
    if (type == null) {
        throw new NullPointerException("type == null");
    }

    throwIfPrepared();

    TypeIdItem result = typeIds.get(type);

    if (result == null) {
        result = new TypeIdItem(new CstType(type));
        typeIds.put(type, result);
    }

    return result;
}
 
Example #19
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 #20
Source File: Ropper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Get the {@link ExceptionHandlerSetup} corresponding to the given type. The
 * ExceptionHandlerSetup is created if this the first request for the given type.
 *
 * @param caughtType {@code non-null;}  the type catch by the requested setup
 * @return {@code non-null;} the handler setup block info for the given type
 */
ExceptionHandlerSetup getSetup(Type caughtType) {
    ExceptionHandlerSetup handler = setups.get(caughtType);
    if (handler == null) {
        int handlerSetupLabel = exceptionSetupLabelAllocator.getNextLabel();
        handler = new ExceptionHandlerSetup(caughtType, handlerSetupLabel);
        setups.put(caughtType, handler);
    }
    return handler;
}
 
Example #21
Source File: Rop.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use one of the
 * public constructors.
 *
 * @param opcode the opcode; one of the constants in {@link RegOps}
 * @param result {@code non-null;} result type of this operation; {@link
 * Type#VOID} for no-result operations
 * @param sources {@code non-null;} types of all the sources of this operation
 * @param exceptions {@code non-null;} list of possible types thrown by this
 * operation
 * @param branchingness the branchingness of this op; one of the
 * {@code BRANCH_*} constants
 * @param isCallLike whether the op is a function/method call or similar
 * @param nickname {@code null-ok;} optional nickname (used for debugging)
 */
public Rop(int opcode, Type result, TypeList sources,
           TypeList exceptions, int branchingness, boolean isCallLike,
           String nickname) {
    if (result == null) {
        throw new NullPointerException("result == null");
    }

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

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

    if ((branchingness < BRANCH_MIN) || (branchingness > BRANCH_MAX)) {
        throw new IllegalArgumentException("invalid branchingness: " + branchingness);
    }

    if ((exceptions.size() != 0) && (branchingness != BRANCH_THROW)) {
        throw new IllegalArgumentException("exceptions / branchingness " +
                                           "mismatch");
    }

    this.opcode = opcode;
    this.result = result;
    this.sources = sources;
    this.exceptions = exceptions;
    this.branchingness = branchingness;
    this.isCallLike = isCallLike;
    this.nickname = nickname;
}
 
Example #22
Source File: RegisterSpec.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #toString} and {@link #toHuman}.
 *
 * @param human whether to be human-oriented
 * @return {@code non-null;} the string form
 */
private String toString0(boolean human) {
    StringBuilder sb = new StringBuilder(40);

    sb.append(regString());
    sb.append(":");

    if (local != null) {
        sb.append(local.toString());
    }

    Type justType = type.getType();
    sb.append(justType);

    if (justType != type) {
        sb.append("=");
        if (human && (type instanceof CstString)) {
            sb.append(((CstString) type).toQuoted());
        } else if (human && (type instanceof Constant)) {
            sb.append(type.toHuman());
        } else {
            sb.append(type);
        }
    }

    return sb.toString();
}
 
Example #23
Source File: CfTranslator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #processFields}, which translates constants into
 * more specific types if necessary.
 *
 * @param constant {@code non-null;} the constant in question
 * @param type {@code non-null;} the desired type
 */
private static TypedConstant coerceConstant(TypedConstant constant,
        Type type) {
    Type constantType = constant.getType();

    if (constantType.equals(type)) {
        return constant;
    }

    switch (type.getBasicType()) {
        case Type.BT_BOOLEAN: {
            return CstBoolean.make(((CstInteger) constant).getValue());
        }
        case Type.BT_BYTE: {
            return CstByte.make(((CstInteger) constant).getValue());
        }
        case Type.BT_CHAR: {
            return CstChar.make(((CstInteger) constant).getValue());
        }
        case Type.BT_SHORT: {
            return CstShort.make(((CstInteger) constant).getValue());
        }
        default: {
            throw new UnsupportedOperationException("can't coerce " +
                    constant + " to " + type);
        }
    }
}
 
Example #24
Source File: Rops.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code not} rop for the given type. The
 * result is a shared instance.
 *
 * @param type {@code non-null;} type of value being operated on
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opNot(TypeBearer type) {
    switch (type.getBasicFrameType()) {
        case Type.BT_INT:  return NOT_INT;
        case Type.BT_LONG: return NOT_LONG;
    }

    return throwBadType(type);
}
 
Example #25
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate {@code move-param} 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 opMoveParam(TypeBearer type) {
    switch (type.getBasicFrameType()) {
        case Type.BT_INT:    return MOVE_PARAM_INT;
        case Type.BT_LONG:   return MOVE_PARAM_LONG;
        case Type.BT_FLOAT:  return MOVE_PARAM_FLOAT;
        case Type.BT_DOUBLE: return MOVE_PARAM_DOUBLE;
        case Type.BT_OBJECT: return MOVE_PARAM_OBJECT;
    }

    return throwBadType(type);
}
 
Example #26
Source File: LiteralOpUpgrader.java    From J2ME-Loader 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 #27
Source File: CstType.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param type {@code non-null;} the underlying type
 */
public CstType(Type type) {
    if (type == null) {
        throw new NullPointerException("type == null");
    }

    if (type == Type.KNOWN_NULL) {
        throw new UnsupportedOperationException(
                "KNOWN_NULL is not representable");
    }

    this.type = type;
    this.descriptor = null;
}
 
Example #28
Source File: RegisterSpec.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #toString} and {@link #toHuman}.
 *
 * @param human whether to be human-oriented
 * @return {@code non-null;} the string form
 */
private String toString0(boolean human) {
    StringBuilder sb = new StringBuilder(40);

    sb.append(regString());
    sb.append(":");

    if (local != null) {
        sb.append(local.toString());
    }

    Type justType = type.getType();
    sb.append(justType);

    if (justType != type) {
        sb.append("=");
        if (human && (type instanceof CstString)) {
            sb.append(((CstString) type).toQuoted());
        } else if (human && (type instanceof Constant)) {
            sb.append(type.toHuman());
        } else {
            sb.append(type);
        }
    }

    return sb.toString();
}
 
Example #29
Source File: Rop.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use one of the
 * public constructors.
 *
 * @param opcode the opcode; one of the constants in {@link RegOps}
 * @param result {@code non-null;} result type of this operation; {@link
 * Type#VOID} for no-result operations
 * @param sources {@code non-null;} types of all the sources of this operation
 * @param exceptions {@code non-null;} list of possible types thrown by this
 * operation
 * @param branchingness the branchingness of this op; one of the
 * {@code BRANCH_*} constants
 * @param isCallLike whether the op is a function/method call or similar
 * @param nickname {@code null-ok;} optional nickname (used for debugging)
 */
public Rop(int opcode, Type result, TypeList sources,
           TypeList exceptions, int branchingness, boolean isCallLike,
           String nickname) {
    if (result == null) {
        throw new NullPointerException("result == null");
    }

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

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

    if ((branchingness < BRANCH_MIN) || (branchingness > BRANCH_MAX)) {
        throw new IllegalArgumentException("invalid branchingness: " + branchingness);
    }

    if ((exceptions.size() != 0) && (branchingness != BRANCH_THROW)) {
        throw new IllegalArgumentException("exceptions / branchingness " +
                                           "mismatch");
    }

    this.opcode = opcode;
    this.result = result;
    this.sources = sources;
    this.exceptions = exceptions;
    this.branchingness = branchingness;
    this.isCallLike = isCallLike;
    this.nickname = nickname;
}
 
Example #30
Source File: Frame.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this frame with the method's parameters. Used for the first
 * frame.
 *
 * @param params Type list of method parameters.
 */
public void initializeWithParameters(StdTypeList params) {
    int at = 0;
    int sz = params.size();

    for (int i = 0; i < sz; i++) {
         Type one = params.get(i);
         locals.set(at, one);
         at += one.getCategory();
    }
}