Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator#getParser()
The following examples show how to use
com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator#getParser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Whitespace.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 2
Source File: Whitespace.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 3
Source File: Whitespace.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 4
Source File: Whitespace.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 5
Source File: Whitespace.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 6
Source File: Whitespace.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 7
Source File: Whitespace.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(List<WhitespaceRule> rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = rules.get(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 8
Source File: Whitespace.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 9
Source File: Whitespace.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 10
Source File: Whitespace.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }
Example 11
Source File: Whitespace.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Compiles the predicate method */ private static void compilePredicate(Vector rules, int defaultAction, ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // private boolean Translet.stripSpace(int type) - cannot be static final MethodGenerator stripSpace = new MethodGenerator(ACC_PUBLIC | ACC_FINAL , com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(DOM_INTF_SIG), com.sun.org.apache.bcel.internal.generic.Type.INT, com.sun.org.apache.bcel.internal.generic.Type.INT }, new String[] { "dom","node","type" }, "stripSpace",classGen.getClassName(),il,cpg); classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter"); final int paramDom = stripSpace.getLocalIndex("dom"); final int paramCurrent = stripSpace.getLocalIndex("node"); final int paramType = stripSpace.getLocalIndex("type"); BranchHandle strip[] = new BranchHandle[rules.size()]; BranchHandle preserve[] = new BranchHandle[rules.size()]; int sCount = 0; int pCount = 0; // Traverse all strip/preserve rules for (int i = 0; i<rules.size(); i++) { // Get the next rule in the prioritised list WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i); // Returns the namespace for a node in the DOM final int gns = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)Ljava/lang/String;"); final int strcmp = cpg.addMethodref("java/lang/String", "compareTo", "(Ljava/lang/String;)I"); // Handle elements="ns:*" type rule if (rule.getStrength() == RULE_NAMESPACE) { il.append(new ALOAD(paramDom)); il.append(new ILOAD(paramCurrent)); il.append(new INVOKEINTERFACE(gns,2)); il.append(new PUSH(cpg, rule.getNamespace())); il.append(new INVOKEVIRTUAL(strcmp)); il.append(ICONST_0); if (rule.getAction() == STRIP_SPACE) { strip[sCount++] = il.append(new IF_ICMPEQ(null)); } else { preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } // Handle elements="ns:el" type rule else if (rule.getStrength() == RULE_ELEMENT) { // Create the QName for the element final Parser parser = classGen.getParser(); QName qname; if (rule.getNamespace() != Constants.EMPTYSTRING ) qname = parser.getQName(rule.getNamespace(), null, rule.getElement()); else qname = parser.getQName(rule.getElement()); // Register the element. final int elementType = xsltc.registerElement(qname); il.append(new ILOAD(paramType)); il.append(new PUSH(cpg, elementType)); // Compare current node type with wanted element type if (rule.getAction() == STRIP_SPACE) strip[sCount++] = il.append(new IF_ICMPEQ(null)); else preserve[pCount++] = il.append(new IF_ICMPEQ(null)); } } if (defaultAction == STRIP_SPACE) { compileStripSpace(strip, sCount, il); compilePreserveSpace(preserve, pCount, il); } else { compilePreserveSpace(preserve, pCount, il); compileStripSpace(strip, sCount, il); } classGen.addMethod(stripSpace); }