当前位置: 首页>>代码示例>>Java>>正文


Java ClassGenerator.addMethod方法代码示例

本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator.addMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ClassGenerator.addMethod方法的具体用法?Java ClassGenerator.addMethod怎么用?Java ClassGenerator.addMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator的用法示例。


在下文中一共展示了ClassGenerator.addMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compileDefault

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
 * Compiles the predicate method
 */
private static void compileDefault(int defaultAction,
                                   ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final XSLTC xsltc = classGen.getParser().getXSLTC();

    // private boolean Translet.stripSpace(int type) - cannot be static
    final MethodGenerator stripSpace =
        new MethodGenerator(ACC_PUBLIC | ACC_FINAL ,
                    com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN,
                    new com.sun.org.apache.bcel.internal.generic.Type[] {
                        Util.getJCRefType(DOM_INTF_SIG),
                        com.sun.org.apache.bcel.internal.generic.Type.INT,
                        com.sun.org.apache.bcel.internal.generic.Type.INT
                    },
                    new String[] { "dom","node","type" },
                    "stripSpace",classGen.getClassName(),il,cpg);

    classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter");

    if (defaultAction == STRIP_SPACE)
        il.append(ICONST_1);
    else
        il.append(ICONST_0);
    il.append(IRETURN);

    classGen.addMethod(stripSpace);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:Whitespace.java

示例2: compileNamedTemplate

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:Mode.java

示例3: compileBuildKeys

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
 * Compile a buildKeys() method into the output class. Note that keys
 * for the input document are created in topLevel(), not in this method.
 * However, we still need this method to create keys for documents loaded
 * via the XPath document() function.
 */
private String compileBuildKeys(ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();

    final com.sun.org.apache.bcel.internal.generic.Type[] argTypes = {
        Util.getJCRefType(DOM_INTF_SIG),
        Util.getJCRefType(NODE_ITERATOR_SIG),
        Util.getJCRefType(TRANSLET_OUTPUT_SIG),
        com.sun.org.apache.bcel.internal.generic.Type.INT
    };

    final String[] argNames = {
        DOCUMENT_PNAME, ITERATOR_PNAME, TRANSLET_OUTPUT_PNAME, "current"
    };

    final InstructionList il = new InstructionList();

    final MethodGenerator buildKeys =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            argTypes, argNames,
                            "buildKeys", _className, il,
                            classGen.getConstantPool());

    buildKeys.addException("com.sun.org.apache.xalan.internal.xsltc.TransletException");

    final Enumeration elements = elements();
    while (elements.hasMoreElements()) {
        // xsl:key
        final Object element = elements.nextElement();
        if (element instanceof Key) {
            final Key key = (Key)element;
            key.translate(classGen, buildKeys);
            _keys.put(key.getName(),key);
        }
    }

    il.append(RETURN);

    // Compute max locals + stack and add method to class
    buildKeys.stripAttributes(true);
    buildKeys.setMaxLocals();
    buildKeys.setMaxStack();
    buildKeys.removeNOPs();

    classGen.addMethod(buildKeys.getMethod());

    return("("+DOM_INTF_SIG+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+"I)V");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:Stylesheet.java

示例4: compileBuildKeys

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
 * Compile a buildKeys() method into the output class. Note that keys
 * for the input document are created in topLevel(), not in this method.
 * However, we still need this method to create keys for documents loaded
 * via the XPath document() function.
 */
private String compileBuildKeys(ClassGenerator classGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();

    final com.sun.org.apache.bcel.internal.generic.Type[] argTypes = {
        Util.getJCRefType(DOM_INTF_SIG),
        Util.getJCRefType(NODE_ITERATOR_SIG),
        Util.getJCRefType(TRANSLET_OUTPUT_SIG),
        com.sun.org.apache.bcel.internal.generic.Type.INT
    };

    final String[] argNames = {
        DOCUMENT_PNAME, ITERATOR_PNAME, TRANSLET_OUTPUT_PNAME, "current"
    };

    final InstructionList il = new InstructionList();

    final MethodGenerator buildKeys =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            argTypes, argNames,
                            "buildKeys", _className, il,
                            classGen.getConstantPool());

    buildKeys.addException("com.sun.org.apache.xalan.internal.xsltc.TransletException");

    final Iterator<SyntaxTreeNode> elements = elements();
    while (elements.hasNext()) {
        // xsl:key
        final SyntaxTreeNode element = elements.next();
        if (element instanceof Key) {
            final Key key = (Key)element;
            key.translate(classGen, buildKeys);
            _keys.put(key.getName(),key);
        }
    }

    il.append(RETURN);

    // Compute max locals + stack and add method to class
    buildKeys.stripAttributes(true);
    buildKeys.setMaxLocals();
    buildKeys.setMaxStack();
    buildKeys.removeNOPs();

    classGen.addMethod(buildKeys.getMethod());

    return("("+DOM_INTF_SIG+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+"I)V");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:Stylesheet.java


注:本文中的com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator.addMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。