微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jdk.nashorn.internal.runtime.Undefined的实例源码

项目:Nasapi    文件Mapping.java   
public Object doMethod(String httpMethod,String path,EndpointRequest request,EndpointResponse response) throws NasapiException {
    if (methods.containsKey(httpMethod)) {
        Object result = methods.get(httpMethod).call(this,request,response);
        if (result != null && result instanceof Undefined) {
            return null;
        }
        return result;
    } else if (METHOD_OPTIONS.equals(httpMethod)) {
        // build default options into response...
        response.setStatus(200);
        response.setHeader(HttpHeaders.ALLOW,allowedMethods);
        response.setBody(null);
    } else {
        throw new MethodNotAllowedException("URI '" + path + "' does not support method '" + httpMethod + "'",allowedMethods);
    }
    return null;
}
项目:Openjsharp    文件JavaAdapterServices.java   
/**
 * Given a JS script object,retrieves a function from it by name,binds it to the script object as its "this",and
 * adapts its parameter types,return types,and arity to the specified type and arity. This method is public mainly
 * for implementation reasons,so the adapter classes can invoke it from their constructors that take a Object
 * in its first argument to obtain the method handles for their method implementations.
 * @param obj the script obj
 * @param name the name of the property that contains the function
 * @param type the method type it has to conform to
 * @return the appropriately adapted method handle for invoking the script function,or null if the value of the
 * property is either null or undefined,or "toString" was requested as the name,but the object doesn't directly
 * define it but just inherits it through prototype.
 */
