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


Java JCTree.TYPECAST属性代码示例

本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.TYPECAST属性的典型用法代码示例。如果您正苦于以下问题:Java JCTree.TYPECAST属性的具体用法?Java JCTree.TYPECAST怎么用?Java JCTree.TYPECAST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.tools.javac.tree.JCTree的用法示例。


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

示例1: instantiatePolymorphicSignatureInstance

/**
 * Compute a synthetic method type corresponding to the requested polymorphic
 * method signature. The target return type is computed from the immediately
 * enclosing scope surrounding the polymorphic-signature call.
 */
Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site,
                                        Name name,
                                        MethodSymbol spMethod,  // sig. poly. method or null if none
                                        List<Type> argtypes) {
    final Type restype;

    //The return type for a polymorphic signature call is computed from
    //the enclosing tree E, as follows: if E is a cast, then use the
    //target type of the cast expression as a return type; if E is an
    //expression statement, the return type is 'void' - otherwise the
    //return type is simply 'Object'. A correctness check ensures that
    //env.next refers to the lexically enclosing environment in which
    //the polymorphic signature call environment is nested.

    switch (env.next.tree.getTag()) {
        case JCTree.TYPECAST:
            JCTypeCast castTree = (JCTypeCast)env.next.tree;
            restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
                castTree.clazz.type :
                syms.objectType;
            break;
        case JCTree.EXEC:
            JCTree.JCExpressionStatement execTree =
                    (JCTree.JCExpressionStatement)env.next.tree;
            restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
                syms.voidType :
                syms.objectType;
            break;
        default:
            restype = syms.objectType;
    }

    List<Type> paramtypes = Type.map(argtypes, implicitArgType);
    List<Type> exType = spMethod != null ?
        spMethod.getThrownTypes() :
        List.of(syms.throwableType); // make it throw all exceptions

    MethodType mtype = new MethodType(paramtypes,
                                      restype,
                                      exType,
                                      syms.methodClass);
    return mtype;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:48,代码来源:Infer.java


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