String sortRecordClass) final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC(); final String className = xsltc.getHelperClassName(); final int nsorts = sortObjects.size(); final ArrayList dups = new ArrayList(); cpg.addUtf8(var.getEscapedName()), cpg.addUtf8(var.getType().toSignature()), null, cpg.getConstantPool())); dups.add(varRef); il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY, "<init>", "(" + DOM_INTF_SIG il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY, il.append(new CHECKCAST(cpg.addClass(sortRecordClass))); cpg.addFieldref(className, var.getEscapedName(), varType.toSignature()))); cpg.addFieldref(sortRecordClass, var.getEscapedName(), varType.toSignature())));
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]; String name = (String)names.elementAt(i-DTM.NTYPES); String namespace = name.substring(0,name.lastIndexOf(':')); final int type = xsltc.registerNamespace(namespace); 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));
/** * 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(BOOLEAN_CLASS))); il.append(new INVOKEVIRTUAL(cpg.addMethodref(BOOLEAN_CLASS, BOOLEAN_VALUE, BOOLEAN_VALUE_SIG))); }
/** * 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))); }
/** * Casts a reference into a NodeIterator. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSet", "(" + OBJECT_SIG + ")" + NODE_ITERATOR_SIG); il.append(new INVOKESTATIC(index)); // Reset this iterator index = cpg.addInterfaceMethodref(NODE_ITERATOR, RESET, RESET_SIG); il.append(new INVOKEINTERFACE(index, 1)); }
il.append(classGen.loadTranslet()); final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, PUSH_PARAM_FRAME, PUSH_PARAM_FRAME_SIG); il.append(new INVOKEVIRTUAL(pushFrame)); il.append(classGen.loadTranslet()); if (sortObjects.size() > 0) { ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this); getParser().reportError(WARNING, err); Sort.translateSortIterator(classGen, methodGen, _select, sortObjects); int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR, SET_START_NODE, "(I)"+ final int applyTemplates = cpg.addMethodref(className, _functionName, applyTemplatesSig); il.append(new INVOKEVIRTUAL(applyTemplates)); final int popFrame = cpg.addMethodref(TRANSLET_CLASS, POP_PARAM_FRAME, POP_PARAM_FRAME_SIG); il.append(new INVOKEVIRTUAL(popFrame));
int gname = cpg.addInterfaceMethodref(DOM_INTF, "getNodeName", "(I)Ljava/lang/String;"); int cmp = cpg.addMethodref(STRING_CLASS, "equals", "(Ljava/lang/Object;)Z"); il.append(methodGen.loadCurrentNode()); il.append(SWAP); il.append(methodGen.storeCurrentNode()); il.append(methodGen.loadCurrentNode()); final int getType = cpg.addInterfaceMethodref(DOM_INTF, "getExpandedTypeID", "(I)I"); il.append(new INVOKEINTERFACE(gname, 2)); il.append(new INVOKEVIRTUAL(cmp)); _falseList.add(il.append(new IFEQ(null))); final int n = _predicates.size(); for (int i = 0; i < n; i++) { Predicate pred = (Predicate)_predicates.elementAt(i); Expression exp = pred.getExpr(); exp.translateDesynthesized(classGen, methodGen);
/** * Translate the fallback element (if any). */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { if (_fallbacks != null) { int count = _fallbacks.size(); for (int i = 0; i < count; i++) { Fallback fallback = (Fallback)_fallbacks.elementAt(i); fallback.translate(classGen, methodGen); } } // We only go into the else block in forward-compatibility mode, when // the unsupported element has no fallback. else { // If the unsupported element does not have any fallback child, then // at runtime, a runtime error should be raised when the unsupported // element is instantiated. Otherwise, no error is thrown. ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF", "(" + STRING_SIG + "Z)V"); il.append(new PUSH(cpg, getQName().toString())); il.append(new PUSH(cpg, _isExtension)); il.append(new INVOKESTATIC(unsupportedElem)); } } }
il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(methodGen.loadHandler()); il.append(methodGen.loadCurrentNode()); il.append(new INVOKEVIRTUAL(cpg.addMethodref(className, methodName, "(" int numParams = _parameters.size(); NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen; Param param = (Param)_parameters.elementAt(i); param.setLoadInstruction(namedMethodGen.loadParameter(i)); param.setStoreInstruction(namedMethodGen.storeParameter(i));
ClassGenerator classGen, MethodGenerator methodGen) { final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC(); final String className = xsltc.getHelperClassName(); final int nsorts = sortObjects.size(); final ArrayList dups = new ArrayList(); final Sort sort = (Sort) sortObjects.get(j); cpg.addUtf8(var.getEscapedName()), cpg.addUtf8(var.getType().toSignature()), null, cpg.getConstantPool())); dups.add(varRef);
null, null); final String applyTemplatesSig = classGen.getApplyTemplatesSig(); final int applyTemplates = cpg.addMethodref(getClassName(), "applyTemplates", applyTemplatesSig); final int domField = cpg.addFieldref(getClassName(), DOM_FIELD, DOM_INTF_SIG); il.append(new NEW(cpg.addClass(MULTI_DOM_CLASS))); il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, "makeDOMAdapter", "("+DOM_INTF_SIG+")"+ final int init = cpg.addMethodref(MULTI_DOM_CLASS, "<init>", "("+DOM_INTF_SIG+")V"); il.append(new INVOKESPECIAL(init)); final int gitr = cpg.addInterfaceMethodref(DOM_INTF, "getIterator", "()"+NODE_ITERATOR_SIG); final int index = cpg.addMethodref(TRANSLET_CLASS, "transferOutputSettings", "("+OUTPUT_HANDLER_SIG+")V"); il.append(new INVOKEVIRTUAL(index));
Util.getJCRefType(NODE_SIG), null, null); match.setStart(il.append(new ISTORE(match.getIndex()))); il.append(new ILOAD(match.getIndex())); translateKernel(classGen, methodGen); il.append(methodGen.loadCurrentNode()); il.append(methodGen.loadIterator()); index = cpg.addMethodref(MATCHING_ITERATOR, "<init>", "(I" + NODE_ITERATOR_SIG + ")V"); il.append(new ASTORE(stepIteratorTemp.getIndex()))); il.append(new NEW(cpg.addClass(MATCHING_ITERATOR))); il.append(DUP); il.append(new ILOAD(match.getIndex())); stepIteratorTemp.setEnd( il.append(new ALOAD(stepIteratorTemp.getIndex()))); il.append(new INVOKESPECIAL(index)); il.append(methodGen.loadDOM()); il.append(new ILOAD(match.getIndex())); index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG); il.append(new INVOKEINTERFACE(index, 2));
il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, ADD_PARAMETER, ADD_PARAMETER_SIG))); if (className != EMPTYSTRING) { il.append(new CHECKCAST(cpg.addClass(className))); if (_refs.isEmpty()) { // nobody uses the value il.append(_type.POP()); _local = null; classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name), cpg.addUtf8(signature), null, cpg.getConstantPool())); il.append(classGen.loadTranslet()); il.append(DUP); il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, ADD_PARAMETER, ADD_PARAMETER_SIG))); il.append(new CHECKCAST(cpg.addClass(className))); il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(), name, signature)));
if (_refs.isEmpty()) { _ignore = true; il.append(_type.STORE(_local.getIndex())); cpg.addUtf8(name), cpg.addUtf8(signature), null, cpg.getConstantPool())); il.append(classGen.loadTranslet()); il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(), name, signature)));
oldMethCopyInIL.append(new NEW(cpg.addClass(argTypeName))); oldMethCopyInIL.append(InstructionConstants.DUP); oldMethCopyInIL.append(InstructionConstants.DUP); oldMethCopyInIL.append( new INVOKESPECIAL(cpg.addMethodref(argTypeName, "<init>", "()V"))); outlinedMethodRef = oldMethCopyOutIL.append( new INVOKESTATIC(cpg.addMethodref( classGen.getClassName(), outlinedMethodName, outlinedMethodRef = oldMethCopyOutIL.append( new INVOKEVIRTUAL(cpg.addMethodref( classGen.getClassName(), outlinedMethodName, copyAreaCG.addField( new Field(ACC_PUBLIC, copyAreaCPG.addUtf8(copyAreaFieldName), copyAreaCPG.addUtf8(varSignature), null, copyAreaCPG.getConstantPool())); int fieldRef = cpg.addFieldref(argTypeName, copyAreaFieldName, varSignature);
cpg.addUtf8(var.getEscapedName()), cpg.addUtf8(var.getType().toSignature()), null, cpg.getConstantPool())); il = new InstructionList(); matchGen = new MatchGenerator(ACC_PUBLIC | ACC_FINAL, il = methodGen.getInstructionList(); final int index = cpg.addMethodref(_className, "<init>", "(" + TRANSLET_INTF_SIG + DOM_INTF_SIG + NODE_ITERATOR_SIG + ")V"); il.append(new NEW(cpg.addClass(_className))); il.append(DUP); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(new INVOKESPECIAL(index)); il.append(var.loadInstruction()); il.append(new PUTFIELD( cpg.addFieldref(_className, var.getEscapedName(), varType.toSignature())));
Constant[] constants = cp.getConstantPool().getConstantPool(); ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()]; return addString(u8.getBytes()); ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; return addClass(u8.getBytes()); return addNameAndType(u8.getBytes(), u8_2.getBytes()); return addUtf8(((ConstantUtf8)c).getBytes()); return addDouble(((ConstantDouble)c).getBytes()); return addFloat(((ConstantFloat)c).getBytes()); return addLong(((ConstantLong)c).getBytes()); return addInteger(((ConstantInteger)c).getBytes()); return addInterfaceMethodref(class_name, name, signature); return addMethodref(class_name, name, signature); return addFieldref(class_name, name, signature);
/** * Compile the expression - leave boolean expression on stack */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); _base.translate(classGen, methodGen); _token.translate(classGen, methodGen); il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS, "startsWith", "("+STRING_SIG+")Z"))); } }
cpg.addUtf8(var.getEscapedName()), cpg.addUtf8(var.getType().toSignature()), null, cpg.getConstantPool())); final InstructionList il = new InstructionList(); testGen = new TestGenerator(ACC_PUBLIC | ACC_FINAL, org.apache.bcel.generic.Type.BOOLEAN, null, null); final String className = classGen.getClassName(); il.append(filterGen.loadTranslet()); il.append(new CHECKCAST(cpg.addClass(className))); il.append(new GETFIELD(cpg.addFieldref(className, DOM_FIELD, DOM_INTF_SIG))); local.setStart(il.append(new ASTORE(local.getIndex())));
/** * Create a constructor for the new class. Updates the reference to the * collator in the super calls only when the stylesheet specifies a new * language in xsl:sort. */ private static MethodGenerator compileInit(Vector sortObjects, NodeSortRecordGenerator sortRecord, ConstantPoolGen cpg, String className) { final InstructionList il = new InstructionList(); final MethodGenerator init = new MethodGenerator(ACC_PUBLIC, org.apache.bcel.generic.Type.VOID, null, null, "<init>", className, il, cpg); // Call the constructor in the NodeSortRecord superclass il.append(ALOAD_0); il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD, "<init>", "()V"))); il.append(RETURN); return init; }