/** * Generates code that loads the array that will contain the character * data represented by this Text node, followed by the offset of the * data from the start of the array, and then the length of the data. * * The pre-condition to calling this method is that * canLoadAsArrayOffsetLength() returns true. * @see #canLoadArrayOffsetLength() */ public void loadAsArrayOffsetLength(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // The XSLTC object keeps track of character data // that is to be stored in char arrays. final int offset = xsltc.addCharacterData(_text); final int length = _text.length(); String charDataFieldName = STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1); il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(), charDataFieldName, STATIC_CHAR_DATA_FIELD_SIG))); il.append(new PUSH(cpg, offset)); il.append(new PUSH(cpg, _text.length())); }
/** * Creates the default, nameless, DecimalFormat object in * AbstractTranslet's format_symbols hashtable. * This should be called for every stylesheet, and the entry * may be overridden by later nameless xsl:decimal-format instructions. */ public static void translateDefaultDFS(ClassGenerator classGen, MethodGenerator methodGen) { ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); final int init = cpg.addMethodref(DFS_CLASS, "<init>", "("+LOCALE_SIG+")V"); // Push the format name, which is empty, on the stack // for call to addDecimalFormat() il.append(classGen.loadTranslet()); il.append(new PUSH(cpg, EMPTYSTRING)); // Manufacture a DecimalFormatSymbols on the stack for // call to addDecimalFormat(). Use the US Locale as the // default, as most of its settings are equivalent to // the default settings required of xsl:decimal-format - // except for the NaN and infinity attributes. il.append(new NEW(cpg.addClass(DFS_CLASS))); il.append(DUP); il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init)); int nan = cpg.addMethodref(DFS_CLASS, "setNaN", "(Ljava/lang/String;)V"); il.append(DUP); il.append(new PUSH(cpg, "NaN")); il.append(new INVOKEVIRTUAL(nan)); int inf = cpg.addMethodref(DFS_CLASS, "setInfinity", "(Ljava/lang/String;)V"); il.append(DUP); il.append(new PUSH(cpg, "Infinity")); il.append(new INVOKEVIRTUAL(inf)); final int put = cpg.addMethodref(TRANSLET_CLASS, "addDecimalFormat", "("+STRING_SIG+DFS_SIG+")V"); il.append(new INVOKEVIRTUAL(put)); }