當前位置: 首頁>>代碼示例>>Java>>正文


Java Opcode類代碼示例

本文整理匯總了Java中org.jf.dexlib.Code.Opcode的典型用法代碼示例。如果您正苦於以下問題:Java Opcode類的具體用法?Java Opcode怎麽用?Java Opcode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Opcode類屬於org.jf.dexlib.Code包,在下文中一共展示了Opcode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: InstructionNode

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
/**
 * Create an instruction node without having an <tt>AnalyzedInstruction</tt>.
 * Primarily eases testing.
 * @param op operation
 * @param target target register, if there is none, insert <tt>-1</tt>
 * @param source source register, i.e. parameters of operation
 */
public InstructionNode(final Opcode op, final int target, final int... source) {
    this.instr = null;
    this.idx = INDEX;
    ++INDEX;
    this.op = op;
    if (target > 0) {
        this.destination = Integer.toString(target);
    } else {
        this.destination = null;
    }
    if (source != null) {
        this.parameters = new String[source.length];
        for (int i = 0; i < parameters.length; ++i) {
            this.parameters[i] = Integer.toString(source[i]);
        }
    } else {
        this.parameters = null;
    }
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:27,代碼來源:InstructionNode.java

示例2: Instruction21c

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction21c(Opcode opcode, short regA, Item referencedItem) {
    super(opcode, referencedItem);

    if (regA >= 1 << 8) {
        throw new RuntimeException("The register number must be less than v256");
    }

    if (opcode == Opcode.NEW_INSTANCE) {
        assert referencedItem instanceof TypeIdItem;
        if (((TypeIdItem)referencedItem).getTypeDescriptor().charAt(0) != 'L') {
            throw new RuntimeException("Only class references can be used with the new-instance opcode");
        }
    }

    this.regA = (byte)regA;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:17,代碼來源:Instruction21c.java

示例3: isInstructionPaddingNop

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
/**
 * @param instructions The instructions array for this method
 * @param instruction The instruction
 * @return true if the specified instruction is a NOP, and the next instruction is one of the variable sized
 * switch/array data structures
 */
private boolean isInstructionPaddingNop(List<AnalyzedInstruction> instructions, AnalyzedInstruction instruction) {
    if (instruction.getInstruction().opcode != Opcode.NOP ||
        instruction.getInstruction().getFormat().variableSizeFormat) {

        return false;
    }

    if (instruction.getInstructionIndex() == instructions.size()-1) {
        return false;
    }

    AnalyzedInstruction nextInstruction = instructions.get(instruction.getInstructionIndex()+1);
    if (nextInstruction.getInstruction().getFormat().variableSizeFormat) {
        return true;
    }
    return false;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:24,代碼來源:MethodDefinition.java

示例4: SparseSwitchDataPseudoInstruction

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public SparseSwitchDataPseudoInstruction(int[] keys, int[] targets) {
    super(Opcode.NOP);

    if (keys.length != targets.length) {
        throw new RuntimeException("The number of keys and targets don't match");
    }

    if (targets.length == 0) {
        throw new RuntimeException("The sparse-switch data must contain at least 1 key/target");
    }

    if (targets.length > 0xFFFF) {
        throw new RuntimeException("The sparse-switch data contains too many elements. " +
                "The maximum number of switch elements is 65535");
    }

    this.keys = keys;
    this.targets = targets;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:20,代碼來源:SparseSwitchDataPseudoInstruction.java

示例5: ArrayDataPseudoInstruction

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public ArrayDataPseudoInstruction(byte[] buffer, int bufferIndex) {
    super(Opcode.NOP);

    byte opcodeByte = buffer[bufferIndex];
    if (opcodeByte != 0x00) {
        throw new RuntimeException("Invalid opcode byte for an ArrayData pseudo-instruction");
    }

    byte subopcodeByte = buffer[bufferIndex+1];
    if (subopcodeByte != 0x03) {
        throw new RuntimeException("Invalid sub-opcode byte for an ArrayData pseudo-instruction");
    }

    this.elementWidth = NumberUtils.decodeUnsignedShort(buffer, bufferIndex+2);
    int elementCount = NumberUtils.decodeInt(buffer, bufferIndex+4);
    this.encodedValues = new byte[elementCount * elementWidth];
    System.arraycopy(buffer, bufferIndex+8, encodedValues, 0, elementCount * elementWidth);
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:19,代碼來源:ArrayDataPseudoInstruction.java

示例6: Instruction22t

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction22t(Opcode opcode, byte regA, byte regB, short offC) {
    super(opcode);

    if (regA >= 16 ||
            regB >= 16) {
        throw new RuntimeException("The register number must be less than v16");
    }

    if (offC == 0) {
        throw new RuntimeException("The address offset cannot be 0.");
    }

    this.regA = regA;
    this.regB = regB;
    this.targetAddressOffset = offC;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:17,代碼來源:Instruction22t.java

示例7: Instruction35s

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction35s(Opcode opcode, int regCount, byte regD, byte regE, byte regF, byte regG,
                      byte regA, Item referencedItem) {
    super(opcode, referencedItem);

    if (regCount > 5) {
        throw new RuntimeException("regCount cannot be greater than 5");
    }

    if (regD >= 1 << 4 ||
            regE >= 1 << 4 ||
            regF >= 1 << 4 ||
            regG >= 1 << 4 ||
            regA >= 1 << 4) {
        throw new RuntimeException("All register args must fit in 4 bits");
    }

    checkItem(opcode, referencedItem, regCount);

    this.regCount = (byte)regCount;
    this.regA = regA;
    this.regD = regD;
    this.regE = regE;
    this.regF = regF;
    this.regG = regG;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:26,代碼來源:Instruction35s.java

示例8: checkItem

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
private static void checkItem(Opcode opcode, Item item, int regCount) {
    if (opcode == FILLED_NEW_ARRAY) {
        //check data for filled-new-array opcode
        String type = ((TypeIdItem) item).getTypeDescriptor();
        if (type.charAt(0) != '[') {
            throw new RuntimeException("The type must be an array type");
        }
        if (type.charAt(1) == 'J' || type.charAt(1) == 'D') {
            throw new RuntimeException("The type cannot be an array of longs or doubles");
        }
    } else if (opcode.value >= INVOKE_VIRTUAL.value && opcode.value <= INVOKE_INTERFACE.value) {
        //check data for invoke-* opcodes
        MethodIdItem methodIdItem = (MethodIdItem) item;
        int parameterRegisterCount = methodIdItem.getPrototype().getParameterRegisterCount();
        if (opcode != INVOKE_STATIC) {
            parameterRegisterCount++;
        }
        if (parameterRegisterCount != regCount) {
            throw new RuntimeException("regCount does not match the number of arguments of the method");
        }
    }
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:23,代碼來源:Instruction35s.java

示例9: Instruction35c

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction35c(Opcode opcode, int regCount, byte regD, byte regE, byte regF, byte regG,
                      byte regA, Item referencedItem) {
    super(opcode, referencedItem);

    if (regCount > 5) {
        throw new RuntimeException("regCount cannot be greater than 5");
    }

    if (regD >= 1 << 4 ||
            regE >= 1 << 4 ||
            regF >= 1 << 4 ||
            regG >= 1 << 4 ||
            regA >= 1 << 4) {
        throw new RuntimeException("All register args must fit in 4 bits");
    }

    this.regCount = (byte)regCount;
    this.regA = regA;
    this.regD = regD;
    this.regE = regE;
    this.regF = regF;
    this.regG = regG;

    checkItem(opcode, referencedItem, regCount);
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:26,代碼來源:Instruction35c.java

示例10: Instruction3rms

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction3rms(Opcode opcode, short regCount, int startReg, int methodIndex) {
    super(opcode);

    if (regCount >= 1 << 8) {
        throw new RuntimeException("regCount must be less than 256");
    }
    if (regCount < 0) {
        throw new RuntimeException("regCount cannot be negative");
    }

    if (startReg >= 1 << 16) {
        throw new RuntimeException("The beginning register of the range must be less than 65536");
    }
    if (startReg < 0) {
        throw new RuntimeException("The beginning register of the range cannot be negative");
    }

    if (methodIndex >= 1 << 16) {
        throw new RuntimeException("The method index must be less than 65536");
    }

    this.regCount = (byte)regCount;
    this.startReg = (short)startReg;
    this.methodIndex = (short)methodIndex;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:26,代碼來源:Instruction3rms.java

示例11: Instruction3rc

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public Instruction3rc(Opcode opcode, short regCount, int startReg, Item referencedItem) {
    super(opcode, referencedItem);

    if (regCount >= 1 << 8) {
        throw new RuntimeException("regCount must be less than 256");
    }
    if (regCount < 0) {
        throw new RuntimeException("regCount cannot be negative");
    }

    if (startReg >= 1 << 16) {
        throw new RuntimeException("The beginning register of the range must be less than 65536");
    }
    if (startReg < 0) {
        throw new RuntimeException("The beginning register of the range cannot be negative");
    }

    this.regCount = (byte)regCount;
    this.startReg = (short)startReg;

    checkItem(opcode, referencedItem, regCount);
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:23,代碼來源:Instruction3rc.java

示例12: checkItem

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
private static void checkItem(Opcode opcode, Item item, int regCount) {
    if (opcode == FILLED_NEW_ARRAY_RANGE) {
        //check data for filled-new-array/range opcode
        String type = ((TypeIdItem) item).getTypeDescriptor();
        if (type.charAt(0) != '[') {
            throw new RuntimeException("The type must be an array type");
        }
        if (type.charAt(1) == 'J' || type.charAt(1) == 'D') {
            throw new RuntimeException("The type cannot be an array of longs or doubles");
        }
    } else if (opcode.value >= INVOKE_VIRTUAL_RANGE.value && opcode.value <= INVOKE_INTERFACE_RANGE.value) {
        //check data for invoke-*/range opcodes
        MethodIdItem methodIdItem = (MethodIdItem) item;
        int parameterRegisterCount = methodIdItem.getPrototype().getParameterRegisterCount();
        if (opcode != INVOKE_STATIC_RANGE) {
            parameterRegisterCount++;
        }
        if (parameterRegisterCount != regCount) {
            throw new RuntimeException("regCount does not match the number of arguments of the method");
        }
    }
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:23,代碼來源:Instruction3rc.java

示例13: PackedSwitchDataPseudoInstruction

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
public PackedSwitchDataPseudoInstruction(byte[] buffer, int bufferIndex) {
    super(Opcode.NOP);

    byte opcodeByte = buffer[bufferIndex];
    if (opcodeByte != 0x00) {
        throw new RuntimeException("Invalid opcode byte for a PackedSwitchData pseudo-instruction");
    }
    byte subopcodeByte = buffer[bufferIndex+1];
    if (subopcodeByte != 0x01) {
        throw new RuntimeException("Invalid sub-opcode byte for a PackedSwitchData pseudo-instruction");
    }

    int targetCount = NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 2);
    this.firstKey = NumberUtils.decodeInt(buffer, bufferIndex + 4);
    this.targets = new int[targetCount];

    for (int i = 0; i<targetCount; i++) {
        targets[i] = NumberUtils.decodeInt(buffer, bufferIndex + 8 + 4*i);
    }
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:21,代碼來源:PackedSwitchDataPseudoInstruction.java

示例14: getOpcodeSubtype

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
private static int getOpcodeSubtype(Opcode opcode) {
    if (opcode.isOdexedInstanceQuick()) {
        return 0;
    } else if (opcode.isOdexedInstanceVolatile()) {
        return 1;
    } else if (opcode.isOdexedStaticVolatile()) {
        return 2;
    }
    throw new RuntimeException(String.format("Not an odexed field access opcode: %s", opcode.name));
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:11,代碼來源:OdexedFieldInstructionMapper.java

示例15: getAndCheckDeodexedOpcodeForOdexedOpcode

import org.jf.dexlib.Code.Opcode; //導入依賴的package包/類
static Opcode getAndCheckDeodexedOpcodeForOdexedOpcode(String fieldType, Opcode odexedOpcode) {
    int opcodeType = odexedOpcode.setsRegister()?0:1;
    int opcodeSubType = getOpcodeSubtype(odexedOpcode);
    int typeIndex = getTypeIndex(fieldType.charAt(0));

    Opcode correctOdexedOpcode = opcodeMap[opcodeType][opcodeSubType][0][typeIndex];
    Opcode deodexedOpcode = opcodeMap[opcodeType][opcodeSubType][1][typeIndex];

    if (correctOdexedOpcode != odexedOpcode) {
        throw new ValidationException(String.format("Incorrect field type \"%s\" for %s", fieldType,
                odexedOpcode.name));
    }

    return deodexedOpcode;
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:16,代碼來源:OdexedFieldInstructionMapper.java


注:本文中的org.jf.dexlib.Code.Opcode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。