Class JSObject

java.lang.Object
com.oracle.truffle.api.object.DynamicObject
com.oracle.truffle.js.runtime.objects.JSDynamicObject
com.oracle.truffle.js.runtime.objects.JSObject
All Implemented Interfaces:
com.oracle.truffle.api.interop.TruffleObject
Direct Known Subclasses:
JSClassObject

public abstract non-sealed class JSObject extends JSDynamicObject
The common base class for all JavaScript objects (values of type Object according to the spec). Includes static methods for dealing with JS objects (internal methods).
  • Field Details

    • CONSTRUCTOR

      public static final com.oracle.truffle.api.strings.TruffleString CONSTRUCTOR
    • PROTOTYPE

      public static final com.oracle.truffle.api.strings.TruffleString PROTOTYPE
    • PROTO

      public static final com.oracle.truffle.api.strings.TruffleString PROTO
    • GET_PROTO_NAME

      public static final com.oracle.truffle.api.strings.TruffleString GET_PROTO_NAME
    • SET_PROTO_NAME

      public static final com.oracle.truffle.api.strings.TruffleString SET_PROTO_NAME
    • HIDDEN_PROTO

      public static final com.oracle.truffle.api.object.HiddenKey HIDDEN_PROTO
    • NO_SUCH_PROPERTY_NAME

      public static final com.oracle.truffle.api.strings.TruffleString NO_SUCH_PROPERTY_NAME
    • NO_SUCH_METHOD_NAME

      public static final com.oracle.truffle.api.strings.TruffleString NO_SUCH_METHOD_NAME
    • EMPTY_STRING_ARRAY

      protected static final String[] EMPTY_STRING_ARRAY
  • Constructor Details

    • JSObject

      protected JSObject(com.oracle.truffle.api.object.Shape shape, JSDynamicObject proto)
  • Method Details

    • copyWithoutProperties

      protected JSObject copyWithoutProperties(com.oracle.truffle.api.object.Shape shape)
    • isJSObject

      public static boolean isJSObject(Object object)
      Returns whether object is a proper JavaScript Object.
    • hasMembers

      public final boolean hasMembers()
    • getMembers

      public Object getMembers(boolean internal)
    • filterEnumerableNames

      protected static String[] filterEnumerableNames(JSDynamicObject target, Iterable<Object> ownKeys, JSClass jsclass)
    • language

      public static JavaScriptLanguage language(com.oracle.truffle.api.interop.InteropLibrary node)
    • readMember

      public final Object readMember(String key, com.oracle.truffle.api.interop.InteropLibrary self, ReadElementNode readNode, boolean bindMemberFunctions, com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode fromJavaString, ExportValueNode exportNode) throws com.oracle.truffle.api.interop.UnknownIdentifierException
      Throws:
      com.oracle.truffle.api.interop.UnknownIdentifierException
    • isMemberReadable

      public final boolean isMemberReadable(String key, KeyInfoNode keyInfo)
    • writeMember

      public final void writeMember(String key, Object value, com.oracle.truffle.api.interop.InteropLibrary self, KeyInfoNode keyInfo, ImportValueNode castValueNode, WriteElementNode writeNode, com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode fromJavaString) throws com.oracle.truffle.api.interop.UnknownIdentifierException, com.oracle.truffle.api.interop.UnsupportedMessageException
      Throws:
      com.oracle.truffle.api.interop.UnknownIdentifierException
      com.oracle.truffle.api.interop.UnsupportedMessageException
    • isMemberModifiable

      public final boolean isMemberModifiable(String key, KeyInfoNode keyInfo)
    • isMemberInsertable

      public final boolean isMemberInsertable(String key, KeyInfoNode keyInfo)
    • removeMember

      public final void removeMember(String key, com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode fromJavaString) throws com.oracle.truffle.api.interop.UnsupportedMessageException
      Throws:
      com.oracle.truffle.api.interop.UnsupportedMessageException
    • isMemberRemovable

      public final boolean isMemberRemovable(String key, KeyInfoNode keyInfo)
    • invokeMember

      public final Object invokeMember(String id, Object[] args, com.oracle.truffle.api.interop.InteropLibrary self, JSInteropInvokeNode callNode, com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode fromJavaString, ExportValueNode exportNode) throws com.oracle.truffle.api.interop.UnsupportedMessageException, com.oracle.truffle.api.interop.UnknownIdentifierException
      Throws:
      com.oracle.truffle.api.interop.UnsupportedMessageException
      com.oracle.truffle.api.interop.UnknownIdentifierException
    • isMemberInvocable

      public final boolean isMemberInvocable(String key, KeyInfoNode keyInfo)
    • hasMemberReadSideEffects

      public final boolean hasMemberReadSideEffects(String key, KeyInfoNode keyInfo)
    • hasMemberWriteSideEffects

      public final boolean hasMemberWriteSideEffects(String key, KeyInfoNode keyInfo)
    • hasIterator

      public boolean hasIterator(com.oracle.truffle.api.interop.InteropLibrary self, JSInteropGetIteratorNode getIteratorNode)
    • getIterator

      public Object getIterator(com.oracle.truffle.api.interop.InteropLibrary self, JSInteropGetIteratorNode getIteratorNode) throws com.oracle.truffle.api.interop.UnsupportedMessageException
      Throws:
      com.oracle.truffle.api.interop.UnsupportedMessageException
    • hasLanguage

      public final boolean hasLanguage()
    • getLanguage

      public final Class<? extends com.oracle.truffle.api.TruffleLanguage<?>> getLanguage()
    • toDisplayString

      public final Object toDisplayString(boolean allowSideEffects)
    • getUncachedRead

      public static ReadElementNode getUncachedRead()
    • getUncachedWrite

      public static WriteElementNode getUncachedWrite()
    • getJSClass

      public static JSClass getJSClass(JSDynamicObject obj)
    • getPrototype

      public static JSDynamicObject getPrototype(JSDynamicObject obj)
    • getPrototype

      public static JSDynamicObject getPrototype(JSDynamicObject obj, JSClassProfile jsclassProfile)
    • setPrototype

      public static boolean setPrototype(JSDynamicObject obj, JSDynamicObject newPrototype)
    • setPrototype

      public static boolean setPrototype(JSDynamicObject obj, JSDynamicObject newPrototype, JSClassProfile jsclassProfile)
    • get

      public static Object get(JSDynamicObject obj, long index)
    • get

      public static Object get(JSDynamicObject obj, Object key)
    • getMethod

      public static Object getMethod(JSDynamicObject obj, Object name)
    • getMethod

      public static Object getMethod(JSDynamicObject obj, Object receiver, Object name)
    • set

      public static boolean set(JSDynamicObject obj, long index, Object value)
    • set

      public static boolean set(JSDynamicObject obj, Object key, Object value)
    • set

      public static boolean set(JSDynamicObject obj, long index, Object value, boolean isStrict, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • set

      public static boolean set(JSDynamicObject obj, Object key, Object value, boolean isStrict, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • setWithReceiver

      public static boolean setWithReceiver(JSDynamicObject obj, Object key, Object value, Object receiver, boolean isStrict, JSClassProfile classProfile, com.oracle.truffle.api.nodes.Node encapsulatingNode)
      [[Set]] with a receiver different than the default.
    • setWithReceiver

      public static boolean setWithReceiver(JSDynamicObject obj, long index, Object value, Object receiver, boolean isStrict, JSClassProfile classProfile, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • delete

      public static boolean delete(JSDynamicObject obj, long index)
    • delete

      public static boolean delete(JSDynamicObject obj, long index, boolean isStrict)
    • delete

      public static boolean delete(JSDynamicObject obj, long index, boolean isStrict, JSClassProfile classProfile)
    • delete

      public static boolean delete(JSDynamicObject obj, Object key)
    • delete

      public static boolean delete(JSDynamicObject obj, Object key, boolean isStrict)
    • delete

      public static boolean delete(JSDynamicObject obj, Object key, boolean isStrict, JSClassProfile classProfile)
    • hasOwnProperty

      public static boolean hasOwnProperty(JSDynamicObject obj, long index)
    • hasOwnProperty

      public static boolean hasOwnProperty(JSDynamicObject obj, long index, JSClassProfile classProfile)
    • hasOwnProperty

      public static boolean hasOwnProperty(JSDynamicObject obj, Object key)
    • hasOwnProperty

      public static boolean hasOwnProperty(JSDynamicObject obj, Object key, JSClassProfile classProfile)
    • hasProperty

      public static boolean hasProperty(JSDynamicObject obj, long index)
    • hasProperty

      public static boolean hasProperty(JSDynamicObject obj, long index, JSClassProfile classProfile)
    • hasProperty

      public static boolean hasProperty(JSDynamicObject obj, Object key)
    • hasProperty

      public static boolean hasProperty(JSDynamicObject obj, Object key, JSClassProfile classProfile)
    • getOwnProperty

      public static PropertyDescriptor getOwnProperty(JSDynamicObject obj, Object key)
    • getOwnProperty

      public static PropertyDescriptor getOwnProperty(JSDynamicObject obj, Object key, JSClassProfile classProfile)
    • ownPropertyKeys

      public static List<Object> ownPropertyKeys(JSDynamicObject obj)
      [[OwnPropertyKeys]]. The returned keys are instanceof (String, Symbol).
    • ownPropertyKeys

      public static List<Object> ownPropertyKeys(JSDynamicObject obj, JSClassProfile classProfile)
    • enumerableOwnNames

      public static List<com.oracle.truffle.api.strings.TruffleString> enumerableOwnNames(JSDynamicObject thisObj)
      7.3.21 EnumerableOwnNames (O).
    • defineOwnProperty

      public static boolean defineOwnProperty(JSDynamicObject obj, Object key, PropertyDescriptor desc)
    • defineOwnProperty

      public static boolean defineOwnProperty(JSDynamicObject obj, Object key, PropertyDescriptor desc, boolean doThrow)
    • get

      public static Object get(JSDynamicObject obj, Object key, JSClassProfile jsclassProfile)
    • get

      public static Object get(JSDynamicObject obj, long index, JSClassProfile jsclassProfile)
    • getOrDefault

      public static Object getOrDefault(JSDynamicObject obj, Object key, Object receiver, Object defaultValue, JSClassProfile jsclassProfile, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getOrDefault

      public static Object getOrDefault(JSDynamicObject obj, long index, Object receiver, Object defaultValue, JSClassProfile jsclassProfile, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getOrDefault

      public static Object getOrDefault(JSDynamicObject obj, Object key, Object receiver, Object defaultValue)
    • getOrDefault

      public static Object getOrDefault(JSDynamicObject obj, long index, Object receiver, Object defaultValue)
    • getWithReceiver

      public static Object getWithReceiver(JSDynamicObject obj, Object key, Object receiver, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • defaultToString

      public static com.oracle.truffle.api.strings.TruffleString defaultToString(JSDynamicObject obj)
    • getBuiltinToStringTag

      public com.oracle.truffle.api.strings.TruffleString getBuiltinToStringTag()
      Returns builtinTag as per Object.prototype.toString(). By default returns "Object".
      Specified by:
      getBuiltinToStringTag in class JSDynamicObject
      Returns:
      built-in toStringTag
    • toPrimitive

      public static Object toPrimitive(JSDynamicObject obj, JSToPrimitiveNode.Hint hint)
      ES2015 7.1.1 ToPrimitive in case an Object is passed.
    • toPrimitive

      public static Object toPrimitive(JSDynamicObject obj)
    • ordinaryToPrimitive

      public static Object ordinaryToPrimitive(JSDynamicObject obj, JSToPrimitiveNode.Hint hint)
      ES2018 7.1.1.1 OrdinaryToPrimitive.
    • isExtensible

      public static boolean isExtensible(JSDynamicObject obj)
    • isExtensible

      public static boolean isExtensible(JSDynamicObject obj, JSClassProfile classProfile)
    • getClassName

      public static com.oracle.truffle.api.strings.TruffleString getClassName(JSDynamicObject obj)
      The property [[Class]] of the object. This is the second part of what Object.prototype.toString.call(myObj) returns, e.g. "[object Array]".
      Returns:
      the internal property [[Class]] of the object.
    • getArray

      public static ScriptArray getArray(JSDynamicObject obj)
    • setArray

      public static void setArray(JSDynamicObject obj, ScriptArray array)
    • hasArray

      public static boolean hasArray(Object obj)
    • getJSContext

      public static JSContext getJSContext(JSDynamicObject obj)