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


Java ClassGenerator.containsField方法代码示例

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


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

示例1: translate

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Don't generate code for unreferenced variables
    if (_refs.isEmpty()) {
        _ignore = true;
    }

    // Make sure that a variable instance is only compiled once
    if (_ignore) return;
    _ignore = true;

    final String name = getEscapedName();

    if (isLocal()) {
        // Compile variable value computation
        translateValue(classGen, methodGen);

        // Add a new local variable and store value
        boolean createLocal = _local == null;
        if (createLocal) {
            mapRegister(methodGen);
        }
        InstructionHandle storeInst =
        il.append(_type.STORE(_local.getIndex()));

        // If the local is just being created, mark the store as the start
        // of its live range.  Note that it might have been created by
        // initializeVariables already, which would have set the start of
        // the live range already.
        if (createLocal) {
            _local.setStart(storeInst);
    }
    }
    else {
        String signature = _type.toSignature();

        // Global variables are store in class fields
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC,
                                        cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));

            // Push a reference to "this" for putfield
            il.append(classGen.loadTranslet());
            // Compile variable value computation
            translateValue(classGen, methodGen);
            // Store the variable in the allocated field
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:Variable.java


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