com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerator Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerator. 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: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #2
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #3
Source File: Mode.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #4
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #5
Source File: Mode.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #6
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #7
Source File: Mode.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #8
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #9
Source File: Mode.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #10
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = _parameters.get(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #11
Source File: Mode.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        List<Param> parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #12
Source File: Mode.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #13
Source File: Mode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #14
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #15
Source File: Mode.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #16
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #17
Source File: Mode.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #18
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #19
Source File: Mode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #20
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
Example #21
Source File: Mode.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void compileNamedTemplate(Template template,
                                  ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    String methodName = Util.escape(template.getName().toString());

    int numParams = 0;
    if (template.isSimpleNamedTemplate()) {
        Vector parameters = template.getParameters();
        numParams = parameters.size();
    }

    // Initialize the types and names arrays for the NamedMethodGenerator.
    com.sun.org.apache.bcel.internal.generic.Type[] types =
        new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
    String[] names = new String[4 + numParams];
    types[0] = Util.getJCRefType(DOM_INTF_SIG);
    types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
    types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
    types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
    names[0] = DOCUMENT_PNAME;
    names[1] = ITERATOR_PNAME;
    names[2] = TRANSLET_OUTPUT_PNAME;
    names[3] = NODE_PNAME;

    // For simple named templates, the signature of the generated method
    // is not fixed. It depends on the number of parameters declared in the
    // template.
    for (int i = 4; i < 4 + numParams; i++) {
        types[i] = Util.getJCRefType(OBJECT_SIG);
        names[i] = "param" + String.valueOf(i-4);
    }

    NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                 com.sun.org.apache.bcel.internal.generic.Type.VOID,
                                 types, names, methodName,
                                 getClassName(), il, cpg);

    il.append(template.compile(classGen, methodGen));
    il.append(RETURN);

    classGen.addMethod(methodGen);
}
 
Example #22
Source File: Template.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();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}