Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator#getApplyTemplatesSig()

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator#getApplyTemplatesSig() . 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: Mode.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 2
Source File: Mode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 3
Source File: Mode.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 4
Source File: Mode.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 5
Source File: Mode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 6
Source File: Mode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 7
Source File: Mode.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 8
Source File: Mode.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 9
Source File: Mode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 10
Source File: Mode.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 11
Source File: Mode.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
 
Example 12
Source File: ApplyTemplates.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Translate call-template. A parameter frame is pushed only if
 * some template in the stylesheet uses parameters.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    boolean setStartNodeCalled = false;
    final Stylesheet stylesheet = classGen.getStylesheet();
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int current = methodGen.getLocalIndex("current");

    // check if sorting nodes is required
    final Vector sortObjects = new Vector();
    final Enumeration children = elements();
    while (children.hasMoreElements()) {
        final Object child = children.nextElement();
        if (child instanceof Sort) {
            sortObjects.addElement(child);
        }
    }

    // Push a new parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int pushFrame = cpg.addMethodref(TRANSLET_CLASS,
                                               PUSH_PARAM_FRAME,
                                               PUSH_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(pushFrame));
        // translate with-params
        translateContents(classGen, methodGen);
    }


    il.append(classGen.loadTranslet());

    // The 'select' expression is a result-tree
    if ((_type != null) && (_type instanceof ResultTreeType)) {
        // <xsl:sort> cannot be applied to a result tree - issue warning
        if (sortObjects.size() > 0) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
            getParser().reportError(WARNING, err);
        }
        // Put the result tree (a DOM adapter) on the stack
        _select.translate(classGen, methodGen);
        // Get back the DOM and iterator (not just iterator!!!)
        _type.translateTo(classGen, methodGen, Type.NodeSet);
    }
    else {
        il.append(methodGen.loadDOM());

        // compute node iterator for applyTemplates
        if (sortObjects.size() > 0) {
            Sort.translateSortIterator(classGen, methodGen,
                                       _select, sortObjects);
            int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                         SET_START_NODE,
                                                         "(I)"+
                                                         NODE_ITERATOR_SIG);
            il.append(methodGen.loadCurrentNode());
            il.append(new INVOKEINTERFACE(setStartNode,2));
            setStartNodeCalled = true;
        }
        else {
            if (_select == null)
                Mode.compileGetChildren(classGen, methodGen, current);
            else
                _select.translate(classGen, methodGen);
        }
    }

    if (_select != null && !setStartNodeCalled) {
        _select.startIterator(classGen, methodGen);
    }

    //!!! need to instantiate all needed modes
    final String className = classGen.getStylesheet().getClassName();
    il.append(methodGen.loadHandler());
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int applyTemplates = cpg.addMethodref(className,
                                                _functionName,
                                                applyTemplatesSig);
    il.append(new INVOKEVIRTUAL(applyTemplates));

    // Pop parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int popFrame = cpg.addMethodref(TRANSLET_CLASS,
                                              POP_PARAM_FRAME,
                                              POP_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(popFrame));
    }
}
 
