Class JSDynamicObject

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

public abstract sealed class JSDynamicObject extends com.oracle.truffle.api.object.DynamicObject implements com.oracle.truffle.api.interop.TruffleObject permits JSObject, Nullish
The common base class for all JavaScript objects as well as null and undefined.
  • Constructor Details

    • JSDynamicObject

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

    • identityHashCode

      public final int identityHashCode()
    • getJSContext

      public final JSContext getJSContext()
    • getJSClass

      public final JSClass getJSClass()
    • getPrototypeOf

      public abstract JSDynamicObject getPrototypeOf()
      [[GetPrototypeOf]] ().
    • setPrototypeOf

      public abstract boolean setPrototypeOf(JSDynamicObject newPrototype)
      [[SetPrototypeOf]] (V).
    • isExtensible

      public abstract boolean isExtensible()
      [IsExtensible]] ().
    • preventExtensions

      public abstract boolean preventExtensions(boolean doThrow)
      [[PreventExtensions]] ().
    • getOwnProperty

      public abstract PropertyDescriptor getOwnProperty(Object propertyKey)
      [[GetOwnProperty]] (P).
    • defineOwnProperty

      public abstract boolean defineOwnProperty(Object key, PropertyDescriptor value, boolean doThrow)
      [[DefineOwnProperty]] (P, Desc).
    • hasProperty

      public abstract boolean hasProperty(Object key)
      [[HasProperty]] (P).
    • hasProperty

      public abstract boolean hasProperty(long index)
    • hasOwnProperty

      public abstract boolean hasOwnProperty(Object propName)
    • hasOwnProperty

      public abstract boolean hasOwnProperty(long index)
    • getValue

      public Object getValue(Object key)
      [[Get]] (P, Receiver).
    • getValue

      public Object getValue(long index)
    • getHelper

      public abstract Object getHelper(Object receiver, Object key, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getHelper

      public abstract Object getHelper(Object receiver, long index, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getOwnHelper

      public abstract Object getOwnHelper(Object receiver, Object key, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getOwnHelper

      public abstract Object getOwnHelper(Object receiver, long index, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • getMethodHelper

      public abstract Object getMethodHelper(Object receiver, Object key, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • set

      public abstract boolean set(Object key, Object value, Object receiver, boolean isStrict, com.oracle.truffle.api.nodes.Node encapsulatingNode)
      [[Set]] (P, V, Receiver).
    • set

      public abstract boolean set(long index, Object value, Object receiver, boolean isStrict, com.oracle.truffle.api.nodes.Node encapsulatingNode)
    • delete

      public abstract boolean delete(Object key, boolean isStrict)
      [[Delete]] (P).
    • delete

      public abstract boolean delete(long propIdx, boolean isStrict)
    • ownPropertyKeys

      public List<Object> ownPropertyKeys()
      [[OwnPropertyKeys]](). Provides all own properties of this object with a String or Symbol key. Represents the [[OwnPropertyKeys]] internal method.
      Returns:
      a List of the keys of all own properties of that object
    • getOwnPropertyKeys

      public abstract List<Object> getOwnPropertyKeys(boolean strings, boolean symbols)
      GetOwnPropertyKeys (O, type).
      Returns:
      a List of the keys of all own properties of that object with the specified types
    • hasOnlyShapeProperties

      public abstract boolean hasOnlyShapeProperties()
    • getClassName

      public abstract com.oracle.truffle.api.strings.TruffleString getClassName()
      The [[Class]] internal property. For ES5, this is the second part of what Object.prototype.toString.call(myObj) returns, e.g. "[object Array]".
    • defaultToString

      public com.oracle.truffle.api.strings.TruffleString defaultToString()
      Returns the equivalent of Object.prototype.toString(), i.e., for ES2015+: "[object " + toStringTag + "]", where toStringTag is either the value of the object's Symbol.toStringTag property, if present and a string value, or else, the builtinTag (default: "Object") according to Object.prototype.toString(). For ES5, the [[Class]] internal property is used instead, i.e.: "[object " + [[Class]] + "]", although in some cases we still use Symbol.toStringTag to override [[Class]] for Nashorn compatibility.
      See Also:
    • getBuiltinToStringTag

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

      public abstract com.oracle.truffle.api.strings.TruffleString toDisplayStringImpl(boolean allowSideEffects, ToDisplayStringFormat format, int depth)
      A more informative toString variant, mainly used for error messages.
      Parameters:
      format - formatting parameters
      depth - current nesting depth
    • testIntegrityLevel

      public boolean testIntegrityLevel(boolean frozen)
      TestIntegrityLevel(O, level).
    • setIntegrityLevel

      public boolean setIntegrityLevel(boolean freeze, boolean doThrow)
      SetIntegrityLevel(O, level).
    • isJSDynamicObject

      public static boolean isJSDynamicObject(Object object)
      Returns whether object is a JSDynamicObject (JSObject or null/undefined).
    • setJSClass

      public static void setJSClass(JSDynamicObject obj, JSClass jsclass)
    • getDynamicType

      public static Object getDynamicType(JSDynamicObject obj)
    • hasProperty

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

      public static com.oracle.truffle.api.object.Property[] getPropertyArray(JSDynamicObject obj)
    • getOrNull

      public static Object getOrNull(JSDynamicObject obj, Object key)
    • getOrDefault

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

      public static int getObjectFlags(JSDynamicObject obj)
    • setObjectFlags

      public static void setObjectFlags(JSDynamicObject obj, int flags)
    • setPropertyFlags

      public static void setPropertyFlags(JSDynamicObject obj, Object key, int flags)
    • getPropertyFlags

      public static int getPropertyFlags(JSDynamicObject obj, Object key)
    • updatePropertyFlags

      public static boolean updatePropertyFlags(JSDynamicObject obj, Object key, IntUnaryOperator updateFunction)
      Update property flags, changing the object's shape if need be.
      Parameters:
      updateFunction - An idempotent function that returns the updated property flags based on the previous flags.
      Returns:
      true if successful, false if there was no such property or no change was made.
      See Also:
    • testProperties

      public static boolean testProperties(JSDynamicObject obj, Predicate<com.oracle.truffle.api.object.Property> predicate)
    • getJSSharedData

      public static JSSharedData getJSSharedData(JSDynamicObject obj)