• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCallSiteType

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
MethodType getCallSiteType(final FunctionNode functionNode) {
    final Type[] types = paramTypeMap.get(functionNode.getId());
    if (types == null) {
        return null;
    }

    MethodType mt = MethodType.methodType(returnTypeMap.get(functionNode.getId()).getTypeClass());
    if (needsCallee) {
        mt = mt.appendParameterTypes(ScriptFunction.class);
    }

    mt = mt.appendParameterTypes(Object.class); //this

    for (final Type type : types) {
        if (type == null) {
            return null; // not all parameter information is supplied
        }
        mt = mt.appendParameterTypes(type.getTypeClass());
    }

    return mt;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TypeMap.java


示例2: dynamicGet

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
/**
 * Generate dynamic getter. Pop scope from stack. Push result
 *
 * @param valueType type of the value to set
 * @param name      name of property
 * @param flags     call site flags
 * @param isMethod  should it prefer retrieving methods
 * @param isIndex   is this an index operation?
 * @return the method emitter
 */
MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) {
    debug("dynamic_get", name, valueType, getProgramPoint(flags));

    Type type = valueType;
    if (type.isObject() || type.isBoolean()) {
        type = Type.OBJECT; //promote e.g strings to object generic setter
    }

    popType(Type.SCOPE);
    method.visitInvokeDynamicInsn(dynGetOperation(isMethod, isIndex) + ':' + NameCodec.encode(name),
            Type.getMethodDescriptor(type, Type.OBJECT), LINKERBOOTSTRAP, flags);

    pushType(type);
    convert(valueType); //most probably a nop

    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:MethodEmitter.java


示例3: enterReturnNode

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!reachable) {
        return false;
    }

    final Expression returnExpr = returnNode.getExpression();
    final Type returnExprType;
    if(returnExpr != null) {
        returnExprType = visitExpressionOnEmptyStack(returnExpr).type;
    } else {
        assertTypeStackIsEmpty();
        returnExprType = Type.UNDEFINED;
    }
    returnType = Type.widestReturnType(returnType, returnExprType);
    doesNotContinueSequentially();
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:LocalVariableTypesCalculator.java


