Package org.apache.harmony.unpack200.bytecode

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


                    ((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


            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();
        int codeAttributeIndex = 0;

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

        boolean allCodeHasFlags = segment.getSegmentHeader().getOptions().hasAllCodeFlags();
        boolean[] codeHasFlags = segment.getClassBands().getCodeHasAttributes();

        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
                    // I believe this has to take wide arguments into account
                    maxLocal += SegmentUtils
                            .countInvokeInterfaceArgs(methodDescr[c][m]);
                    String[] cpClass = segment.getCpBands().getCpClass();
                    operandManager.setCurrentClass(cpClass[segment
                            .getClassBands().getClassThisInts()[c]]);
                    operandManager.setSuperClass(cpClass[segment
                            .getClassBands().getClassSuperInts()[c]]);
                    List exceptionTable = new ArrayList();
                    if (handlerCount != null) {
                        for (int j = 0; j < handlerCount[i]; j++) {
                            int handlerClass = handlerClassTypes[i][j] - 1;
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();
        int codeAttributeIndex = 0;

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

        boolean allCodeHasFlags = segment.getSegmentHeader().getOptions().hasAllCodeFlags();
        boolean[] codeHasFlags = segment.getClassBands().getCodeHasAttributes();

        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
                    // I believe this has to take wide arguments into account
                    maxLocal += SegmentUtils
                            .countInvokeInterfaceArgs(methodDescr[c][m]);
                    String[] cpClass = segment.getCpBands().getCpClass();
                    operandManager.setCurrentClass(cpClass[segment
                            .getClassBands().getClassThisInts()[c]]);
                    operandManager.setSuperClass(cpClass[segment
                            .getClassBands().getClassSuperInts()[c]]);
                    List exceptionTable = new ArrayList();
                    if (handlerCount != null) {
                        for (int j = 0; j < handlerCount[i]; j++) {
                            int handlerClass = handlerClassTypes[i][j] - 1;
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();
        int[][] 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
                    // I believe this has to take wide arguments into account
                    maxLocal += SegmentUtils
                            .countInvokeInterfaceArgs(methodDescr[c][m]);
                    String[] cpClass = segment.getCpBands().getCpClass();
                    operandManager.setCurrentClass(cpClass[segment
                            .getClassBands().getClassThisInts()[c]]);
                    operandManager.setSuperClass(cpClass[segment
                            .getClassBands().getClassSuperInts()[c]]);
                    List exceptionTable = new ArrayList();
                    if (handlerCount != null) {
                        for (int j = 0; j < handlerCount[i]; j++) {
                            int handlerClass = handlerClassTypes[i][j] - 1;
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();
        int[][] 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
                    // I believe this has to take wide arguments into account
                    maxLocal += SegmentUtils
                            .countInvokeInterfaceArgs(methodDescr[c][m]);
                    String[] cpClass = segment.getCpBands().getCpClass();
                    operandManager.setCurrentClass(cpClass[segment.getClassBands()
                            .getClassThisInts()[c]]);
                    operandManager.setSuperClass(cpClass[segment.getClassBands()
                            .getClassSuperInts()[c]]);
                    List exceptionTable = new ArrayList();
                    if (handlerCount != null) {
                        for (int j = 0; j < handlerCount[i]; j++) {
                            int handlerClass = handlerClassTypes[i][j] - 1;
View Full Code Here

        // -1+1=0, so str.substring(0)
        // == str

        // Get the source file attribute
        ArrayList classAttributes = classBands.getClassAttributes()[classNum];
        SourceFileAttribute sourceFileAttribute = null;
        for (int index = 0; index < classAttributes.size(); index++) {
            if (((Attribute) classAttributes.get(index))
                    .isSourceFileAttribute()) {
                sourceFileAttribute = ((SourceFileAttribute) classAttributes
                        .get(index));
            }
        }

        if (sourceFileAttribute == null) {
            // If we don't have a source file attribute yet, we need
            // to infer it from the class.
            AttributeLayout SOURCE_FILE = attrDefinitionBands
                    .getAttributeDefinitionMap().getAttributeLayout(
                            AttributeLayout.ATTRIBUTE_SOURCE_FILE,
                            AttributeLayout.CONTEXT_CLASS);
            if (SOURCE_FILE.matches(classBands.getRawClassFlags()[classNum])) {
                int firstDollar = SegmentUtils.indexOfFirstDollar(fullName);
                String fileName = null;

                if (firstDollar > -1 && (i <= firstDollar)) {
                    fileName = fullName.substring(i, firstDollar) + ".java";
                } else {
                    fileName = fullName.substring(i) + ".java";
                }
                sourceFileAttribute = new SourceFileAttribute(cpBands
                        .cpUTF8Value(fileName, false));
                classFile.attributes = new Attribute[] { (Attribute) cp
                        .add(sourceFileAttribute) };
            } else {
                classFile.attributes = new Attribute[] {};
View Full Code Here

        assertFalse(unequal.equals(equal1));
        assertFalse(unequal.equals(equal2));
    }

    public void testSourceAttribute() {
        SourceFileAttribute sfa1 = new SourceFileAttribute(new CPUTF8(
                new String("Thing.java"), 1)); //$NON-NLS-1$
        SourceFileAttribute sfa2 = new SourceFileAttribute(new CPUTF8(
                new String("Thing.java"), 1)); //$NON-NLS-1$
        SourceFileAttribute sfa3 = new SourceFileAttribute(new CPUTF8(
                new String("OtherThing.java"), 2)); //$NON-NLS-1$
        checkEquality(sfa1, sfa2, "Thing.java", sfa3); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.unpack200.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.