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


Java Type.typeFor方法代码示例

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


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

示例1: toTypeWithoutCallee

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static Type[] toTypeWithoutCallee(final MethodType type, final int thisIndex) {
    final int paramCount = type.parameterCount();
    final Type[] t = new Type[paramCount - thisIndex];
    for(int i = thisIndex; i < paramCount; ++i) {
        t[i - thisIndex] = Type.typeFor(type.parameterType(i));
    }
    return t;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:CompiledFunction.java

示例2: matchesCallSite

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
boolean matchesCallSite(final MethodType other, final boolean pickVarArg) {
    if (other.equals(this.callSiteType)) {
        return true;
    }
    final MethodType type  = type();
    final int fnParamCount = getParamCount(type);
    final boolean isVarArg = fnParamCount == Integer.MAX_VALUE;
    if (isVarArg) {
        return pickVarArg;
    }

    final int csParamCount = getParamCount(other);
    final boolean csIsVarArg = csParamCount == Integer.MAX_VALUE;
    final int thisThisIndex = needsCallee() ? 1 : 0; // Index of "this" parameter in this function's type

    final int fnParamCountNoCallee = fnParamCount - thisThisIndex;
    final int minParams = Math.min(csParamCount - 1, fnParamCountNoCallee); // callSiteType always has callee, so subtract 1
    // We must match all incoming parameters, except "this". Starting from 1 to skip "this".
    for(int i = 1; i < minParams; ++i) {
        final Type fnType = Type.typeFor(type.parameterType(i + thisThisIndex));
        final Type csType = csIsVarArg ? Type.OBJECT : Type.typeFor(other.parameterType(i + 1));
        if(!fnType.isEquivalentTo(csType)) {
            return false;
        }
    }

    // Must match any undefined parameters to Object type.
    for(int i = minParams; i < fnParamCountNoCallee; ++i) {
        if(!Type.typeFor(type.parameterType(i + thisThisIndex)).isEquivalentTo(Type.OBJECT)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:CompiledFunction.java

示例3: getStaticSignature

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private String getStaticSignature() {
    if (staticSignature == null) {
        if (paramTypes == null) {
            staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT);
        } else {
            final Type[] params = new Type[paramTypes.length + 2];
            params[0] = Type.typeFor(ScriptObject.class);
            params[1] = Type.INT;
            System.arraycopy(paramTypes, 0, params, 2, paramTypes.length);
            staticSignature = Type.getMethodDescriptor(returnType, params);
        }
    }
    return staticSignature;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:SharedScopeCall.java

示例4: TypeMap

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
 * Constructor
 * @param functionNodeId function node id
 * @param type           method type found at runtime corresponding to parameter guess
 * @param needsCallee    does the function using this type map need a callee
 */
public TypeMap(final int functionNodeId, final MethodType type, final boolean needsCallee) {
    final Type[] types = new Type[type.parameterCount()];
    int pos = 0;
    for (final Class<?> p : type.parameterArray()) {
        types[pos++] = Type.typeFor(p);
    }
    paramTypeMap.put(functionNodeId, types);
    returnTypeMap.put(functionNodeId, Type.typeFor(type.returnType()));

    this.needsCallee = needsCallee;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:TypeMap.java

示例5: getPropertyType

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static Type getPropertyType(final ScriptObject sobj, final String name) {
    final FindProperty find = sobj.findProperty(name, true);
    if (find == null) {
        return null;
    }

    final Property property      = find.getProperty();
    final Class<?> propertyClass = property.getType();
    if (propertyClass == null) {
        // propertyClass == null means its value is Undefined. It is probably not initialized yet, so we won't make
        // a type assumption yet.
        return null;
    } else if (propertyClass.isPrimitive()) {
        return Type.typeFor(propertyClass);
    }

    final ScriptObject owner = find.getOwner();
    if (property.hasGetterFunction(owner)) {
        // Can have side effects, so we can't safely evaluate it; since !propertyClass.isPrimitive(), it's Object.
        return Type.OBJECT;
    }

    // Safely evaluate the property, and return the narrowest type for the actual value (e.g. Type.INT for a boxed
    // integer).
    final Object value = property.needsDeclaration() ? ScriptRuntime.UNDEFINED : property.getObjectValue(owner, owner);
    if (value == ScriptRuntime.UNDEFINED) {
        return null;
    }
    return Type.typeFor(JSType.unboxedFieldType(value));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:TypeEvaluator.java

示例6: initializeInternalFunctionOrSplitParameter

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private Symbol initializeInternalFunctionOrSplitParameter(final CompilerConstants cc, final FunctionNode fn, final Label functionStart, final int slot) {
    final Symbol symbol = fn.getBody().getExistingSymbol(cc.symbolName());
    final Type type = Type.typeFor(cc.type());
    method.initializeMethodParameter(symbol, type, functionStart);
    method.onLocalStore(type, slot);
    return symbol;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:CodeGenerator.java

示例7: matchesCallSite

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
boolean matchesCallSite(final MethodType other, final boolean pickVarArg) {
    if (other.equals(this.callSiteType)) {
        return true;
    }
    final MethodType type  = type();
    final int fnParamCount = getParamCount(type);
    final boolean isVarArg = fnParamCount == Integer.MAX_VALUE;
    if (isVarArg) {
        return pickVarArg;
    }

    final int csParamCount = getParamCount(other);
    final boolean csIsVarArg = csParamCount == Integer.MAX_VALUE;
    final int thisThisIndex = needsCallee() ? 1 : 0; // Index of "this" parameter in this function's type

    final int fnParamCountNoCallee = fnParamCount - thisThisIndex;
    final int minParams = Math.min(csParamCount - 1, fnParamCountNoCallee); // callSiteType always has callee, so subtract 1
    // We must match all incoming parameters, including "this". "this" will usually be Object, but there
    // are exceptions, e.g. when calling functions with primitive "this" in strict mode or through call/apply.
    for(int i = 0; i < minParams; ++i) {
        final Type fnType = Type.typeFor(type.parameterType(i + thisThisIndex));
        final Type csType = csIsVarArg ? Type.OBJECT : Type.typeFor(other.parameterType(i + 1));
        if(!fnType.isEquivalentTo(csType)) {
            return false;
        }
    }

    // Must match any undefined parameters to Object type.
    for(int i = minParams; i < fnParamCountNoCallee; ++i) {
        if(!Type.typeFor(type.parameterType(i + thisThisIndex)).isEquivalentTo(Type.OBJECT)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:CompiledFunction.java

示例8: TypeMap

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
 * Constructor
 * @param functionNodeId function node id
 * @param type           method type found at runtime corresponding to parameter guess
 * @param needsCallee    does the function using this type map need a callee
 */
public TypeMap(final int functionNodeId, final MethodType type, final boolean needsCallee) {
    final Type[] types = new Type[type.parameterCount()];
    int pos = 0;
    for (final Class<?> p : type.parameterArray()) {
        types[pos++] = Type.typeFor(p);
    }

    this.functionNodeId = functionNodeId;
    this.paramTypes = types;
    this.returnType = Type.typeFor(type.returnType());
    this.needsCallee = needsCallee;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TypeMap.java

示例9: getOptimisticType

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getOptimisticType() {
    return Type.typeFor(getElementType());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:ContinuousArrayData.java

示例10: getType

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getType(final Function<Symbol, Type> localVariableTypes) {
    return Type.typeFor(value.getClass());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:LiteralNode.java

示例11: getType

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getType() {
    return Type.typeFor(value.getClass());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:LiteralNode.java


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