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


Java CompoundStatement类代码示例

本文整理汇总了Java中sun.tools.tree.CompoundStatement的典型用法代码示例。如果您正苦于以下问题:Java CompoundStatement类的具体用法?Java CompoundStatement怎么用?Java CompoundStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: resolveAnonymousStructure

import sun.tools.tree.CompoundStatement; //导入依赖的package包/类
/**
 * Just before checking an anonymous class, decide its true
 * inheritance, and build its (sole, implicit) constructor.
 */
private void resolveAnonymousStructure(Environment env,
                                       ClassDefinition sup,
                                       Expression args[], Type argTypes[]
                                       ) throws ClassNotFound {

    if (tracing) env.dtEvent("SourceClass.resolveAnonymousStructure: " +
                             this + ", super " + sup);

    // Decide now on the superclass.

    // This check has been removed as part of the fix for 4055017.
    // In the anonymous class created to hold the 'class$' method
    // of an interface, 'superClassId' refers to 'java.lang.Object'.
    /*---------------------*
    if (!(superClass == null && superClassId.getName() == idNull)) {
        throw new CompilerError("superclass "+superClass);
    }
    *---------------------*/

    if (sup.isInterface()) {
        // allow an interface in the "super class" position
        int ni = (interfaces == null) ? 0 : interfaces.length;
        ClassDeclaration i1[] = new ClassDeclaration[1+ni];
        if (ni > 0) {
            System.arraycopy(interfaces, 0, i1, 1, ni);
            if (interfaceIds != null && interfaceIds.length == ni) {
                IdentifierToken id1[] = new IdentifierToken[1+ni];
                System.arraycopy(interfaceIds, 0, id1, 1, ni);
                id1[0] = new IdentifierToken(sup.getName());
            }
        }
        i1[0] = sup.getClassDeclaration();
        interfaces = i1;

        sup = toplevelEnv.getClassDefinition(idJavaLangObject);
    }
    superClass = sup.getClassDeclaration();

    if (hasConstructor()) {
        throw new CompilerError("anonymous constructor");
    }

    // Synthesize an appropriate constructor.
    Type t = Type.tMethod(Type.tVoid, argTypes);
    IdentifierToken names[] = new IdentifierToken[argTypes.length];
    for (int i = 0; i < names.length; i++) {
        names[i] = new IdentifierToken(args[i].getWhere(),
                                       Identifier.lookup("$"+i));
    }
    int outerArg = (sup.isTopLevel() || sup.isLocal()) ? 0 : 1;
    Expression superArgs[] = new Expression[-outerArg + args.length];
    for (int i = outerArg ; i < args.length ; i++) {
        superArgs[-outerArg + i] = new IdentifierExpression(names[i]);
    }
    long where = getWhere();
    Expression superExp;
    if (outerArg == 0) {
        superExp = new SuperExpression(where);
    } else {
        superExp = new SuperExpression(where,
                                       new IdentifierExpression(names[0]));
    }
    Expression superCall = new MethodExpression(where,
                                                superExp, idInit,
                                                superArgs);
    Statement body[] = { new ExpressionStatement(where, superCall) };
    Node code = new CompoundStatement(where, body);
    int mod = M_SYNTHETIC; // ISSUE: make M_PRIVATE, with wrapper?
    env.makeMemberDefinition(env, where, this, null,
                            mod, t, idInit, names, null, code);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:SourceClass.java


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