Package org.apache.harmony.pack200.bytecode

Examples of org.apache.harmony.pack200.bytecode.OperandManager


                       for (int k = 0; k < n; k++) {
                           long result = codec.decode(in);
                           exceptions[k] = new CPClass(cpBands.getCpClass()[(int) result]);
                       }
                   }
                   methodExceptions[i][j] = new ExceptionsAttribute(exceptions);
                   methodAttributes[i][j].add(methodExceptions[i][j]);
               }
            }
        }
    }
View Full Code Here


                bcEscRefCount);
        bcEscRefSize = decodeBandInt("bc_escrefsize", in, Codec.UNSIGNED5, bcEscRefCount);
        bcEscSize = decodeBandInt("bc_escsize", in, Codec.UNSIGNED5, bcEscCount);
        bcEscByte = decodeBandInt("bc_escbyte", in, Codec.BYTE1, bcEscSize);

        OperandManager operandManager = new OperandManager(bcByte, bcShort,
                bcLocal, bcLabel, bcIntRef, bcFloatRef, bcLongRef, bcDoubleRef,
                bcStringRef, bcClassRef, bcFieldRef, bcMethodRef, bcIMethodRef,
                bcThisField, bcSuperField, bcThisMethod, bcSuperMethod,
                bcInitRef);
        operandManager.setSegment(segment);

        int i = 0;
        ArrayList orderedCodeAttributes = segment.getClassBands().getOrderedCodeAttributes();
        for (int c = 0; c < classCount; c++) {
           int numberOfMethods = methodFlags[c].length;
           for (int m = 0; m < numberOfMethods; m++) {
               long methodFlag = methodFlags[c][m];
               if (!abstractModifier.matches(methodFlag)
                       && !nativeModifier.matches(methodFlag)) {
                   int maxStack = codeMaxStack[i];
                   int maxLocal = codeMaxNALocals[i];
                   if (!staticModifier.matches(methodFlag))
                       maxLocal++; // one for 'this' parameter
                   maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
                   // TODO Move creation of code attribute until after constant
                   // pool resolved
                   operandManager.setCurrentClass(segment.getClassBands().getClassThis()[c]);
                   operandManager.setSuperClass(segment.getClassBands().getClassSuper()[c]);
                   CodeAttribute attr = new CodeAttribute(maxStack, maxLocal,
                           methodByteCodePacked[c][m], segment, operandManager);
                   methodAttributes[c][m].add(attr);
                   // Should I add all the attributes in here?
                 ArrayList currentAttributes = (ArrayList)orderedCodeAttributes.get(i);
View Full Code Here

            18, // ldc 2
            -49, // return 4
    };

    public void testLength() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        MockCodeAttribute attribute = new MockCodeAttribute(3, // maxStack
                2, // maxLocals
                mixedByteArray, // codePacked
                segment, // segment
View Full Code Here

                null, null, null));
        assertEquals(37, attribute.getLength());
    }

    public void testMixedByteCodes() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        CodeAttribute attribute = new CodeAttribute(3, // maxStack
                2, // maxLocals
                mixedByteArray, // codePacked
                segment, // segment
View Full Code Here

                    ((Integer) attribute.byteCodeOffsets.get(index)).intValue());
        }
    }

    public void testSingleByteCodes() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        CodeAttribute attribute = new CodeAttribute(4, // maxStack
                3, // maxLocals
                singleByteArray, // codePacked
                segment, // segment
View Full Code Here

        int[] wideByteCodeArray = new int[wideByteCodes.size()];
        for(int index=0; index < wideByteCodeArray.length; index++) {
            wideByteCodeArray[index] = ((Integer)wideByteCodes.get(index)).intValue();
        }
        OperandManager operandManager = new OperandManager(bcCaseCount, bcCaseValue,
                bcByte, bcShort, bcLocal, bcLabel, bcIntRef, bcFloatRef, bcLongRef,
                bcDoubleRef, bcStringRef, bcClassRef, bcFieldRef, bcMethodRef,
                bcIMethodRef, bcThisField, bcSuperField, bcThisMethod, bcSuperMethod,
                bcInitRef, wideByteCodeArray);
        operandManager.setSegment(segment);

        int i = 0;
        ArrayList orderedCodeAttributes = segment.getClassBands().getOrderedCodeAttributes();

        // Exception table fields
        int[] handlerCount = segment.getClassBands().getCodeHandlerCount();
        int[][] handlerStartPCs = segment.getClassBands().getCodeHandlerStartP();
        int[][] handlerEndPCs = segment.getClassBands().getCodeHandlerEndPO();
        int[][] handlerCatchPCs = segment.getClassBands().getCodeHandlerCatchPO();
        String[][] handlerClassTypes = segment.getClassBands().getCodeHandlerClassRCN();

        for (int c = 0; c < classCount; c++) {
            int numberOfMethods = methodFlags[c].length;
            for (int m = 0; m < numberOfMethods; m++) {
                long methodFlag = methodFlags[c][m];
                if (!abstractModifier.matches(methodFlag)
                        && !nativeModifier.matches(methodFlag)) {
                    int maxStack = codeMaxStack[i];
                    int maxLocal = codeMaxNALocals[i];
                    if (!staticModifier.matches(methodFlag))
                        maxLocal++; // one for 'this' parameter
                    maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
                    operandManager.setCurrentClass(segment.getClassBands()
                            .getClassThis()[c]);
                    operandManager.setSuperClass(segment.getClassBands()
                            .getClassSuper()[c]);
                    List exceptionTable = new ArrayList();
                    if(handlerCount != null) {
                        for (int j = 0; j < handlerCount[i]; j++) {
                            String handlerClass = handlerClassTypes[i][j];
View Full Code Here

            18, // ldc 2
            -49, // return 4
    };

    public void testLength() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        MockCodeAttribute attribute = new MockCodeAttribute(3, // maxStack
                2, // maxLocals
                mixedByteArray, // codePacked
                segment, // segment
View Full Code Here

                null, null, null));
        assertEquals(37, attribute.getLength());
    }

    public void testMixedByteCodes() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        CodeAttribute attribute = new CodeAttribute(3, // maxStack
                2, // maxLocals
                mixedByteArray, // codePacked
                segment, // segment
View Full Code Here

                    ((Integer) attribute.byteCodeOffsets.get(index)).intValue());
        }
    }

    public void testSingleByteCodes() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        CodeAttribute attribute = new CodeAttribute(4, // maxStack
                3, // maxLocals
                singleByteArray, // codePacked
                segment, // segment
View Full Code Here

        .getAttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
            AttributeLayout.CONTEXT_CLASS);
    if (SOURCE_FILE.matches(classBands.getClassFlags()[classNum])) {
      String fileName = fullName.substring(i) + ".java";
      classFile.attributes = new Attribute[] { (Attribute) cp
          .add(new SourceFileAttribute(fileName)) };
    } else {
      classFile.attributes = new Attribute[] {};
    }
    // this/superclass
    ClassFileEntry cfThis = cp.add(new CPClass(fullName));
View Full Code Here

TOP

Related Classes of org.apache.harmony.pack200.bytecode.OperandManager

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.