com.sun.org.apache.bcel.internal.generic.GETSTATIC Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.generic.GETSTATIC. 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: Text.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #2
Source File: Text.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #3
Source File: Text.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #4
Source File: Text.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #5
Source File: Text.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #6
Source File: Text.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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()));
}
 
Example #7
Source File: Text.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #8
Source File: Text.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #9
Source File: Text.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #10
Source File: Text.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #11
Source File: Text.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #12
Source File: Stylesheet.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #13
Source File: DecimalFormatting.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #14
Source File: Stylesheet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #15
Source File: Stylesheet.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #16
Source File: DecimalFormatting.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #17
Source File: DecimalFormatting.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #18
Source File: Stylesheet.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #19
Source File: Stylesheet.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #20
Source File: DecimalFormatting.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #21
Source File: Stylesheet.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #22
Source File: DecimalFormatting.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #23
Source File: DecimalFormatting.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #24
Source File: DecimalFormatting.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #25
Source File: Stylesheet.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #26
Source File: DecimalFormatting.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #27
Source File: Stylesheet.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #28
Source File: DecimalFormatting.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * 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));
}
 
Example #29
Source File: Stylesheet.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compile the translet's constructor
 */
private void compileConstructor(ClassGenerator classGen, Output output) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final MethodGenerator constructor =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>",
                            _className, il, cpg);

    // Call the constructor in the AbstractTranslet superclass
    il.append(classGen.loadTranslet());
    il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 "<init>", "()V")));

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMES_ARRAY_FIELD,
                                            NAMES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMES_INDEX,
                                           NAMES_INDEX_SIG)));

    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_URIS_ARRAY_FIELD,
                                            URIS_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           URIS_INDEX,
                                           URIS_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_TYPES_ARRAY_FIELD,
                                            TYPES_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TYPES_INDEX,
                                           TYPES_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new GETSTATIC(cpg.addFieldref(_className,
                                            STATIC_NAMESPACE_ARRAY_FIELD,
                                            NAMESPACE_INDEX_SIG)));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           NAMESPACE_INDEX,
                                           NAMESPACE_INDEX_SIG)));
    constructor.markChunkEnd();

    constructor.markChunkStart();
    il.append(classGen.loadTranslet());
    il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
    il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                           TRANSLET_VERSION_INDEX,
                                           TRANSLET_VERSION_INDEX_SIG)));
    constructor.markChunkEnd();

    if (_hasIdCall) {
        constructor.markChunkStart();
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, Boolean.TRUE));
        il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                               HASIDCALL_INDEX,
                                               HASIDCALL_INDEX_SIG)));
        constructor.markChunkEnd();
    }

    // Compile in code to set the output configuration from <xsl:output>
    if (output != null) {
        // Set all the output settings files in the translet
        constructor.markChunkStart();
        output.translate(classGen, constructor);
        constructor.markChunkEnd();
    }

    // Compile default decimal formatting symbols.
    // This is an implicit, nameless xsl:decimal-format top-level element.
    if (_numberFormattingUsed) {
        constructor.markChunkStart();
        DecimalFormatting.translateDefaultDFS(classGen, constructor);
        constructor.markChunkEnd();
    }

    il.append(RETURN);

    classGen.addMethod(constructor);
}
 
Example #30
Source File: DecimalFormatting.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}