/** * 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())); } }
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init));
final String name = namesArray[i]; staticConst.markChunkStart(); il.append(new GETSTATIC(namesArrayRef)); il.append(new PUSH(cpg, i)); il.append(new PUSH(cpg, name)); final String uri = urisArray[i]; staticConst.markChunkStart(); il.append(new GETSTATIC(urisArrayRef)); il.append(new PUSH(cpg, i)); il.append(new PUSH(cpg, uri)); final int nodeType = typesArray[i]; staticConst.markChunkStart(); il.append(new GETSTATIC(typesArrayRef)); il.append(new PUSH(cpg, i)); il.append(new PUSH(cpg, nodeType)); final String ns = (String)namespaces.elementAt(i); staticConst.markChunkStart(); il.append(new GETSTATIC(namespaceArrayRef)); il.append(new PUSH(cpg, i)); il.append(new PUSH(cpg, ns)); int ancestor = ((Integer) namespaceAncestors.get(i)).intValue(); staticConst.markChunkStart(); il.append(new GETSTATIC(namespaceAncestorsArrayRef)); il.append(new PUSH(cpg, i)); il.append(new PUSH(cpg, ancestor));
replacement = new PUTSTATIC(index); } else { replacement = new GETSTATIC(index);
il.append(DUP); il.append(new PUSH(cpg, getNodeIDForStylesheetNSLookup())); il.append(new GETSTATIC(cpg.addFieldref( transletClassName, STATIC_NS_ANCESTORS_ARRAY_FIELD, NS_ANCESTORS_INDEX_SIG))); il.append(new GETSTATIC(cpg.addFieldref( transletClassName, STATIC_PREFIX_URIS_IDX_ARRAY_FIELD, PREFIX_URIS_IDX_SIG))); il.append(new GETSTATIC(cpg.addFieldref( transletClassName, STATIC_PREFIX_URIS_ARRAY_FIELD,
il.append(new GETSTATIC(cpg.addFieldref(_className, STATIC_NAMES_ARRAY_FIELD, NAMES_INDEX_SIG))); il.append(new GETSTATIC(cpg.addFieldref(_className, STATIC_URIS_ARRAY_FIELD, URIS_INDEX_SIG))); il.append(new GETSTATIC(cpg.addFieldref(_className, STATIC_TYPES_ARRAY_FIELD, TYPES_INDEX_SIG))); il.append(new GETSTATIC(cpg.addFieldref(_className, STATIC_NAMESPACE_ARRAY_FIELD, NAMESPACE_INDEX_SIG)));
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init));
public GETSTATIC createGetStatic( final String class_name, final String name, final Type t ) { return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature())); }
public GETSTATIC createGetStatic(String class_name, String name, Type t) { return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature())); }
/** Create a field instruction. * * @param class_name name of the accessed class * @param name name of the referenced field * @param type type of field * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC * @see Constants */ public FieldInstruction createFieldAccess(String class_name, String name, Type type, short kind) { int index; String signature = type.getSignature(); index = cp.addFieldref(class_name, name, signature); switch(kind) { case Constants.GETFIELD: return new GETFIELD(index); case Constants.PUTFIELD: return new PUTFIELD(index); case Constants.GETSTATIC: return new GETSTATIC(index); case Constants.PUTSTATIC: return new PUTSTATIC(index); default: throw new RuntimeException("Oops: Unknown getfield kind:" + kind); } }
/** Create a field instruction. * * @param class_name name of the accessed class * @param name name of the referenced field * @param type type of field * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC * @see Const */ public FieldInstruction createFieldAccess( final String class_name, final String name, final Type type, final short kind ) { int index; final String signature = type.getSignature(); index = cp.addFieldref(class_name, name, signature); switch (kind) { case Const.GETFIELD: return new GETFIELD(index); case Const.PUTFIELD: return new PUTFIELD(index); case Const.GETSTATIC: return new GETSTATIC(index); case Const.PUTSTATIC: return new PUTSTATIC(index); default: throw new RuntimeException("Oops: Unknown getfield kind:" + kind); } }
/** Create a call to the most popular System.out.println() method. * * @param s the string to print */ public InstructionList createPrintln( final String s ) { final InstructionList il = new InstructionList(); final int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); final int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); il.append(new GETSTATIC(out)); il.append(new PUSH(cp, s)); il.append(new INVOKEVIRTUAL(println)); return il; }
/** Create a call to the most popular System.out.println() method. * * @param s the string to print */ public InstructionList createPrintln(String s) { InstructionList il = new InstructionList(); int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); il.append(new GETSTATIC(out)); il.append(new PUSH(cp, s)); il.append(new INVOKEVIRTUAL(println)); return il; }
/** * 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())); } }
/** * 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())); } }
/** * 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())); } }
public InstructionList createPrintln(final ConstantPoolGen cp, final Instruction instruction) { final InstructionList il = new InstructionList(); final int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); final int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); il.append(new GETSTATIC(out)); il.append(instruction); il.append(new INVOKEVIRTUAL(println)); return il; }
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init));
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init));
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", LOCALE_SIG))); il.append(new INVOKESPECIAL(init));