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


Java Type.getKind方法代码示例

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


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

示例1: interfaceParameterIsIntersectionType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:LambdaToMethod.java

示例2: getJvmPrimitiveSignature

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
private String getJvmPrimitiveSignature(Type t) {
    switch (t.getKind()) {
        case VOID:      return SIG_VOID;
        case BOOLEAN:   return SIG_BOOLEAN;
        case BYTE:      return SIG_BYTE;
        case CHAR:      return SIG_CHAR;
        case SHORT:     return SIG_SHORT;
        case INT:       return SIG_INT;
        case LONG:      return SIG_LONG;
        case FLOAT:     return SIG_FLOAT;
        case DOUBLE:    return SIG_DOUBLE;
        default:
            Assert.error("unknown type: should not happen");
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JNIWriter.java

示例3: getDescriptorType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * Find the type of the method descriptor associated to the functional interface.
 * 
 * @param origin functional interface type
 * @return associated method descriptor type or <code>null</code> if the <code>origin</code> is not a functional interface.
 * @since 0.112
 */
public ExecutableType getDescriptorType(DeclaredType origin) {
    Types types = Types.instance(info.impl.getJavacTask().getContext());
    if (types.isFunctionalInterface(((Type)origin).tsym)) {
        Type dt = types.findDescriptorType((Type)origin);
        if (dt != null && dt.getKind() == TypeKind.EXECUTABLE) {
            return (ExecutableType)dt;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TypeUtilities.java

示例4: interfaceParameterIsIntersectionType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:LambdaToMethod.java

示例5: treeToInfo

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
private ExpressionInfo treeToInfo(TreePath tp) {
    if (tp != null) {
        Tree tree = tp.getLeaf();
        if (tree instanceof ExpressionTree) {
            ExpressionInfo ei = new ExpressionInfo();
            ei.tree = (ExpressionTree) tree;
            Type type = pathToType(tp, tree);
            if (type != null) {
                switch (type.getKind()) {
                    case VOID:
                    case NONE:
                    case ERROR:
                    case OTHER:
                        break;
                    case NULL:
                        ei.isNonVoid = true;
                        ei.typeName = OBJECT_TYPE_NAME;
                        break;
                    default: {
                        ei.isNonVoid = true;
                        ei.typeName = varTypeName(type);
                        if (ei.typeName == null) {
                            ei.typeName = OBJECT_TYPE_NAME;
                        }
                        break;
                    }
                }
            }
            return ei;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ExpressionToTypeInfo.java

示例6: createMethod

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@NonNull
protected MethodSpec.Builder createMethod(final Symbol.MethodSymbol ms) throws Exception {
    final String methodName = ms.getSimpleName().toString();
    final MethodSpec.Builder builder = MethodSpec.methodBuilder(methodName);

    builder.addModifiers(Modifier.FINAL, Modifier.PUBLIC);

    // extract annotations of return type / method. copy all, except @Yield & @AfterCall
    mimicMethodAnnotations(builder, ms);

    // extract our own annotations
    final Attribute.Compound yield = findYieldMethodAnnotation(ms);
    final Attribute.Compound after = findAfterMethodAnnotation(ms);

    // extract return type
    final Type returnType = ms.getReturnType();
    final boolean hasReturn = returnType.getKind() != TypeKind.VOID;
    builder.returns(TypeName.get(returnType));

    // extract parameters
    final StringBuilder arguments = mimicParameters(builder, ms);

    // extract throws
    mimicThrows(builder, ms);

    builder.beginControlFlow("if (!$L( $S$L ))", PREDICATE, methodName,
            (arguments.length() == 0 ? "" : ", ") + arguments);

    // generate default return value
    if (hasReturn || null != yield) {
        if (null != yield) builder.addComment("" + yield);
        createYieldPart(builder, returnType, yield);
    } else {
        builder.addStatement("return");
    }

    builder.endControlFlow();

    // generate return
    if (null == after) {
        builder.addStatement((hasReturn ? "return " : "") + "this.inner.$N($L)", methodName, arguments);
    } else {
        afterCalls.set(true);

        if (hasReturn) {
            builder.addStatement("return $L($S, this.inner.$N($L))", AFTERCALL, methodName, methodName, arguments);
        } else {
            builder.addStatement("this.inner.$N($L)", methodName, arguments);
            builder.addStatement("$L($S, null)", AFTERCALL, methodName);
        }
    }

    return builder;
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:55,代码来源:CommonClassGenerator.java

示例7: jniType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@SuppressWarnings("fallthrough")
protected final String jniType(Type t) {
    switch (t.getKind()) {
        case ARRAY: {
            Type ct = ((Type.ArrayType)t).getComponentType();
            switch (ct.getKind()) {
                case BOOLEAN:  return "jbooleanArray";
                case BYTE:     return "jbyteArray";
                case CHAR:     return "jcharArray";
                case SHORT:    return "jshortArray";
                case INT:      return "jintArray";
                case LONG:     return "jlongArray";
                case FLOAT:    return "jfloatArray";
                case DOUBLE:   return "jdoubleArray";
                case ARRAY:
                case DECLARED: return "jobjectArray";
                default: throw new Error(ct.toString());
            }
        }

        case VOID:     return "void";
        case BOOLEAN:  return "jboolean";
        case BYTE:     return "jbyte";
        case CHAR:     return "jchar";
        case SHORT:    return "jshort";
        case INT:      return "jint";
        case LONG:     return "jlong";
        case FLOAT:    return "jfloat";
        case DOUBLE:   return "jdouble";
        case DECLARED: {
            if (t.tsym.type == syms.stringType) {
                return "jstring";
            } else if (types.isAssignable(t, syms.throwableType)) {
                return "jthrowable";
            } else if (types.isAssignable(t, syms.classType)) {
                return "jclass";
            } else {
                return "jobject";
            }
        }
    }

    Assert.check(false, "jni unknown type");
    return null; /* dead code. */
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:JNIWriter.java


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