当前位置: 首页>>代码示例>>Java>>正文


Java Instruction类代码示例

本文整理汇总了Java中org.jf.dexlib2.iface.instruction.Instruction的典型用法代码示例。如果您正苦于以下问题:Java Instruction类的具体用法?Java Instruction怎么用?Java Instruction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Instruction类属于org.jf.dexlib2.iface.instruction包,在下文中一共展示了Instruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: if

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
public LinkedHashMap<String,BundleListing.BundleInfo>read(String className,String memberName) throws Exception {

        if (reader!= null) {
            Method method = (Method) reader.read(className, memberName);
            if (method!= null){
                Iterable<? extends Instruction> instructions = method.getImplementation().getInstructions();
                for (Instruction instruction:instructions){
                    if (instruction instanceof ReferenceInstruction){
                        if (((ReferenceInstruction) instruction).getReferenceType()== 0){
                            StringReference s = (StringReference) ((ReferenceInstruction) instruction).getReference();
                            return BundleListingUtil.parseArray(s.getString(), (LinkedHashMap<String, BundleListing.BundleInfo>) map);
                        }
                    }
                }
            }
        }
        return null;
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:19,代码来源:AtlasFrameworkPropertiesReader.java

示例2: makeInstructionFormatMethodItem

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:InstructionMethodItemFactory.java

示例3: fixInstructions

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private void fixInstructions(@Nonnull MutableMethodImplementation methodImplementation) {
    List<? extends Instruction> instructions = methodImplementation.getInstructions();

    for (int i=0; i<instructions.size(); i++) {
        Instruction instruction = instructions.get(i);

        if (instruction.getOpcode() == Opcode.CONST_STRING) {
            if (stringSection.getItemIndex(
                    (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) {
                methodImplementation.replaceInstruction(i, new BuilderInstruction31c(Opcode.CONST_STRING_JUMBO,
                        ((OneRegisterInstruction)instruction).getRegisterA(),
                        ((ReferenceInstruction)instruction).getReference()));
            }
        }
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:17,代码来源:DexWriter.java

示例4: rewrite

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
@Nonnull @Override public Instruction rewrite(@Nonnull Instruction instruction) {
    if (instruction instanceof ReferenceInstruction) {
        switch (instruction.getOpcode().format) {
            case Format20bc:
                return new RewrittenInstruction20bc((Instruction20bc)instruction);
            case Format21c:
                return new RewrittenInstruction21c((Instruction21c)instruction);
            case Format22c:
                return new RewrittenInstruction22c((Instruction22c)instruction);
            case Format31c:
                return new RewrittenInstruction31c((Instruction31c)instruction);
            case Format35c:
                return new RewrittenInstruction35c((Instruction35c)instruction);
            case Format3rc:
                return new RewrittenInstruction3rc((Instruction3rc)instruction);
            default:
                throw new IllegalArgumentException();
        }
    }
    return instruction;
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:22,代码来源:InstructionRewriter.java

示例5: visitAndset

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private void visitAndset(IRegion root, BitSet live) {
    ((AbstractRegion)root).remove(AFlag.REMOVE_FOR_FLAT);
    if (root.getChildren() != null) {
        List<IRegion> children = root.getChildren();
        for (int i = children.size() - 1; i >= 0; i--) {
            visitAndset(children.get(i), live);
        }
    }

    if (root instanceof Region) {
        InsnNode node = ((Region) root).getInsn();
        Instruction insn = node.getInstruction().getInstruction();
        if (insn != null) {
            if (insn.getOpcode().setsRegister()) {
                int registernum = ((OneRegisterInstruction) insn).getRegisterA();
                live.clear(registernum);
                if (insn.getOpcode().setsWideRegister())
                    live.clear(registernum + 1);
            }
            LiveVarVisitor.setUse(insn, live);
        }
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:24,代码来源:TraceLiveVisitor.java

示例6: doSimplify

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private void doSimplify(IRegion region, BlockNode newBlock, MulRegion newRegion) {
        if (region instanceof Region) {
            MethodLocation location = ((Region) region).getInsn().getInstruction();
            if (!((Region) region).contains(AFlag.REMOVE_FOR_FLAT)) {
                Instruction insn = location.getInstruction();
                if (insn != null) {
//                    System.out.println(insn.getOpcode().name);
                    newRegion.addChild(region);
//                    newBlock.getInstructions().add(((Region) region).getInsn().getInstruction());
                }
            } else {
                if (!remover.contains(location))
                    remover.add(location);
            }
        }

        newBlock.mergeinto(region.getBlock());

        if (region.getChildren() != null) {
            for (IRegion child : region.getChildren()) {
                doSimplify(child, newBlock, newRegion);
            }
        }
    }
 
开发者ID:CvvT,项目名称:andbg,代码行数:25,代码来源:TraceLiveVisitor.java

示例7: visitAndset

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private void visitAndset(IRegion root, BitSet live) {
    //clear flag
    ((AbstractRegion)root).remove(AFlag.REMOVE_FOR_FLAT);
    if (root.getChildren() != null) {
        List<IRegion> children = root.getChildren();
        for (int i = children.size() - 1; i >= 0; i--) {
            visitAndset(children.get(i), live);
        }
    }

    if (root instanceof Region) {
        InsnNode node = ((Region) root).getInsn();
        Instruction insn = node.getInstruction().getInstruction();
        if (insn != null) {
            if (insn.getOpcode().setsRegister()) {
                int registernum = ((OneRegisterInstruction) insn).getRegisterA();
                live.clear(registernum);
                if (insn.getOpcode().setsWideRegister())
                    live.clear(registernum + 1);
            }
            LiveVarVisitor.setUse(insn, live);
        }
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:25,代码来源:MarkFlattenVisitor.java

示例8: analyze

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private void analyze(@Nonnull DexBackedMethodImplementation implementation) {
    cyclomaticComplexity = calculateComplexity(implementation);
    registerCount = implementation.getRegisterCount();
    tryCatchCount = implementation.getTryBlocks().size();
    debugItemCount = Utils.makeCollection(implementation.getDebugItems()).size();

    for (Instruction instruction : implementation.getInstructions()) {
        instructionCount++;
        Opcode op = instruction.getOpcode();
        opCounts.adjustOrPutValue(op, 1, 1);

        if (instruction instanceof ReferenceInstruction) {
            ReferenceInstruction refInstr = (ReferenceInstruction) instruction;
            switch (op.referenceType) {
                case ReferenceType.METHOD:
                    MethodReference methodRef = (MethodReference) refInstr.getReference();
                    if (fullMethodSignatures) {
                        apiCounts.adjustOrPutValue(methodRef, 1, 1);
                    } else {
                        ShortMethodReference shortMethodRef = new ShortMethodReference(methodRef);
                        apiCounts.adjustOrPutValue(shortMethodRef, 1, 1);
                    }
                    break;
                case ReferenceType.FIELD:
                    FieldReference fieldRef = (FieldReference) refInstr.getReference();
                    fieldReferenceCounts.adjustOrPutValue(fieldRef, 1, 1);
                    break;
                case ReferenceType.STRING:
                    StringReference stringRef = (StringReference) refInstr.getReference();
                    stringReferenceCounts.adjustOrPutValue(stringRef, 1, 1);
                    break;
            }
        }
    }
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:36,代码来源:DexMethod.java

示例9: equalsInstruction

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
/**
 * 比较method重的tryBlock块
 *
 * @param a
 * @param b
 * @return
 */
private static boolean equalsInstruction(List<Instruction> a, List<Instruction> b) {
    if (a.size() != b.size()) {
        return false;
    }
    Instruction at, bt;
    for (int i = 0; i < a.size(); i++) {
        at = a.get(i);
        bt = b.get(i);
        if (!at.getOpcode().equals(bt.getOpcode()) || !(at.getCodeUnits() == bt.getCodeUnits())) {
            return false;
        }
    }
    return true;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:DexCompareUtils.java

示例10: reMethodImpl

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
@Override
protected MethodImplementation reMethodImpl(MethodImplementation methodImplementation) {
    if (methodImplementation == null){
        return null;
    }
    Iterable<? extends Instruction> instructions = methodImplementation.getInstructions();
    Iterable<? extends DebugItem> debugItems = methodImplementation.getDebugItems();
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = methodImplementation.getTryBlocks();
    return new ImmutableMethodImplementation(methodImplementation.getRegisterCount(), reInstructions(instructions), reTryCatchBlock(methodImplementation.getTryBlocks()), reDebugItem(methodImplementation.getDebugItems()));

}
 
开发者ID:alibaba,项目名称:atlas,代码行数:12,代码来源:MethodImplReIClassDef.java

示例11: findSwitchPayload

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
public Instruction findSwitchPayload(int targetOffset, Opcode type) {
    int targetIndex;
    try {
        targetIndex = instructionOffsetMap.getInstructionIndexAtCodeOffset(targetOffset);
    } catch (InvalidInstructionOffset ex) {
        throw new InvalidSwitchPayload(targetOffset);
    }

    //TODO: does dalvik let you pad with multiple nops?
    //TODO: does dalvik let a switch instruction point to a non-payload instruction?

    Instruction instruction = instructions.get(targetIndex);
    if (instruction.getOpcode() != type) {
        // maybe it's pointing to a NOP padding instruction. Look at the next instruction
        if (instruction.getOpcode() == Opcode.NOP) {
            targetIndex += 1;
            if (targetIndex < instructions.size()) {
                instruction = instructions.get(targetIndex);
                if (instruction.getOpcode() == type) {
                    return instruction;
                }
            }
        }
        throw new InvalidSwitchPayload(targetOffset);
    } else {
        return instruction;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:29,代码来源:MethodDefinition.java

示例12: findPayloadOffset

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
public int findPayloadOffset(int targetOffset, Opcode type) {
    int targetIndex;
    try {
        targetIndex = instructionOffsetMap.getInstructionIndexAtCodeOffset(targetOffset);
    } catch (InvalidInstructionOffset ex) {
        throw new InvalidSwitchPayload(targetOffset);
    }

    //TODO: does dalvik let you pad with multiple nops?
    //TODO: does dalvik let a switch instruction point to a non-payload instruction?

    Instruction instruction = instructions.get(targetIndex);
    if (instruction.getOpcode() != type) {
        // maybe it's pointing to a NOP padding instruction. Look at the next instruction
        if (instruction.getOpcode() == Opcode.NOP) {
            targetIndex += 1;
            if (targetIndex < instructions.size()) {
                instruction = instructions.get(targetIndex);
                if (instruction.getOpcode() == type) {
                    return instructionOffsetMap.getInstructionCodeOffset(targetIndex);
                }
            }
        }
        throw new InvalidSwitchPayload(targetOffset);
    } else {
        return targetOffset;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:29,代码来源:MethodDefinition.java

示例13: needsAnalyzed

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
private boolean needsAnalyzed() {
    for (Instruction instruction : methodImpl.getInstructions()) {
        if (instruction.getOpcode().odexOnly()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:9,代码来源:MethodDefinition.java

示例14: ImmutableMethodImplementation

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
public ImmutableMethodImplementation(int registerCount,
                                     @Nullable Iterable<? extends Instruction> instructions,
                                     @Nullable List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks,
                                     @Nullable Iterable<? extends DebugItem> debugItems) {
    this.registerCount = registerCount;
    this.instructions = ImmutableInstruction.immutableListOf(instructions);
    this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks);
    this.debugItems = ImmutableDebugItem.immutableListOf(debugItems);
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:10,代码来源:ImmutableMethodImplementation.java

示例15: getInstructions

import org.jf.dexlib2.iface.instruction.Instruction; //导入依赖的package包/类
@Nullable @Override public Iterable<? extends Instruction> getInstructions(@Nonnull PoolMethod method) {
    MethodImplementation impl = method.getImplementation();
    if (impl != null) {
        return impl.getInstructions();
    }
    return null;
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:8,代码来源:ClassPool.java


注:本文中的org.jf.dexlib2.iface.instruction.Instruction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。