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


Java ReferenceInstruction类代码示例

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


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

示例1: if

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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: fixInstructions

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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

示例3: rewrite

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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

示例4: jimplify

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
public void jimplify (DexBody body) {
      TwoRegisterInstruction i = (TwoRegisterInstruction)instruction;
      int dest = i.getRegisterA();
      int object = i.getRegisterB();
      FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
      InstanceFieldRef r = Jimple.v().newInstanceFieldRef(body.getRegisterLocal(object),
                                                          getSootFieldRef(f));
      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), r);
      setUnit(assign);
      addTags(assign);
      body.add(assign);
      
if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
      }
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:19,代码来源:IgetInstruction.java

示例5: jimplify

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
public void jimplify (DexBody body) {
      int source = ((OneRegisterInstruction)instruction).getRegisterA();
      FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
      StaticFieldRef instanceField = Jimple.v().newStaticFieldRef(getStaticSootFieldRef(f));
      Local sourceValue = body.getRegisterLocal(source);
      assign = getAssignStmt(body, sourceValue, instanceField);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
      }
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:17,代码来源:SputInstruction.java

示例6: jimplify

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction21c))
          throw new IllegalArgumentException("Expected Instruction21c but got: "+instruction.getClass());

      ReferenceInstruction constClass = (ReferenceInstruction) this.instruction;

      TypeReference tidi = (TypeReference)(constClass.getReference());
      String type = tidi.getType();
      if (type.startsWith("L") && type.endsWith(";"))
        type = type.replaceAll("^L", "").replaceAll(";$", "");

      int dest = ((OneRegisterInstruction) instruction).getRegisterA();
      Constant cst = ClassConstant.v(type);
      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cst);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); //TODO: classtype could be null!
        DalvikTyper.v().setType(assign.getLeftOpBox(), cst.getType(), false);
      }
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:26,代码来源:ConstClassInstruction.java

示例7: jimplify

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
public void jimplify (DexBody body) {
      TwoRegisterInstruction i = (TwoRegisterInstruction)instruction;
      int source = i.getRegisterA();
      int object = i.getRegisterB();
      FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
      InstanceFieldRef instanceField = Jimple.v().newInstanceFieldRef(body.getRegisterLocal(object),
                           getSootFieldRef(f));
      Local sourceValue = body.getRegisterLocal(source);
      assign = getAssignStmt(body, sourceValue, instanceField);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
      }
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:20,代码来源:IputInstruction.java

示例8: isUsedAsFloatingPoint

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
/**
 * Determine if register is used as floating point.
 *
 * Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this)
 * @param isStatic if this method is static
 */
protected boolean isUsedAsFloatingPoint(DexBody body, int register, boolean isStatic) {
    MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference();
    List<? extends CharSequence> paramTypes = item.getParameterTypes();
    List<Integer> regs = getUsedRegistersNums();
    if (paramTypes == null)
        return false;

    for (int i = 0, j = 0; i < regs.size(); i++, j++) {
        if (!isStatic && i == 0) {
            j--;
            continue;
        }

        if (regs.get(i) == register && isFloatLike(DexType.toSoot(paramTypes.get(j).toString())))
            return true;
        if (DexType.isWide(paramTypes.get(j).toString()))
            i++;
    }
    return false;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:27,代码来源:MethodInvocationInstruction.java

示例9: isUsedAsObject

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
/**
 * Determine if register is used as object.
 *
 * Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this)
 * @param isStatic if this method is static
 */
protected boolean isUsedAsObject(DexBody body, int register, boolean isStatic) {
    MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference();
    List<? extends CharSequence> paramTypes = item.getParameterTypes();
    List<Integer> regs = getUsedRegistersNums();
    if (paramTypes == null)
        return false;

    // we call a method on the register
    if (!isStatic && regs.get(0) == register)
        return true;

    // we call a method with register as a reftype paramter
    for (int i = 0, j = 0; i < regs.size(); i++, j++) {
        if (!isStatic && i == 0) {
            j--;
            continue;
        }

        if (regs.get(i) == register && (DexType.toSoot(paramTypes.get(j).toString()) instanceof RefType))
            return true;
        if (DexType.isWide(paramTypes.get(j).toString()))
            i++;
    }
    return false;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:32,代码来源:MethodInvocationInstruction.java

示例10: fixInstructions

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
private void fixInstructions( 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:AndreJCL,项目名称:JCL,代码行数:17,代码来源:DexWriter.java

示例11: rewrite

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
@Override public Instruction rewrite( 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:AndreJCL,项目名称:JCL,代码行数:22,代码来源:InstructionRewriter.java

示例12: fixInstructions

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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:niranjan94,项目名称:show-java,代码行数:17,代码来源:DexWriter.java

示例13: rewrite

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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:niranjan94,项目名称:show-java,代码行数:24,代码来源:InstructionRewriter.java

示例14: analyzeMoveResult

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的package包/类
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex - 1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction) previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference) reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference) reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:20,代码来源:MethodAnalyzer.java

示例15: analyze

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入依赖的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


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