Java Code Examples for jdk.nashorn.internal.runtime.JSType#NULL

The following examples show how to use jdk.nashorn.internal.runtime.JSType#NULL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 2
Source File: NativeObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 3
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 4
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 5
Source File: NativeObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
        case SYMBOL:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 6
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 7
Source File: NativeObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.of(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || (type == JSType.NULL || type == JSType.UNDEFINED)) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
        case FUNCTION:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 8
Source File: NativeObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.of(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || (type == JSType.NULL || type == JSType.UNDEFINED)) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
        case FUNCTION:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 9
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.ofNoFunction(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || type == JSType.NULL || type == JSType.UNDEFINED) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}
 
Example 10
Source File: NativeObject.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.2.1 , 15.2.1.1 new Object([value]) and Object([value])
 *
 * Constructor
 *
 * @param newObj is the new object instantiated with the new operator
 * @param self   self reference
 * @param value  value of object to be instantiated
 * @return the new NativeObject
 */
@Constructor
public static Object construct(final boolean newObj, final Object self, final Object value) {
    final JSType type = JSType.of(value);

    // Object(null), Object(undefined), Object() are same as "new Object()"

    if (newObj || (type == JSType.NULL || type == JSType.UNDEFINED)) {
        switch (type) {
        case BOOLEAN:
        case NUMBER:
        case STRING:
            return Global.toObject(value);
        case OBJECT:
        case FUNCTION:
            return value;
        case NULL:
        case UNDEFINED:
            // fall through..
        default:
            break;
        }

        return Global.newEmptyInstance();
    }

    return Global.toObject(value);
}