Example 13
Source File: ApplyTemplates.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Translate call-template. A parameter frame is pushed only if
 * some template in the stylesheet uses parameters.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    boolean setStartNodeCalled = false;
    final Stylesheet stylesheet = classGen.getStylesheet();
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int current = methodGen.getLocalIndex("current");

    // check if sorting nodes is required
    final Vector sortObjects = new Vector();
    final Enumeration children = elements();
    while (children.hasMoreElements()) {
        final Object child = children.nextElement();
        if (child instanceof Sort) {
            sortObjects.addElement(child);
        }
    }

    // Push a new parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int pushFrame = cpg.addMethodref(TRANSLET_CLASS,
                                               PUSH_PARAM_FRAME,
                                               PUSH_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(pushFrame));
        // translate with-params
        translateContents(classGen, methodGen);
    }


    il.append(classGen.loadTranslet());

    // The 'select' expression is a result-tree
    if ((_type != null) && (_type instanceof ResultTreeType)) {
        // <xsl:sort> cannot be applied to a result tree - issue warning
        if (sortObjects.size() > 0) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
            getParser().reportError(WARNING, err);
        }
        // Put the result tree (a DOM adapter) on the stack
        _select.translate(classGen, methodGen);
        // Get back the DOM and iterator (not just iterator!!!)
        _type.translateTo(classGen, methodGen, Type.NodeSet);
    }
    else {
        il.append(methodGen.loadDOM());

        // compute node iterator for applyTemplates
        if (sortObjects.size() > 0) {
            Sort.translateSortIterator(classGen, methodGen,
                                       _select, sortObjects);
            int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                         SET_START_NODE,
                                                         "(I)"+
                                                         NODE_ITERATOR_SIG);
            il.append(methodGen.loadCurrentNode());
            il.append(new INVOKEINTERFACE(setStartNode,2));
            setStartNodeCalled = true;
        }
        else {
            if (_select == null)
                Mode.compileGetChildren(classGen, methodGen, current);
            else
                _select.translate(classGen, methodGen);
        }
    }

    if (_select != null && !setStartNodeCalled) {
        _select.startIterator(classGen, methodGen);
    }

    //!!! need to instantiate all needed modes
    final String className = classGen.getStylesheet().getClassName();
    il.append(methodGen.loadHandler());
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int applyTemplates = cpg.addMethodref(className,
                                                _functionName,
                                                applyTemplatesSig);
    il.append(new INVOKEVIRTUAL(applyTemplates));

    // Pop parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int popFrame = cpg.addMethodref(TRANSLET_CLASS,
                                              POP_PARAM_FRAME,
                                              POP_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(popFrame));
    }
}
 
Example 14
Source File: ApplyTemplates.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Translate call-template. A parameter frame is pushed only if
 * some template in the stylesheet uses parameters.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    boolean setStartNodeCalled = false;
    final Stylesheet stylesheet = classGen.getStylesheet();
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int current = methodGen.getLocalIndex("current");

    // check if sorting nodes is required
    final Vector sortObjects = new Vector();
    final Enumeration children = elements();
    while (children.hasMoreElements()) {
        final Object child = children.nextElement();
        if (child instanceof Sort) {
            sortObjects.addElement(child);
        }
    }

    // Push a new parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int pushFrame = cpg.addMethodref(TRANSLET_CLASS,
                                               PUSH_PARAM_FRAME,
                                               PUSH_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(pushFrame));
        // translate with-params
        translateContents(classGen, methodGen);
    }


    il.append(classGen.loadTranslet());

    // The 'select' expression is a result-tree
    if ((_type != null) && (_type instanceof ResultTreeType)) {
        // <xsl:sort> cannot be applied to a result tree - issue warning
        if (sortObjects.size() > 0) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
            getParser().reportError(WARNING, err);
        }
        // Put the result tree (a DOM adapter) on the stack
        _select.translate(classGen, methodGen);
        // Get back the DOM and iterator (not just iterator!!!)
        _type.translateTo(classGen, methodGen, Type.NodeSet);
    }
    else {
        il.append(methodGen.loadDOM());

        // compute node iterator for applyTemplates
        if (sortObjects.size() > 0) {
            Sort.translateSortIterator(classGen, methodGen,
                                       _select, sortObjects);
            int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                         SET_START_NODE,
                                                         "(I)"+
                                                         NODE_ITERATOR_SIG);
            il.append(methodGen.loadCurrentNode());
            il.append(new INVOKEINTERFACE(setStartNode,2));
            setStartNodeCalled = true;
        }
        else {
            if (_select == null)
                Mode.compileGetChildren(classGen, methodGen, current);
            else
                _select.translate(classGen, methodGen);
        }
    }

    if (_select != null && !setStartNodeCalled) {
        _select.startIterator(classGen, methodGen);
    }

    //!!! need to instantiate all needed modes
    final String className = classGen.getStylesheet().getClassName();
    il.append(methodGen.loadHandler());
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int applyTemplates = cpg.addMethodref(className,
                                                _functionName,
                                                applyTemplatesSig);
    il.append(new INVOKEVIRTUAL(applyTemplates));

    // Pop parameter frame
    if (stylesheet.hasLocalParams() || hasContents()) {
        il.append(classGen.loadTranslet());
        final int popFrame = cpg.addMethodref(TRANSLET_CLASS,
                                              POP_PARAM_FRAME,
                                              POP_PARAM_FRAME_SIG);
        il.append(new INVOKEVIRTUAL(popFrame));
    }
}