本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例9: getOptimisticType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getOptimisticType() {
return Type.typeFor(getElementType());
}
示例10: getType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getType(final Function<Symbol, Type> localVariableTypes) {
return Type.typeFor(value.getClass());
}
示例11: getType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
public Type getType() {
return Type.typeFor(value.getClass());
}