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

The following examples show how to use com.sun.org.apache.bcel.internal.generic.IFNULL. 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: ObjectType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #2
Source File: ObjectType.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #3
Source File: ObjectType.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #4
Source File: ObjectType.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #5
Source File: ObjectType.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #6
Source File: ObjectType.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #7
Source File: ObjectType.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #8
Source File: ObjectType.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #9
Source File: ObjectType.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #10
Source File: ObjectType.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #11
Source File: ObjectType.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #12
Source File: Copy.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #13
Source File: Copy.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #14
Source File: Copy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #15
Source File: Copy.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #16
Source File: Copy.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #17
Source File: Copy.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #18
Source File: Copy.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #19
Source File: Copy.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #20
Source File: Copy.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #21
Source File: Copy.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}
 
Example #22
Source File: Copy.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final LocalVariableGen name =
        methodGen.addLocalVariable2("name",
                                    Util.getJCRefType(STRING_SIG),
                                    null);
    final LocalVariableGen length =
        methodGen.addLocalVariable2("length",
                                    Util.getJCRefType("I"),
                                    null);

    // Get the name of the node to copy and save for later
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadCurrentNode());
    il.append(methodGen.loadHandler());
    final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
                                              "shallowCopy",
                                              "("
                                              + NODE_SIG
                                              + TRANSLET_OUTPUT_SIG
                                              + ")" + STRING_SIG);
    il.append(new INVOKEINTERFACE(cpy, 3));
    il.append(DUP);
    name.setStart(il.append(new ASTORE(name.getIndex())));
    final BranchHandle ifBlock1 = il.append(new IFNULL(null));

    // Get the length of the node name and save for later
    il.append(new ALOAD(name.getIndex()));
    final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
    il.append(new INVOKEVIRTUAL(lengthMethod));
    il.append(DUP);
    length.setStart(il.append(new ISTORE(length.getIndex())));

    // Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
    // returns "" for ROOT, so skip attribute sets if length == 0
    final BranchHandle ifBlock4 = il.append(new IFEQ(null));

    // Copy in attribute sets if specified
    if (_useSets != null) {
        // If the parent of this element will result in an element being
        // output then we know that it is safe to copy out the attributes
        final SyntaxTreeNode parent = getParent();
        if ((parent instanceof LiteralElement) ||
            (parent instanceof LiteralElement)) {
            _useSets.translate(classGen, methodGen);
        }
        // If not we have to check to see if the copy will result in an
        // element being output.
        else {
            // check if element; if not skip to translate body
            il.append(new ILOAD(length.getIndex()));
            final BranchHandle ifBlock2 = il.append(new IFEQ(null));
            // length != 0 -> element -> do attribute sets
            _useSets.translate(classGen, methodGen);
            // not an element; root
            ifBlock2.setTarget(il.append(NOP));
        }
    }

    // Instantiate body of xsl:copy
    ifBlock4.setTarget(il.append(NOP));
    translateContents(classGen, methodGen);

    // Call the output handler's endElement() if we copied an element
    // (The DOM.shallowCopy() method calls startElement().)
    length.setEnd(il.append(new ILOAD(length.getIndex())));
    final BranchHandle ifBlock3 = il.append(new IFEQ(null));
    il.append(methodGen.loadHandler());
    name.setEnd(il.append(new ALOAD(name.getIndex())));
    il.append(methodGen.endElement());

    final InstructionHandle end = il.append(NOP);
    ifBlock1.setTarget(end);
    ifBlock3.setTarget(end);
    methodGen.removeLocalVariable(name);
    methodGen.removeLocalVariable(length);
}