public static MethodHandle getHandle(final Object obj,final String name,final MethodType type) {
    if (! (obj instanceof ScriptObject)) {
        throw typeError("not.an.object",ScriptRuntime.safetoString(obj));
    }

    final ScriptObject sobj = (ScriptObject)obj;
    // Since every JS Object has a toString,we only override "String toString()" it if it's explicitly specified
    if ("toString".equals(name) && !sobj.hasOwnProperty("toString")) {
        return null;
    }

    final Object fnObj = sobj.get(name);
    if (fnObj instanceof ScriptFunction) {
        return bindAndAdaptHandle((ScriptFunction)fnObj,sobj,type);
    } else if(fnObj == null || fnObj instanceof Undefined) {
        return null;
    } else {
        throw typeError("not.a.function",name);
    }
}
项目:Openjsharp    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:openjdk-jdk10    文件MapIterator.java   
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(),Boolean.TRUE,global);
    }

    final LinkedMap.Node node = iterator.next();

    if (node == null) {
        iterator = null;
        return makeResult(Undefined.getUndefined(),global);
    }

    if (iterationKind == IterationKind.KEY_VALUE) {
        final NativeArray array = new NativeArray(new Object[] {node.getKey(),node.getValue()});
        return makeResult(array,Boolean.FALSE,global);
    }

    return makeResult(iterationKind == IterationKind.KEY ? node.getKey() : node.getValue(),global);
}
项目:openjdk-jdk10    文件SetIterator.java   
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(),node.getKey()});
        return makeResult(array,global);
    }

    return makeResult(node.getKey(),global);
}
项目:openjdk-jdk10    文件StringIterator.java   
@Override
protected IteratorResult next(final Object arg) {
    final int index = nextIndex;
    final String string = iteratedString;

    if (string == null || index >= string.length()) {
        // ES6 21.1.5.2.1 step 8
        iteratedString = null;
        return makeResult(Undefined.getUndefined(),global);
    }

    final char first = string.charat(index);
    if (first >= 0xd800 && first <= 0xdbff && index < string.length() - 1) {
        final char second = string.charat(index + 1);
        if (second >= 0xdc00 && second <= 0xdfff) {
            nextIndex += 2;
            return makeResult(String.valueOf(new char[] {first,second}),global);
        }
    }

    nextIndex++;
    return makeResult(String.valueOf(first),global);
}
项目:openjdk-jdk10    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:openjdk9    文件MapIterator.java   
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(),global);
}
项目:openjdk9    文件SetIterator.java   
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(),global);
}
项目:openjdk9    文件StringIterator.java   
@Override
protected IteratorResult next(final Object arg) {
    final int index = nextIndex;
    final String string = iteratedString;

    if (string == null || index >= string.length()) {
        // ES6 21.1.5.2.1 step 8
        iteratedString = null;
        return makeResult(Undefined.getUndefined(),global);
}
项目:openjdk9    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:kaziranga    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:kaziranga    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:MultiScripts    文件Util.java   
public static Object toJSValue(Value value){
    if(value == null)
        return Undefined.getUndefined();

    if(value == Value.VOID)
        return Undefined.getUndefined();

    if(value.isstring())
        return new JsstringValue(value);

    if(value.isBoolean()|| value.isNumber())
        return value.get();

    if(value.isFunction())
        return new JSFunction(value);

    if(value.isArray())
        return new JSArray(value);

    if(value.isMap())
        return new JSMap(value);

    return Undefined.getUndefined();
}
项目:lookaside_java-1.8.0-openjdk    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:jdk8u_nashorn    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:jdk8u_nashorn    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:infobip-open-jdk-8    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:infobip-open-jdk-8    文件ObjectType.java   
@Override
public Type ldc(final MethodVisitor method,final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
项目:OLD-OpenJDK8    文件NashornLinker.java   
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request,final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNametokenCount() < 2 || !"dyn".equals(desc.getNametoken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc,request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv,linkerServices,desc);
}
项目:OLD-OpenJDK8    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:nashorn-backport    文件NashornLinker.java   
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request,desc);
}
项目:nashorn-backport    文件JavaAdapterServices.java   
/**
 * Given a JS script object,we only override "String toString()" it if it's explicitly specified
    if ("toString".equals(name) && !sobj.hasOwnProperty("toString")) {
        return null;
    }

    final Object fnObj = sobj.get(name);
    if (fnObj instanceof ScriptFunction) {
        return adaptHandle(((ScriptFunction)fnObj).getBoundInvokeHandle(sobj),name);
    }
}
项目:nashorn    文件NashornLinker.java   
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request,desc);
}
项目:nashorn    文件JavaAdapterServices.java   
/**
 * Given a JS script object,name);
    }
}
项目:Openjsharp    文件NativeArray.java   
private static MethodHandle getREDUCE_CALLBACK_INVOKER() {
    return Global.instance().getDynamicInvoker(REDUCE_CALLBACK_INVOKER,new Callable<MethodHandle>() {
                @Override
                public MethodHandle call() {
                    return Bootstrap.createDynamicInvoker("dyn:call",Object.class,Undefined.class,long.class,Object.class);
                }
            });
}
项目:Openjsharp    文件NashornLinker.java   
private static GuardedInvocation getGuardedInvocation(final Object self,final LinkRequest request,final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc,request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
项目:openjdk-jdk10    文件NativeSymbol.java   
/**
 * ECMA 6 19.4.1.1 Symbol ( [ description ] )
 *
 * @param newObj is this function invoked with the new operator
 * @param self   self reference
 * @param args   arguments
 * @return new symbol value
 */
