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

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util#escape() . 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 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 2
Source File: VariableBase.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
Example 3
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 4
Source File: VariableBase.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
Example 5
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 6
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 7
Source File: CallTemplate.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 Stylesheet stylesheet = classGen.getStylesheet();
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // If there are Params in the stylesheet or WithParams in this call?
    if (stylesheet.hasLocalParams() || hasContents()) {
        _calleeTemplate = getCalleeTemplate();

        // Build the parameter list if the called template is simple named
        if (_calleeTemplate != null) {
            buildParameterList();
        }
        // This is only needed when the called template is not
        // a simple named template.
        else {
            // Push parameter frame
            final int push = cpg.addMethodref(TRANSLET_CLASS,
                                              PUSH_PARAM_FRAME,
                                              PUSH_PARAM_FRAME_SIG);
            il.append(classGen.loadTranslet());
            il.append(new INVOKEVIRTUAL(push));
            translateContents(classGen, methodGen);
        }
    }

    // Generate a valid Java method name
    final String className = stylesheet.getClassName();
    String methodName = Util.escape(_name.toString());

    // Load standard arguments
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());
    il.append(methodGen.loadIterator());
    il.append(methodGen.loadHandler());
    il.append(methodGen.loadCurrentNode());

    // Initialize prefix of method signature
    StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG
        + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG);

    // If calling a simply named template, push actual arguments
    if (_calleeTemplate != null) {
        Vector calleeParams = _calleeTemplate.getParameters();
        int numParams = _parameters.length;

        for (int i = 0; i < numParams; i++) {
            SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
            methodSig.append(OBJECT_SIG);   // append Object to signature

            // Push 'null' if Param to indicate no actual parameter specified
            if (node instanceof Param) {
                il.append(ACONST_NULL);
            }
            else {  // translate WithParam
                node.translate(classGen, methodGen);
            }
        }
    }

    // Complete signature and generate invokevirtual call
    methodSig.append(")V");
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                 methodName,
                                                 methodSig.toString())));

    // Do not need to call Translet.popParamFrame() if we are
    // calling a simple named template.
    if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) {
        // Pop parameter frame
        final int pop = cpg.addMethodref(TRANSLET_CLASS,
                                         POP_PARAM_FRAME,
                                         POP_PARAM_FRAME_SIG);
        il.append(classGen.loadTranslet());
        il.append(new INVOKEVIRTUAL(pop));
    }
}
 
Example 8
Source File: WithParam.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
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 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 11
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 12
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 13
Source File: VariableBase.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
Example 14
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 15
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 16
Source File: VariableBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
Example 17
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 18
Source File: WithParam.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}
 
Example 19
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 20
Source File: WithParam.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the name of the variable or paremeter. Escape all special chars.
 */
public void setName(QName name) {
    _name = name;
    _escapedName = Util.escape(name.getStringRep());
}