com.sun.org.apache.bcel.internal.generic.GETFIELD Java Examples
The following examples show how to use
com.sun.org.apache.bcel.internal.generic.GETFIELD.
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: NodeType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #2
Source File: NodeType.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #3
Source File: NodeType.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #4
Source File: NodeType.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #5
Source File: NodeType.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #6
Source File: NodeType.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #7
Source File: NodeType.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #8
Source File: NodeType.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
Example #9
Source File: Number.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void compileDefault(ClassGenerator classGen, MethodGenerator methodGen) { int index; ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); int[] fieldIndexes = getXSLTC().getNumberFieldIndexes(); if (fieldIndexes[_level] == -1) { Field defaultNode = new Field(ACC_PRIVATE, cpg.addUtf8(FieldNames[_level]), cpg.addUtf8(NODE_COUNTER_SIG), null, cpg.getConstantPool()); // Add a new private field to this class classGen.addField(defaultNode); // Get a reference to the newly added field fieldIndexes[_level] = cpg.addFieldref(classGen.getClassName(), FieldNames[_level], NODE_COUNTER_SIG); } // Check if field is initialized (runtime) il.append(classGen.loadTranslet()); il.append(new GETFIELD(fieldIndexes[_level])); final BranchHandle ifBlock1 = il.append(new IFNONNULL(null)); // Create an instance of DefaultNodeCounter index = cpg.addMethodref(ClassNames[_level], "getDefaultNodeCounter", "(" + TRANSLET_INTF_SIG + DOM_INTF_SIG + NODE_ITERATOR_SIG + ")" + NODE_COUNTER_SIG); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(new INVOKESTATIC(index)); il.append(DUP); // Store the node counter in the field il.append(classGen.loadTranslet()); il.append(SWAP); il.append(new PUTFIELD(fieldIndexes[_level])); final BranchHandle ifBlock2 = il.append(new GOTO(null)); // Backpatch conditionals ifBlock1.setTarget(il.append(classGen.loadTranslet())); il.append(new GETFIELD(fieldIndexes[_level])); ifBlock2.setTarget(il.append(NOP)); }
Example #10
Source File: ResultTreeType.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Expects a result tree on the stack and pushes a node-set (iterator). * Note that the produced iterator is an iterator for the DOM that * contains the result tree, and not the DOM that is currently in use. * This conversion here will therefore not directly work with elements * such as <xsl:apply-templates> and <xsl:for-each> without the DOM * parameter/variable being updates as well. * * @param classGen A BCEL class generator * @param methodGen A BCEL method generator * @param type An instance of NodeSetType (any) * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Put an extra copy of the result tree (DOM) on the stack il.append(DUP); // DOM adapters containing a result tree are not initialised with // translet-type to DOM-type mapping. This must be done now for // XPath expressions and patterns to work for the iterator we create. il.append(classGen.loadTranslet()); // get names array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMES_INDEX, NAMES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get uris array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, URIS_INDEX, URIS_INDEX_SIG))); il.append(classGen.loadTranslet()); // get types array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, TYPES_INDEX, TYPES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get namespaces array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMESPACE_INDEX, NAMESPACE_INDEX_SIG))); // Pass the type mappings to the DOM adapter final int mapping = cpg.addInterfaceMethodref(DOM_INTF, "setupMapping", "(["+STRING_SIG+ "["+STRING_SIG+ "[I" + "["+STRING_SIG+")V"); il.append(new INVOKEINTERFACE(mapping, 5)); il.append(DUP); // Create an iterator for the root node of the DOM adapter final int iter = cpg.addInterfaceMethodref(DOM_INTF, "getIterator", "()"+NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(iter, 1)); }
Example #11
Source File: StepPattern.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void translateGeneralContext(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); int iteratorIndex = 0; BranchHandle ifBlock = null; LocalVariableGen iter, node, node2; final String iteratorName = getNextFieldName(); // Store node on the stack into a local variable node = methodGen.addLocalVariable("step_pattern_tmp1", Util.getJCRefType(NODE_SIG), null, null); node.setStart(il.append(new ISTORE(node.getIndex()))); // Create a new local to store the iterator iter = methodGen.addLocalVariable("step_pattern_tmp2", Util.getJCRefType(NODE_ITERATOR_SIG), null, null); // Add a new private field if this is the main class if (!classGen.isExternal()) { final Field iterator = new Field(ACC_PRIVATE, cpg.addUtf8(iteratorName), cpg.addUtf8(NODE_ITERATOR_SIG), null, cpg.getConstantPool()); classGen.addField(iterator); iteratorIndex = cpg.addFieldref(classGen.getClassName(), iteratorName, NODE_ITERATOR_SIG); il.append(classGen.loadTranslet()); il.append(new GETFIELD(iteratorIndex)); il.append(DUP); iter.setStart(il.append(new ASTORE(iter.getIndex()))); ifBlock = il.append(new IFNONNULL(null)); il.append(classGen.loadTranslet()); } // Compile the step created at type checking time _step.translate(classGen, methodGen); InstructionHandle iterStore = il.append(new ASTORE(iter.getIndex())); // If in the main class update the field too if (!classGen.isExternal()) { il.append(new ALOAD(iter.getIndex())); il.append(new PUTFIELD(iteratorIndex)); ifBlock.setTarget(il.append(NOP)); } else { // If class is not external, start of range for iter variable was // set above iter.setStart(iterStore); } // Get the parent of the node on the stack il.append(methodGen.loadDOM()); il.append(new ILOAD(node.getIndex())); int index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG); il.append(new INVOKEINTERFACE(index, 2)); // Initialize the iterator with the parent il.append(new ALOAD(iter.getIndex())); il.append(SWAP); il.append(methodGen.setStartNode()); /* * Inline loop: * * int node2; * while ((node2 = iter.next()) != NodeIterator.END * && node2 < node); * return node2 == node; */ BranchHandle skipNext; InstructionHandle begin, next; node2 = methodGen.addLocalVariable("step_pattern_tmp3", Util.getJCRefType(NODE_SIG), null, null); skipNext = il.append(new GOTO(null)); next = il.append(new ALOAD(iter.getIndex())); node2.setStart(next); begin = il.append(methodGen.nextNode()); il.append(DUP); il.append(new ISTORE(node2.getIndex())); _falseList.add(il.append(new IFLT(null))); // NodeIterator.END il.append(new ILOAD(node2.getIndex())); il.append(new ILOAD(node.getIndex())); iter.setEnd(il.append(new IF_ICMPLT(next))); node2.setEnd(il.append(new ILOAD(node2.getIndex()))); node.setEnd(il.append(new ILOAD(node.getIndex()))); _falseList.add(il.append(new IF_ICMPNE(null))); skipNext.setTarget(begin); }
Example #12
Source File: Predicate.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Translate a predicate expression. This translation pushes * two references on the stack: a reference to a newly created * filter object and a reference to the predicate's closure. */ public void translateFilter(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Compile auxiliary class for filter compileFilter(classGen, methodGen); // Create new instance of filter il.append(new NEW(cpg.addClass(_className))); il.append(DUP); il.append(new INVOKESPECIAL(cpg.addMethodref(_className, "<init>", "()V"))); // Initialize closure variables final int length = (_closureVars == null) ? 0 : _closureVars.size(); for (int i = 0; i < length; i++) { VariableRefBase varRef = (VariableRefBase) _closureVars.get(i); VariableBase var = varRef.getVariable(); Type varType = var.getType(); il.append(DUP); // Find nearest closure implemented as an inner class Closure variableClosure = _parentClosure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } // Use getfield if in an inner class if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), var.getEscapedName(), varType.toSignature()))); } else { // Use a load of instruction if in translet class il.append(var.loadInstruction()); } // Store variable in new closure il.append(new PUTFIELD( cpg.addFieldref(_className, var.getEscapedName(), varType.toSignature()))); } }
Example #13
Source File: DocumentCall.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Translates the document() function call to a call to LoadDocument()'s * static method document(). */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final int ac = argumentCount(); final int domField = cpg.addFieldref(classGen.getClassName(), DOM_FIELD, DOM_INTF_SIG); String docParamList = null; if (ac == 1) { // documentF(Object,String,AbstractTranslet,DOM) docParamList = "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG +")"+NODE_ITERATOR_SIG; } else { //ac == 2; ac < 1 or as >2 was tested in typeChec() // documentF(Object,DTMAxisIterator,String,AbstractTranslet,DOM) docParamList = "("+OBJECT_SIG+NODE_ITERATOR_SIG+STRING_SIG +TRANSLET_SIG+DOM_INTF_SIG+")"+NODE_ITERATOR_SIG; } final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS, "documentF", docParamList); // The URI can be either a node-set or something else cast to a string _arg1.translate(classGen, methodGen); if (_arg1Type == Type.NodeSet) { _arg1.startIterator(classGen, methodGen); } if (ac == 2) { //_arg2 == null was tested in typeChec() _arg2.translate(classGen, methodGen); _arg2.startIterator(classGen, methodGen); } // Feck the rest of the parameters on the stack il.append(new PUSH(cpg, getStylesheet().getSystemId())); il.append(classGen.loadTranslet()); il.append(DUP); il.append(new GETFIELD(domField)); il.append(new INVOKESTATIC(docIdx)); }
Example #14
Source File: VariableRef.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Fall-through for variables that are implemented as methods if (_type.implementedAsMethod()) return; final String name = _variable.getEscapedName(); final String signature = _type.toSignature(); if (_variable.isLocal()) { if (classGen.isExternal()) { Closure variableClosure = _closure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), name, signature))); } else { il.append(_variable.loadInstruction()); } } else { il.append(_variable.loadInstruction()); } } else { final String className = classGen.getClassName(); il.append(classGen.loadTranslet()); if (classGen.isExternal()) { il.append(new CHECKCAST(cpg.addClass(className))); } il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); } if (_variable.getType() instanceof NodeSetType) { // The method cloneIterator() also does resetting final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, "cloneIterator", "()" + NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(clone, 1)); } }
Example #15
Source File: Number.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * This method compiles code that is common to matchesFrom() and * matchesCount() in the auxillary class. */ private void compileLocals(NodeCounterGenerator nodeCounterGen, MatchGenerator matchGen, InstructionList il) { int field; LocalVariableGen local; ConstantPoolGen cpg = nodeCounterGen.getConstantPool(); // Get NodeCounter._iterator and store locally local = matchGen.addLocalVariable("iterator", Util.getJCRefType(NODE_ITERATOR_SIG), null, null); field = cpg.addFieldref(NODE_COUNTER, "_iterator", ITERATOR_FIELD_SIG); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); local.setStart(il.append(new ASTORE(local.getIndex()))); matchGen.setIteratorIndex(local.getIndex()); // Get NodeCounter._translet and store locally local = matchGen.addLocalVariable("translet", Util.getJCRefType(TRANSLET_SIG), null, null); field = cpg.addFieldref(NODE_COUNTER, "_translet", "Lcom/sun/org/apache/xalan/internal/xsltc/Translet;"); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); il.append(new CHECKCAST(cpg.addClass(TRANSLET_CLASS))); local.setStart(il.append(new ASTORE(local.getIndex()))); nodeCounterGen.setTransletIndex(local.getIndex()); // Get NodeCounter._document and store locally local = matchGen.addLocalVariable("document", Util.getJCRefType(DOM_INTF_SIG), null, null); field = cpg.addFieldref(_className, "_document", DOM_INTF_SIG); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); // Make sure we have the correct DOM type on the stack!!! local.setStart(il.append(new ASTORE(local.getIndex()))); matchGen.setDomIndex(local.getIndex()); }
Example #16
Source File: VariableRef.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Fall-through for variables that are implemented as methods if (_type.implementedAsMethod()) return; final String name = _variable.getEscapedName(); final String signature = _type.toSignature(); if (_variable.isLocal()) { if (classGen.isExternal()) { Closure variableClosure = _closure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), name, signature))); } else { il.append(_variable.loadInstruction()); } } else { il.append(_variable.loadInstruction()); } } else { final String className = classGen.getClassName(); il.append(classGen.loadTranslet()); if (classGen.isExternal()) { il.append(new CHECKCAST(cpg.addClass(className))); } il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); } if (_variable.getType() instanceof NodeSetType) { // The method cloneIterator() also does resetting final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, "cloneIterator", "()" + NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(clone, 1)); } }
Example #17
Source File: ResultTreeType.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Expects a result tree on the stack and pushes a node-set (iterator). * Note that the produced iterator is an iterator for the DOM that * contains the result tree, and not the DOM that is currently in use. * This conversion here will therefore not directly work with elements * such as <xsl:apply-templates> and <xsl:for-each> without the DOM * parameter/variable being updates as well. * * @param classGen A BCEL class generator * @param methodGen A BCEL method generator * @param type An instance of NodeSetType (any) * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Put an extra copy of the result tree (DOM) on the stack il.append(DUP); // DOM adapters containing a result tree are not initialised with // translet-type to DOM-type mapping. This must be done now for // XPath expressions and patterns to work for the iterator we create. il.append(classGen.loadTranslet()); // get names array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMES_INDEX, NAMES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get uris array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, URIS_INDEX, URIS_INDEX_SIG))); il.append(classGen.loadTranslet()); // get types array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, TYPES_INDEX, TYPES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get namespaces array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMESPACE_INDEX, NAMESPACE_INDEX_SIG))); // Pass the type mappings to the DOM adapter final int mapping = cpg.addInterfaceMethodref(DOM_INTF, "setupMapping", "(["+STRING_SIG+ "["+STRING_SIG+ "[I" + "["+STRING_SIG+")V"); il.append(new INVOKEINTERFACE(mapping, 5)); il.append(DUP); // Create an iterator for the root node of the DOM adapter final int iter = cpg.addInterfaceMethodref(DOM_INTF, "getIterator", "()"+NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(iter, 1)); }
Example #18
Source File: ParameterRef.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); /* * To fix bug 24518 related to setting parameters of the form * {namespaceuri}localName, which will get mapped to an instance * variable in the class. */ final String name = BasisLibrary.mapQNameToJavaName (_name.toString()); final String signature = _type.toSignature(); if (_variable.isLocal()) { if (classGen.isExternal()) { Closure variableClosure = _closure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), name, signature))); } else { il.append(_variable.loadInstruction()); } } else { il.append(_variable.loadInstruction()); } } else { final String className = classGen.getClassName(); il.append(classGen.loadTranslet()); if (classGen.isExternal()) { il.append(new CHECKCAST(cpg.addClass(className))); } il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); } if (_variable.getType() instanceof NodeSetType) { // The method cloneIterator() also does resetting final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, "cloneIterator", "()" + NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(clone, 1)); } }
Example #19
Source File: ProcessingInstruction.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); if (!_isLiteral) { // if the ncname is an AVT, then the ncname has to be checked at runtime if it is a valid ncname LocalVariableGen nameValue = methodGen.addLocalVariable2("nameValue", Util.getJCRefType(STRING_SIG), null); // store the name into a variable first so _name.translate only needs to be called once _name.translate(classGen, methodGen); nameValue.setStart(il.append(new ASTORE(nameValue.getIndex()))); il.append(new ALOAD(nameValue.getIndex())); // call checkNCName if the name is an AVT final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkNCName", "(" +STRING_SIG +")V"); il.append(new INVOKESTATIC(check)); // Save the current handler base on the stack il.append(methodGen.loadHandler()); il.append(DUP); // first arg to "attributes" call // load name value again nameValue.setEnd(il.append(new ALOAD(nameValue.getIndex()))); } else { // Save the current handler base on the stack il.append(methodGen.loadHandler()); il.append(DUP); // first arg to "attributes" call // Push attribute name _name.translate(classGen, methodGen);// 2nd arg } il.append(classGen.loadTranslet()); il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, "stringValueHandler", STRING_VALUE_HANDLER_SIG))); il.append(DUP); il.append(methodGen.storeHandler()); // translate contents with substituted handler translateContents(classGen, methodGen); // get String out of the handler il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER, "getValueOfPI", "()" + STRING_SIG))); // call "processingInstruction" final int processingInstruction = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "processingInstruction", "(" + STRING_SIG + STRING_SIG + ")V"); il.append(new INVOKEINTERFACE(processingInstruction, 3)); // Restore old handler base from stack il.append(methodGen.storeHandler()); }
Example #20
Source File: Predicate.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Translate a predicate expression. This translation pushes * two references on the stack: a reference to a newly created * filter object and a reference to the predicate's closure. */ public void translateFilter(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Compile auxiliary class for filter compileFilter(classGen, methodGen); // Create new instance of filter il.append(new NEW(cpg.addClass(_className))); il.append(DUP); il.append(new INVOKESPECIAL(cpg.addMethodref(_className, "<init>", "()V"))); // Initialize closure variables final int length = (_closureVars == null) ? 0 : _closureVars.size(); for (int i = 0; i < length; i++) { VariableRefBase varRef = (VariableRefBase) _closureVars.get(i); VariableBase var = varRef.getVariable(); Type varType = var.getType(); il.append(DUP); // Find nearest closure implemented as an inner class Closure variableClosure = _parentClosure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } // Use getfield if in an inner class if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), var.getEscapedName(), varType.toSignature()))); } else { // Use a load of instruction if in translet class il.append(var.loadInstruction()); } // Store variable in new closure il.append(new PUTFIELD( cpg.addFieldref(_className, var.getEscapedName(), varType.toSignature()))); } }
Example #21
Source File: Number.java From Bytecoder with Apache License 2.0 | 4 votes |
private void compileDefault(ClassGenerator classGen, MethodGenerator methodGen) { int index; ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); int[] fieldIndexes = getXSLTC().getNumberFieldIndexes(); if (fieldIndexes[_level] == -1) { Field defaultNode = new Field(ACC_PRIVATE, cpg.addUtf8(FieldNames[_level]), cpg.addUtf8(NODE_COUNTER_SIG), null, cpg.getConstantPool()); // Add a new private field to this class classGen.addField(defaultNode); // Get a reference to the newly added field fieldIndexes[_level] = cpg.addFieldref(classGen.getClassName(), FieldNames[_level], NODE_COUNTER_SIG); } // Check if field is initialized (runtime) il.append(classGen.loadTranslet()); il.append(new GETFIELD(fieldIndexes[_level])); final BranchHandle ifBlock1 = il.append(new IFNONNULL(null)); // Create an instance of DefaultNodeCounter index = cpg.addMethodref(ClassNames[_level], "getDefaultNodeCounter", "(" + TRANSLET_INTF_SIG + DOM_INTF_SIG + NODE_ITERATOR_SIG + ")" + NODE_COUNTER_SIG); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(new INVOKESTATIC(index)); il.append(DUP); // Store the node counter in the field il.append(classGen.loadTranslet()); il.append(SWAP); il.append(new PUTFIELD(fieldIndexes[_level])); final BranchHandle ifBlock2 = il.append(new GOTO(null)); // Backpatch conditionals ifBlock1.setTarget(il.append(classGen.loadTranslet())); il.append(new GETFIELD(fieldIndexes[_level])); ifBlock2.setTarget(il.append(NOP)); }
Example #22
Source File: Number.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * This method compiles code that is common to matchesFrom() and * matchesCount() in the auxillary class. */ private void compileLocals(NodeCounterGenerator nodeCounterGen, MatchGenerator matchGen, InstructionList il) { int field; LocalVariableGen local; ConstantPoolGen cpg = nodeCounterGen.getConstantPool(); // Get NodeCounter._iterator and store locally local = matchGen.addLocalVariable("iterator", Util.getJCRefType(NODE_ITERATOR_SIG), null, null); field = cpg.addFieldref(NODE_COUNTER, "_iterator", ITERATOR_FIELD_SIG); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); local.setStart(il.append(new ASTORE(local.getIndex()))); matchGen.setIteratorIndex(local.getIndex()); // Get NodeCounter._translet and store locally local = matchGen.addLocalVariable("translet", Util.getJCRefType(TRANSLET_SIG), null, null); field = cpg.addFieldref(NODE_COUNTER, "_translet", "Lcom/sun/org/apache/xalan/internal/xsltc/Translet;"); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); il.append(new CHECKCAST(cpg.addClass(TRANSLET_CLASS))); local.setStart(il.append(new ASTORE(local.getIndex()))); nodeCounterGen.setTransletIndex(local.getIndex()); // Get NodeCounter._document and store locally local = matchGen.addLocalVariable("document", Util.getJCRefType(DOM_INTF_SIG), null, null); field = cpg.addFieldref(_className, "_document", DOM_INTF_SIG); il.append(ALOAD_0); // 'this' pointer on stack il.append(new GETFIELD(field)); // Make sure we have the correct DOM type on the stack!!! local.setStart(il.append(new ASTORE(local.getIndex()))); matchGen.setDomIndex(local.getIndex()); }
Example #23
Source File: Number.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void compileDefault(ClassGenerator classGen, MethodGenerator methodGen) { int index; ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); int[] fieldIndexes = getXSLTC().getNumberFieldIndexes(); if (fieldIndexes[_level] == -1) { Field defaultNode = new Field(ACC_PRIVATE, cpg.addUtf8(FieldNames[_level]), cpg.addUtf8(NODE_COUNTER_SIG), null, cpg.getConstantPool()); // Add a new private field to this class classGen.addField(defaultNode); // Get a reference to the newly added field fieldIndexes[_level] = cpg.addFieldref(classGen.getClassName(), FieldNames[_level], NODE_COUNTER_SIG); } // Check if field is initialized (runtime) il.append(classGen.loadTranslet()); il.append(new GETFIELD(fieldIndexes[_level])); final BranchHandle ifBlock1 = il.append(new IFNONNULL(null)); // Create an instance of DefaultNodeCounter index = cpg.addMethodref(ClassNames[_level], "getDefaultNodeCounter", "(" + TRANSLET_INTF_SIG + DOM_INTF_SIG + NODE_ITERATOR_SIG + ")" + NODE_COUNTER_SIG); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(new INVOKESTATIC(index)); il.append(DUP); // Store the node counter in the field il.append(classGen.loadTranslet()); il.append(SWAP); il.append(new PUTFIELD(fieldIndexes[_level])); final BranchHandle ifBlock2 = il.append(new GOTO(null)); // Backpatch conditionals ifBlock1.setTarget(il.append(classGen.loadTranslet())); il.append(new GETFIELD(fieldIndexes[_level])); ifBlock2.setTarget(il.append(NOP)); }
Example #24
Source File: DocumentCall.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Translates the document() function call to a call to LoadDocument()'s * static method document(). */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final int ac = argumentCount(); final int domField = cpg.addFieldref(classGen.getClassName(), DOM_FIELD, DOM_INTF_SIG); String docParamList = null; if (ac == 1) { // documentF(Object,String,AbstractTranslet,DOM) docParamList = "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG +")"+NODE_ITERATOR_SIG; } else { //ac == 2; ac < 1 or as >2 was tested in typeChec() // documentF(Object,DTMAxisIterator,String,AbstractTranslet,DOM) docParamList = "("+OBJECT_SIG+NODE_ITERATOR_SIG+STRING_SIG +TRANSLET_SIG+DOM_INTF_SIG+")"+NODE_ITERATOR_SIG; } final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS, "documentF", docParamList); // The URI can be either a node-set or something else cast to a string _arg1.translate(classGen, methodGen); if (_arg1Type == Type.NodeSet) { _arg1.startIterator(classGen, methodGen); } if (ac == 2) { //_arg2 == null was tested in typeChec() _arg2.translate(classGen, methodGen); _arg2.startIterator(classGen, methodGen); } // Feck the rest of the parameters on the stack il.append(new PUSH(cpg, getStylesheet().getSystemId())); il.append(classGen.loadTranslet()); il.append(DUP); il.append(new GETFIELD(domField)); il.append(new INVOKESTATIC(docIdx)); }
Example #25
Source File: ParameterRef.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); /* * To fix bug 24518 related to setting parameters of the form * {namespaceuri}localName, which will get mapped to an instance * variable in the class. */ final String name = BasisLibrary.mapQNameToJavaName (_name.toString()); final String signature = _type.toSignature(); if (_variable.isLocal()) { if (classGen.isExternal()) { Closure variableClosure = _closure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), name, signature))); } else { il.append(_variable.loadInstruction()); } } else { il.append(_variable.loadInstruction()); } } else { final String className = classGen.getClassName(); il.append(classGen.loadTranslet()); if (classGen.isExternal()) { il.append(new CHECKCAST(cpg.addClass(className))); } il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); } if (_variable.getType() instanceof NodeSetType) { // The method cloneIterator() also does resetting final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, "cloneIterator", "()" + NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(clone, 1)); } }
Example #26
Source File: StepPattern.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private void translateGeneralContext(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); int iteratorIndex = 0; BranchHandle ifBlock = null; LocalVariableGen iter, node, node2; final String iteratorName = getNextFieldName(); // Store node on the stack into a local variable node = methodGen.addLocalVariable("step_pattern_tmp1", Util.getJCRefType(NODE_SIG), null, null); node.setStart(il.append(new ISTORE(node.getIndex()))); // Create a new local to store the iterator iter = methodGen.addLocalVariable("step_pattern_tmp2", Util.getJCRefType(NODE_ITERATOR_SIG), null, null); // Add a new private field if this is the main class if (!classGen.isExternal()) { final Field iterator = new Field(ACC_PRIVATE, cpg.addUtf8(iteratorName), cpg.addUtf8(NODE_ITERATOR_SIG), null, cpg.getConstantPool()); classGen.addField(iterator); iteratorIndex = cpg.addFieldref(classGen.getClassName(), iteratorName, NODE_ITERATOR_SIG); il.append(classGen.loadTranslet()); il.append(new GETFIELD(iteratorIndex)); il.append(DUP); iter.setStart(il.append(new ASTORE(iter.getIndex()))); ifBlock = il.append(new IFNONNULL(null)); il.append(classGen.loadTranslet()); } // Compile the step created at type checking time _step.translate(classGen, methodGen); InstructionHandle iterStore = il.append(new ASTORE(iter.getIndex())); // If in the main class update the field too if (!classGen.isExternal()) { il.append(new ALOAD(iter.getIndex())); il.append(new PUTFIELD(iteratorIndex)); ifBlock.setTarget(il.append(NOP)); } else { // If class is not external, start of range for iter variable was // set above iter.setStart(iterStore); } // Get the parent of the node on the stack il.append(methodGen.loadDOM()); il.append(new ILOAD(node.getIndex())); int index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG); il.append(new INVOKEINTERFACE(index, 2)); // Initialize the iterator with the parent il.append(new ALOAD(iter.getIndex())); il.append(SWAP); il.append(methodGen.setStartNode()); /* * Inline loop: * * int node2; * while ((node2 = iter.next()) != NodeIterator.END * && node2 < node); * return node2 == node; */ BranchHandle skipNext; InstructionHandle begin, next; node2 = methodGen.addLocalVariable("step_pattern_tmp3", Util.getJCRefType(NODE_SIG), null, null); skipNext = il.append(new GOTO(null)); next = il.append(new ALOAD(iter.getIndex())); node2.setStart(next); begin = il.append(methodGen.nextNode()); il.append(DUP); il.append(new ISTORE(node2.getIndex())); _falseList.add(il.append(new IFLT(null))); // NodeIterator.END il.append(new ILOAD(node2.getIndex())); il.append(new ILOAD(node.getIndex())); iter.setEnd(il.append(new IF_ICMPLT(next))); node2.setEnd(il.append(new ILOAD(node2.getIndex()))); node.setEnd(il.append(new ILOAD(node.getIndex()))); _falseList.add(il.append(new IF_ICMPNE(null))); skipNext.setTarget(begin); }
Example #27
Source File: ResultTreeType.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Expects a result tree on the stack and pushes a node-set (iterator). * Note that the produced iterator is an iterator for the DOM that * contains the result tree, and not the DOM that is currently in use. * This conversion here will therefore not directly work with elements * such as <xsl:apply-templates> and <xsl:for-each> without the DOM * parameter/variable being updates as well. * * @param classGen A BCEL class generator * @param methodGen A BCEL method generator * @param type An instance of NodeSetType (any) * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Put an extra copy of the result tree (DOM) on the stack il.append(DUP); // DOM adapters containing a result tree are not initialised with // translet-type to DOM-type mapping. This must be done now for // XPath expressions and patterns to work for the iterator we create. il.append(classGen.loadTranslet()); // get names array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMES_INDEX, NAMES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get uris array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, URIS_INDEX, URIS_INDEX_SIG))); il.append(classGen.loadTranslet()); // get types array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, TYPES_INDEX, TYPES_INDEX_SIG))); il.append(classGen.loadTranslet()); // get namespaces array il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, NAMESPACE_INDEX, NAMESPACE_INDEX_SIG))); // Pass the type mappings to the DOM adapter final int mapping = cpg.addInterfaceMethodref(DOM_INTF, "setupMapping", "(["+STRING_SIG+ "["+STRING_SIG+ "[I" + "["+STRING_SIG+")V"); il.append(new INVOKEINTERFACE(mapping, 5)); il.append(DUP); // Create an iterator for the root node of the DOM adapter final int iter = cpg.addInterfaceMethodref(DOM_INTF, "getIterator", "()"+NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(iter, 1)); }
Example #28
Source File: ProcessingInstruction.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); if (!_isLiteral) { // if the ncname is an AVT, then the ncname has to be checked at runtime if it is a valid ncname LocalVariableGen nameValue = methodGen.addLocalVariable2("nameValue", Util.getJCRefType(STRING_SIG), null); // store the name into a variable first so _name.translate only needs to be called once _name.translate(classGen, methodGen); nameValue.setStart(il.append(new ASTORE(nameValue.getIndex()))); il.append(new ALOAD(nameValue.getIndex())); // call checkNCName if the name is an AVT final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkNCName", "(" +STRING_SIG +")V"); il.append(new INVOKESTATIC(check)); // Save the current handler base on the stack il.append(methodGen.loadHandler()); il.append(DUP); // first arg to "attributes" call // load name value again nameValue.setEnd(il.append(new ALOAD(nameValue.getIndex()))); } else { // Save the current handler base on the stack il.append(methodGen.loadHandler()); il.append(DUP); // first arg to "attributes" call // Push attribute name _name.translate(classGen, methodGen);// 2nd arg } il.append(classGen.loadTranslet()); il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, "stringValueHandler", STRING_VALUE_HANDLER_SIG))); il.append(DUP); il.append(methodGen.storeHandler()); // translate contents with substituted handler translateContents(classGen, methodGen); // get String out of the handler il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER, "getValueOfPI", "()" + STRING_SIG))); // call "processingInstruction" final int processingInstruction = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "processingInstruction", "(" + STRING_SIG + STRING_SIG + ")V"); il.append(new INVOKEINTERFACE(processingInstruction, 3)); // Restore old handler base from stack il.append(methodGen.storeHandler()); }
Example #29
Source File: Predicate.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Translate a predicate expression. This translation pushes * two references on the stack: a reference to a newly created * filter object and a reference to the predicate's closure. */ public void translateFilter(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Compile auxiliary class for filter compileFilter(classGen, methodGen); // Create new instance of filter il.append(new NEW(cpg.addClass(_className))); il.append(DUP); il.append(new INVOKESPECIAL(cpg.addMethodref(_className, "<init>", "()V"))); // Initialize closure variables final int length = (_closureVars == null) ? 0 : _closureVars.size(); for (int i = 0; i < length; i++) { VariableRefBase varRef = (VariableRefBase) _closureVars.get(i); VariableBase var = varRef.getVariable(); Type varType = var.getType(); il.append(DUP); // Find nearest closure implemented as an inner class Closure variableClosure = _parentClosure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } // Use getfield if in an inner class if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), var.getEscapedName(), varType.toSignature()))); } else { // Use a load of instruction if in translet class il.append(var.loadInstruction()); } // Store variable in new closure il.append(new PUTFIELD( cpg.addFieldref(_className, var.getEscapedName(), varType.toSignature()))); } }
Example #30
Source File: VariableRef.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Fall-through for variables that are implemented as methods if (_type.implementedAsMethod()) return; final String name = _variable.getEscapedName(); final String signature = _type.toSignature(); if (_variable.isLocal()) { if (classGen.isExternal()) { Closure variableClosure = _closure; while (variableClosure != null) { if (variableClosure.inInnerClass()) break; variableClosure = variableClosure.getParentClosure(); } if (variableClosure != null) { il.append(ALOAD_0); il.append(new GETFIELD( cpg.addFieldref(variableClosure.getInnerClassName(), name, signature))); } else { il.append(_variable.loadInstruction()); } } else { il.append(_variable.loadInstruction()); } } else { final String className = classGen.getClassName(); il.append(classGen.loadTranslet()); if (classGen.isExternal()) { il.append(new CHECKCAST(cpg.addClass(className))); } il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); } if (_variable.getType() instanceof NodeSetType) { // The method cloneIterator() also does resetting final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, "cloneIterator", "()" + NODE_ITERATOR_SIG); il.append(new INVOKEINTERFACE(clone, 1)); } }