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

The following examples show how to use jdk.nashorn.internal.runtime.JSType#OBJECT . 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 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 2
Source File: NativeObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 3
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 4
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 5
Source File: NativeObject.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 6
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 7
Source File: NativeObject.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 8
Source File: NativeObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 9
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}
 
Example 10
Source File: NativeObject.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.2.3.2 Object.getPrototypeOf ( O )
 *
 * @param  self self reference
 * @param  obj object to get prototype from
 * @return the prototype of an object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getPrototypeOf(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).getProto();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).getProto();
    } else {
        final JSType type = JSType.of(obj);
        if (type == JSType.OBJECT) {
            // host (Java) objects have null __proto__
            return null;
        }

        // must be some JS primitive
        throw notAnObject(obj);
    }
}