@Constructor(arity = 1)
public static Object constructor(final boolean newObj,final Object self,final Object... args) {
    if (newObj) {
        throw typeError("symbol.as.constructor");
    }
    final String description = args.length > 0 && args[0] != Undefined.getUndefined() ?
            JSType.toString(args[0]) : "";
    return new Symbol(description);
}
项目:openjdk-jdk10    文件NativeSymbol.java   
/**
 * ES6 19.4.2.5 Symbol.keyFor ( sym )
 *
 * @param self self reference
 * @param arg the argument
 * @return the symbol name
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public synchronized static Object keyFor(final Object self,final Object arg) {
    if (!(arg instanceof Symbol)) {
        throw typeError("not.a.symbol",ScriptRuntime.safetoString(arg));
    }
    final String name = ((Symbol) arg).getName();
    return globalSymbolRegistry.get(name) == arg ? name : Undefined.getUndefined();
}
项目:openjdk-jdk10    文件NativeWeakSet.java   
static void populateWeakSet(final Map<Object,Boolean> set,final Object arg,final Global global) {
    if (arg != null && arg != Undefined.getUndefined()) {
        AbstractIterator.iterate(arg,global,value -> {
                set.put(checkKey(value),Boolean.TRUE);
        });
    }
}
项目:openjdk-jdk10    文件NativeArray.java   
private static MethodHandle getREDUCE_CALLBACK_INVOKER() {
    return Global.instance().getDynamicInvoker(REDUCE_CALLBACK_INVOKER,new Callable<MethodHandle>() {
                @Override
                public MethodHandle call() {
                    return Bootstrap.createDynamicCallInvoker(Object.class,double.class,Object.class);
                }
            });
}
项目:openjdk-jdk10    文件NativeMap.java   
static void populateMap(final LinkedMap map,value -> {
            if (JSType.isPrimitive(value)) {
                throw typeError(global,"not.an.object",ScriptRuntime.safetoString(value));
            }
            if (value instanceof ScriptObject) {
                final ScriptObject sobj = (ScriptObject) value;
                map.set(convertKey(sobj.get(0)),sobj.get(1));
            }
        });
    }
}
项目:openjdk-jdk10    文件NativeWeakMap.java   
/**
 * ECMA6 23.3.3.3 WeakMap.prototype.get ( key )
 *
 * @param self the self reference
 * @param key the key
 * @return the associated value or undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object get(final Object self,final Object key) {
    final NativeWeakMap map = getMap(self);
    if (isPrimitive(key)) {
        return Undefined.getUndefined();
    }
    return map.jmap.get(key);
}
项目:openjdk-jdk10    文件NativeWeakMap.java   
static void populateMap(final Map<Object,Object> map,final Global global) {
    // This method is similar to NativeMap.populateMap,but it uses a different
    // map implementation and the checking/conversion of keys differs as well.
    if (arg != null && arg != Undefined.getUndefined()) {
        AbstractIterator.iterate(arg,value -> {
            if (isPrimitive(value)) {
                throw typeError(global,ScriptRuntime.safetoString(value));
            }
            if (value instanceof ScriptObject) {
                final ScriptObject sobj = (ScriptObject) value;
                map.put(checkKey(sobj.get(0)),sobj.get(1));
            }
        });
    }
}
项目:openjdk-jdk10    文件NashornLinker.java   
private static GuardedInvocation getGuardedInvocation(final LinkRequest request,final CallSiteDescriptor desc) {
    final Object self = request.getReceiver();

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc,request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
项目:openjdk9    文件NativeSymbol.java   
/**
 * ECMA 6 19.4.1.1 Symbol ( [ description ] )
 *
 * @param newObj is this function invoked with the new operator
 * @param self   self reference
 * @param args   arguments
 * @return new symbol value
 */
@Constructor(arity = 1)
public static Object constructor(final boolean newObj,final Object... args) {
    if (newObj) {
        throw typeError("symbol.as.constructor");
    }
    final String description = args.length > 0 && args[0] != Undefined.getUndefined() ?
            JSType.toString(args[0]) : "";
    return new Symbol(description);
}
项目:openjdk9    文件NativeSymbol.java   
/**
 * ES6 19.4.2.5 Symbol.keyFor ( sym )
 *
 * @param self self reference
 * @param arg the argument
 * @return the symbol name
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,ScriptRuntime.safetoString(arg));
    }
    final String name = ((Symbol) arg).getName();
    return globalSymbolRegistry.get(name) == arg ? name : Undefined.getUndefined();
}
项目:openjdk9    文件NativeWeakSet.java   
static void populateWeakSet(final Map<Object,Boolean.TRUE);
        });
    }
}
项目:openjdk9    文件NativeArray.java   
private static MethodHandle getREDUCE_CALLBACK_INVOKER() {
    return Global.instance().getDynamicInvoker(REDUCE_CALLBACK_INVOKER,Object.class);
                }
            });
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。