Java Code Examples for jdk.nashorn.internal.runtime.JSType#of()
The following examples show how to use
jdk.nashorn.internal.runtime.JSType#of() .
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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 |
/** * 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 11
Source File: NativeObject.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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 12
Source File: NativeObject.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 13
Source File: NativeObject.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * 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); }