Java 类com.sun.org.apache.bcel.internal.generic.SWITCH 实例源码

项目:OpenJSharp    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:openjdk-jdk10    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:openjdk9    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:infobip-open-jdk-8    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:OLD-OpenJDK8    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
项目:openjdk-icedtea7    文件:Mode.java   
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}