示例4: evaluate

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
@Override
protected void evaluate() {
    final Expression lhs = assignNode.lhs();
    final Expression rhs = assignNode.rhs();
    final Type widestOperationType = assignNode.getWidestOperationType();
    final TypeBounds bounds = new TypeBounds(assignNode.getType(), widestOperationType);
    new OptimisticOperation(assignNode, bounds) {
        @Override
        void loadStack() {
            final boolean forceConversionSeparation;
            if (isValid(getProgramPoint()) || widestOperationType == Type.NUMBER) {
                forceConversionSeparation = false;
            } else {
                final Type operandType = Type.widest(booleanToInt(objectToNumber(lhs.getType())), booleanToInt(objectToNumber(rhs.getType())));
                forceConversionSeparation = operandType.narrowerThan(widestOperationType);
            }
            loadBinaryOperands(lhs, rhs, bounds, true, forceConversionSeparation);
        }
        @Override
        void consumeStack() {
            op(this);
        }
    }.emit(getOptimisticIgnoreCountForSelfModifyingExpression(lhs));
    method.convert(assignNode.getType());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:CodeGenerator.java


示例5: computeElementType

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
private static Type computeElementType(final Expression[] value) {
    Type widestElementType = Type.INT;

    for (final Expression elem : value) {
        if (elem == null) {
            widestElementType = widestElementType.widest(Type.OBJECT); //no way to represent undefined as number
            break;
        }

        final Type type = elem.getType().isUnknown() ? Type.OBJECT : elem.getType();
        if (type.isBoolean()) {
            //TODO fix this with explicit boolean types
            widestElementType = widestElementType.widest(Type.OBJECT);
            break;
        }

        widestElementType = widestElementType.widest(type);
        if (widestElementType.isObject()) {
            break;
        }
    }
    return widestElementType;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:LiteralNode.java


示例6: getDynamicSignature

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
/**
 * Helper function to generate a function signature based on stack contents
 * and argument count and return type
 *
 * @param returnType return type
 * @param argCount   argument count
 *
 * @return function signature for stack contents
 */
private String getDynamicSignature(final Type returnType, final int argCount) {
    final Type[]         paramTypes = new Type[argCount];

    int pos = 0;
    for (int i = argCount - 1; i >= 0; i--) {
        Type pt = stack.peek(pos++);
        // "erase" specific ScriptObject subtype info - except for NativeArray.
        // NativeArray is used for array/List/Deque conversion for Java calls.
        if (ScriptObject.class.isAssignableFrom(pt.getTypeClass()) &&
            !NativeArray.class.isAssignableFrom(pt.getTypeClass())) {
            pt = Type.SCRIPT_OBJECT;
        }
        paramTypes[i] = pt;
    }
    final String descriptor = Type.getMethodDescriptor(returnType, paramTypes);
    for (int i = 0; i < argCount; i++) {
        popType(paramTypes[argCount - i - 1]);
    }

    return descriptor;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:MethodEmitter.java


示例7: requestRecompile

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
boolean requestRecompile(final RewriteException e) {
    final Type retType            = e.getReturnType();
    final Type previousFailedType = invalidatedProgramPoints.put(e.getProgramPoint(), retType);

    if (previousFailedType != null && !previousFailedType.narrowerThan(retType)) {
        final StackTraceElement[] stack      = e.getStackTrace();
        final String              functionId = stack.length == 0 ?
                data.getName() :
                stack[0].getClassName() + "." + stack[0].getMethodName();

        log.info("RewriteException for an already invalidated program point ", e.getProgramPoint(), " in ", functionId, ". This is okay for a recursive function invocation, but a bug otherwise.");

        return false;
    }

    SwitchPoint.invalidateAll(new SwitchPoint[] { optimisticAssumptions });

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


示例8: enterReturnNode

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!reachable) {
        return false;
    }

    final Expression returnExpr = returnNode.getExpression();
    final Type returnExprType;
    if(returnExpr != null) {
        returnExpr.accept(this);
        returnExprType = getType(returnExpr);
    } else {
        returnExprType = Type.UNDEFINED;
    }
    returnType = Type.widestReturnType(returnType, returnExprType);
    doesNotContinueSequentially();
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LocalVariableTypesCalculator.java


示例9: ensureInt

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
@SuppressWarnings("unused")
private static int ensureInt(final double arg, final int programPoint) {
    if (JSType.isStrictlyRepresentableAsInt(arg)) {
        return (int)arg;
    }
    throw new UnwarrantedOptimismException(arg, programPoint, Type.NUMBER);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:OptimisticReturnFilters.java


示例10: OptimisticOperation

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
OptimisticOperation(final Optimistic optimistic, final TypeBounds resultBounds) {
    this.optimistic = optimistic;
    this.expression = (Expression)optimistic;
    this.resultBounds = resultBounds;
    this.isOptimistic = isOptimistic(optimistic) && useOptimisticTypes() &&
            // Operation is only effectively optimistic if its type, after being coerced into the result bounds
            // is narrower than the upper bound.
            resultBounds.within(Type.generic(((Expression)optimistic).getType())).narrowerThan(resultBounds.widest);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CodeGenerator.java


示例11: load

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
/**
 * Push a String constant to the stack
 *
 * @param s value of the String
 *
 * @return the method emitter
 */
MethodEmitter load(final String s) {
    debug("load string", s);

    if (s == null) {
        loadNull();
        return this;
    }

    //NASHORN-142 - split too large string
    final int length = s.length();
    if (length > LARGE_STRING_THRESHOLD) {

        _new(StringBuilder.class);
        dup();
        load(length);
        invoke(constructorNoLookup(StringBuilder.class, int.class));

        for (int n = 0; n < length; n += LARGE_STRING_THRESHOLD) {
            final String part = s.substring(n, Math.min(n + LARGE_STRING_THRESHOLD, length));
            load(part);
            stringBuilderAppend();
        }

        invoke(virtualCallNoLookup(StringBuilder.class, "toString", String.class));

        return this;
    }

    pushType(Type.OBJECT.ldc(method, s));
    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:MethodEmitter.java


示例12: storeIdentWithCatchConversion

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
private void storeIdentWithCatchConversion(final IdentNode identNode, final Type type) {
    // Assignments happening in try/catch blocks need to ensure that they also store a possibly wider typed value
    // that will be live at the exit from the try block
    final LocalVariableConversion conversion = identNode.getLocalVariableConversion();
    final Symbol symbol = identNode.getSymbol();
    if(conversion != null && conversion.isLive()) {
        assert symbol == conversion.getSymbol();
        assert symbol.isBytecodeLocal();
        // Only a single conversion from the target type to the join type is expected.
        assert conversion.getNext() == null;
        assert conversion.getFrom() == type;
        // We must propagate potential type change to the catch block
        final Label catchLabel = catchLabels.peek();
        assert catchLabel != METHOD_BOUNDARY; // ident conversion only exists in try blocks
        assert catchLabel.isReachable();
        final Type joinType = conversion.getTo();
        final Label.Stack catchStack = catchLabel.getStack();
        final int joinSlot = symbol.getSlot(joinType);
        // With nested try/catch blocks (incl. synthetic ones for finally), we can have a supposed conversion for
        // the exception symbol in the nested catch, but it isn't live in the outer catch block, so prevent doing
        // conversions for it. E.g. in "try { try { ... } catch(e) { e = 1; } } catch(e2) { ... }", we must not
        // introduce an I->O conversion on "e = 1" assignment as "e" is not live in "catch(e2)".
        if(catchStack.getUsedSlotsWithLiveTemporaries() > joinSlot) {
            method.dup();
            method.convert(joinType);
            method.store(symbol, joinType);
            catchLabel.getStack().onLocalStore(joinType, joinSlot, true);
            method.canThrow(catchLabel);
            // Store but keep the previous store live too.
            method.store(symbol, type, false);
            return;
        }
    }

    method.store(symbol, type, true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:CodeGenerator.java


示例13: createEmptyGetter

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoint(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ScriptObject.java


示例14: fieldType

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
@SuppressWarnings("fallthrough")
private static Type fieldType(final String desc) {
    switch (desc) {
    case "Z":
    case "B":
    case "C":
    case "S":
    case "I":
        return Type.INT;
    case "F":
        assert false;
    case "D":
        return Type.NUMBER;
    case "J":
        return Type.LONG;
    default:
        assert desc.startsWith("[") || desc.startsWith("L") : desc + " is not an object type";
        switch (desc.charAt(0)) {
        case 'L':
            return Type.OBJECT;
        case '[':
            return Type.typeFor(Array.newInstance(fieldType(desc.substring(1)).getTypeClass(), 0).getClass());
        default:
            assert false;
        }
        return Type.OBJECT;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:MethodEmitter.java


示例15: computePresets

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
static Object computePresets(final Expression[] value, final Type elementType, final int[] postsets) {
    assert !elementType.isUnknown();
    if (elementType.isInteger()) {
        return presetIntArray(value, postsets);
    } else if (elementType.isNumeric()) {
        return presetDoubleArray(value, postsets);
    } else {
        return presetObjectArray(value, postsets);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:LiteralNode.java


示例16: compileTypeSpecialization

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) {
    // We're creating an empty script object for holding local variables. AssignSymbols will populate it with
    // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and
    // CompilationEnvironment#declareLocalSymbol()).

    if (log.isEnabled()) {
        log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType);
    }

    final boolean persistentCache = usePersistentCodeCache() && persist;
    String cacheKey = null;
    if (persistentCache) {
        final TypeMap typeMap = typeMap(actualCallSiteType);
        final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId);
        cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes);
        final CodeInstaller<ScriptEnvironment> newInstaller = getInstallerForNewCode();
        final StoredScript script = newInstaller.loadScript(source, cacheKey);

        if (script != null) {
            Compiler.updateCompilationId(script.getCompilationId());
            return installStoredScript(script, newInstaller);
        }
    }

    final FunctionNode fn = reparse();
    final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope);
    final FunctionNode compiledFn = compiler.compile(fn,
            isSerialized() ? CompilationPhases.COMPILE_ALL_SERIALIZED : CompilationPhases.COMPILE_ALL);

    if (persist && !compiledFn.getFlag(FunctionNode.HAS_APPLY_TO_CALL_SPECIALIZATION)) {
        compiler.persistClassInfo(cacheKey, compiledFn);
    }
    return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:RecompilableScriptFunctionData.java


示例17: toString

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
String toString(final String prefix) {
    final StringBuilder sb = new StringBuilder();

    if (paramTypeMap.isEmpty()) {
        sb.append(prefix).append("\t<empty>");
        return sb.toString();
    }

    for (final Map.Entry<Integer, Type[]> entry : paramTypeMap.entrySet()) {
        final int id = entry.getKey();
        sb.append(prefix).append('\t');
        sb.append("function ").append(id).append('\n');
        sb.append(prefix).append("\t\tparamTypes=");
        if (entry.getValue() == null) {
            sb.append("[]");
        } else {
            sb.append(Arrays.toString(entry.getValue()));
        }
        sb.append('\n');
        sb.append(prefix).append("\t\treturnType=");
        final Type ret = returnTypeMap.get(id);
        sb.append(ret == null ? "N/A" : ret);
        sb.append('\n');
    }

    return sb.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:TypeMap.java


示例18: SharedScopeCall

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param symbol the symbol
 * @param valueType the type of the value
 * @param returnType the return type
 * @param paramTypes the function parameter types
 * @param flags the callsite flags
 */
SharedScopeCall(final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) {
    this.symbol = symbol;
    this.valueType = valueType;
    this.returnType = returnType;
    this.paramTypes = paramTypes;
    assert (flags & CALLSITE_OPTIMISTIC) == 0;
    this.flags = flags;
    // If paramTypes is not null this is a call, otherwise it's just a get.
    this.isCall = paramTypes != null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:SharedScopeCall.java


示例19: emitLocalVariableConversion

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:MethodEmitter.java


示例20: dynamicArrayPopulatorCall

import jdk.nashorn.internal.codegen.types.Type; //导入依赖的package包/类
MethodEmitter dynamicArrayPopulatorCall(final int argCount, final int startIndex) {
    debug("populate_array", "args=", argCount, "startIndex=", startIndex);
    final String signature = getDynamicSignature(Type.OBJECT_ARRAY, argCount);
    method.visitInvokeDynamicInsn("populateArray", signature, POPULATE_ARRAY_BOOTSTRAP, startIndex);
    pushType(Type.OBJECT_ARRAY);
    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:MethodEmitter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TokenPBImpl类代码示例发布时间:2022-05-22
下一篇:
Java Image类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap