Package com.android.dx.rop.cst

Examples of com.android.dx.rop.cst.CstMethodRef


        this.declaringType = declaringType;
        this.returnType = returnType;
        this.name = name;
        this.parameters = parameters;
        this.nat = new CstNat(new CstString(name), new CstString(descriptor(false)));
        this.constant = new CstMethodRef(declaringType.constant, nat);
    }
View Full Code Here


                case CONSTANT_Methodref: {
                    int classIndex = bytes.getUnsignedShort(at + 1);
                    CstType type = (CstType) parse0(classIndex);
                    int natIndex = bytes.getUnsignedShort(at + 3);
                    CstNat nat = (CstNat) parse0(natIndex);
                    cst = new CstMethodRef(type, nat);
                    break;
                }
                case CONSTANT_InterfaceMethodref: {
                    int classIndex = bytes.getUnsignedShort(at + 1);
                    CstType type = (CstType) parse0(classIndex);
View Full Code Here

    }

    ConcreteMethod concrete= new ConcreteMethod(method, classFile, false, false);
    TranslationAdvice advice= DexTranslationAdvice.THE_ONE;
    RopMethod rmeth= Ropper.convert(concrete, advice);
    CstMethodRef meth= new CstMethodRef(method.getDefiningClass(), method.getNat());
    int paramSize= meth.getParameterWordCount(isStatic);
    DalvCode code= RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize);
    DalvCode.AssignIndicesCallback callback= new DalvCode.AssignIndicesCallback()
    {
      public int getIndex(Constant cst)
      {
View Full Code Here

        int sz = methods.size();

        for (int i = 0; i < sz; i++) {
            Method one = methods.get(i);
            try {
                CstMethodRef meth = new CstMethodRef(thisClass, one.getNat());
                int accessFlags = one.getAccessFlags();
                boolean isStatic = AccessFlags.isStatic(accessFlags);
                boolean isPrivate = AccessFlags.isPrivate(accessFlags);
                boolean isNative = AccessFlags.isNative(accessFlags);
                boolean isAbstract = AccessFlags.isAbstract(accessFlags);
                boolean isConstructor = meth.isInstanceInit() ||
                    meth.isClassInit();
                DalvCode code;

                if (isNative || isAbstract) {
                    // There's no code for native or abstract methods.
                    code = null;
                } else {
                    ConcreteMethod concrete =
                        new ConcreteMethod(one, cf,
                                (args.positionInfo != PositionList.NONE),
                                args.localInfo);

                    TranslationAdvice advice;

                    advice = DexTranslationAdvice.THE_ONE;

                    RopMethod rmeth = Ropper.convert(concrete, advice);
                    RopMethod nonOptRmeth = null;
                    int paramSize;

                    paramSize = meth.getParameterWordCount(isStatic);
   
                    String canonicalName
                            = thisClass.getClassType().getDescriptor()
                                + "." + one.getName().getString();

                    if (args.optimize &&
                            OptimizerOptions.shouldOptimize(canonicalName)) {
                        if (DEBUG) {
                            System.err.println("Optimizing " + canonicalName);
                        }

                        nonOptRmeth = rmeth;
                        rmeth = Optimizer.optimize(rmeth,
                                paramSize, isStatic, args.localInfo, advice);

                        if (DEBUG) {
                            OptimizerOptions.compareOptimizerStep(nonOptRmeth,
                                    paramSize, isStatic, args, advice, rmeth);
                        }

                        if (args.statistics) {
                            CodeStatistics.updateRopStatistics(
                                    nonOptRmeth, rmeth);
                        }
                    }

                    LocalVariableInfo locals = null;

                    if (args.localInfo) {
                        locals = LocalVariableExtractor.extract(rmeth);
                    }

                    code = RopTranslator.translate(rmeth, args.positionInfo,
                            locals, paramSize);

                    if (args.statistics && nonOptRmeth != null) {
                        updateDexStatistics(args, rmeth, nonOptRmeth, locals,
                                paramSize, concrete.getCode().size());
                    }
                }

                // Preserve the synchronized flag as its "declared" variant...
                if (AccessFlags.isSynchronized(accessFlags)) {
                    accessFlags |= AccessFlags.ACC_DECLARED_SYNCHRONIZED;

                    /*
                     * ...but only native methods are actually allowed to be
                     * synchronized.
                     */
                    if (!isNative) {
                        accessFlags &= ~AccessFlags.ACC_SYNCHRONIZED;
                    }
                }
               
                if (isConstructor) {
                    accessFlags |= AccessFlags.ACC_CONSTRUCTOR;
                }

                TypeList exceptions = AttributeTranslator.getExceptions(one);
                EncodedMethod mi =
                    new EncodedMethod(meth, accessFlags, code, exceptions);

                if (meth.isInstanceInit() || meth.isClassInit() ||
                    isStatic || isPrivate) {
                    out.addDirectMethod(mi);
                } else {
                    out.addVirtualMethod(mi);
                }
View Full Code Here

             */
            return AnnotationUtils.makeEnclosingClass(enclosingClass);
        }

        return AnnotationUtils.makeEnclosingMethod(
                new CstMethodRef(enclosingClass, nat));
    }
View Full Code Here

  private void processMethod(Method method, DirectClassFile cf, Element classElement, Map<String, ReferenceKind> referencedTypes, boolean skeletonOnly)
  {
    final boolean localInfo= true;
    final int positionInfo= PositionList.LINES;

    CstMethodRef meth= new CstMethodRef(method.getDefiningClass(), method.getNat());

    // Extract flags for this method.
    int accessFlags= method.getAccessFlags();
    boolean isNative= AccessFlags.isNative(accessFlags);
    boolean isStatic= AccessFlags.isStatic(accessFlags);
    boolean isAbstract= AccessFlags.isAbstract(accessFlags);

    // Create XMLVM element for this method
    Element methodElement= new Element("method", NS_XMLVM);
    methodElement.setAttribute("name", method.getName().getString());
    methodElement.setAttribute("signature", method.getNat().getDescriptor().toHuman());// meth.getPrototype().getDescriptor());
    classElement.addContent(methodElement);

    // Set the access flag attributes for this method.
    processAccessFlags(accessFlags, methodElement);

    // Create signature element.
    methodElement.addContent(processSignature(meth, referencedTypes));

    // Create code element.
    Element codeElement= new Element("code", NS_DEX);
    methodElement.addContent(codeElement);

    // Add delegate method information
    addDelegateElement(method, methodElement);

    // For skeleton-only classes we don't generate instructions.
    if (skeletonOnly)
    {
      methodElement.setAttribute("noImplementation", "true");
      return;
    }

    // Native and abstract methods don't have an implementation.
    if (isNative || isAbstract)
    {
      return;
    }

    ConcreteMethod concrete= new ConcreteMethod(method, cf, (positionInfo != PositionList.NONE), localInfo);

    TranslationAdvice advice= DexTranslationAdvice.THE_ONE;

    RopMethod rmeth= Ropper.convert(concrete, advice);
    int paramSize= meth.getParameterWordCount(isStatic);

    String canonicalName= method.getDefiningClass().getClassType().getDescriptor() + "." + method.getName().getString();
    if (LOTS_OF_DEBUG)
    {
      System.out.println("\n\nMethod: " + canonicalName);
    }

    // Optimize
    rmeth= Optimizer.optimize(rmeth, paramSize, isStatic, localInfo, advice);

    LocalVariableInfo locals= null;

    if (localInfo)
    {
      locals= LocalVariableExtractor.extract(rmeth);
    }

    DalvCode code= RopTranslator.translate(rmeth, positionInfo, locals, paramSize);
    DalvCode.AssignIndicesCallback callback= new DalvCode.AssignIndicesCallback()
    {
      public int getIndex(Constant cst)
      {
        // Everything is at index 0!
        return 0;
      }
    };
    code.assignIndices(callback);

    DalvInsnList instructions= code.getInsns();
    codeElement.setAttribute("register-size", String.valueOf(instructions.getRegistersSize()));
    processLocals(instructions.getRegistersSize(), isStatic, parseClassName(cf.getThisClass().getClassType().getClassName()).toString(), meth.getPrototype().getParameterTypes(), codeElement);
    Map<Integer, SwitchData> switchDataBlocks= extractSwitchData(instructions);
    Map<Integer, ArrayData> arrayData= extractArrayData(instructions);
    CatchTable catches= code.getCatches();
    processCatchTable(catches, codeElement);
    Map<Integer, Target> targets= extractTargets(instructions, catches);
View Full Code Here

TOP

Related Classes of com.android.dx.rop.cst.CstMethodRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.