Class ScopeObject

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<VarScope>
org.htmlunit.corejs.javascript.ScopeObject
All Implemented Interfaces:
Serializable, ConstProperties<VarScope>, PropHolder<VarScope>, VarScope
Direct Known Subclasses:
DeclarationScope, TopLevel

public class ScopeObject extends SlotMapOwner<VarScope> implements VarScope, Serializable
See Also:
  • Constructor Details

    • ScopeObject

      public ScopeObject(VarScope parentScope)
  • Method Details

    • getParentScope

      public VarScope getParentScope()
      Description copied from interface: VarScope
      Get the parent scope of this scope.
      Specified by:
      getParentScope in interface VarScope
      Returns:
      the parent scope
    • getThis

      public ScopeObject getThis()
      Specified by:
      getThis in class SlotMapOwner<VarScope>
    • put

      public void put(String name, VarScope start, Object value)
      Sets the value of the named property, creating it if need be.

      If the property was created using defineProperty, the appropriate setter method is called.

      If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.

      Specified by:
      put in interface PropHolder<VarScope>
      Overrides:
      put in class SlotMapOwner<VarScope>
      Parameters:
      name - the name of the property
      start - the object whose property is being set
      value - value to set the property to
    • putOwnProperty

      protected boolean putOwnProperty(String name, VarScope start, Object value, boolean isThrow)
      Set the value of the named property, and return true if the property is actually defined and can be set. Subclasses of ScriptableObject should override this method, and not "put," for proper strict mode operation in the future.
      Parameters:
      isThrow - if true, throw an exception as if in strict mode
    • put

      public void put(int index, VarScope start, Object value)
      Sets the value of the indexed property, creating it if need be.
      Specified by:
      put in interface PropHolder<VarScope>
      Overrides:
      put in class SlotMapOwner<VarScope>
      Parameters:
      index - the numeric index for the property
      start - the object whose property is being set
      value - value to set the property to
    • putOwnProperty

      protected boolean putOwnProperty(int index, VarScope start, Object value, boolean isThrow)
      Set the value of the named property, and return true if the property is actually defined and can be set. Subclasses of ScriptableObject should override this method, and not "put," for proper strict mode operation in the future
      Parameters:
      isThrow - if true, throw an exception as if in strict mode
    • put

      public void put(Symbol key, VarScope start, Object value)
      Implementation of put required by SymbolScriptable objects.
      Specified by:
      put in interface PropHolder<VarScope>
      Overrides:
      put in class SlotMapOwner<VarScope>
    • putOwnProperty

      protected boolean putOwnProperty(Symbol key, VarScope start, Object value, boolean isThrow)
      Set the value of the named property, and return true if the property is actually defined and can be set. Subclasses of ScriptableObject should override this method, and not "put," for proper strict mode operation in the future
      Parameters:
      isThrow - if true, throw an exception as if in strict mode
    • has

      public boolean has(String name, VarScope start)
      Returns true if the named property is defined.
      Specified by:
      has in interface PropHolder<VarScope>
      Overrides:
      has in class SlotMapOwner<VarScope>
      Parameters:
      name - the name of the property
      start - the object in which the lookup began
      Returns:
      true if and only if the property was found in the object
    • has

      public boolean has(int index, VarScope start)
      Returns true if the property index is defined.
      Specified by:
      has in interface PropHolder<VarScope>
      Overrides:
      has in class SlotMapOwner<VarScope>
      Parameters:
      index - the numeric index for the property
      start - the object in which the lookup began
      Returns:
      true if and only if the property was found in the object
    • has

      public boolean has(Symbol key, VarScope start)
      A version of "has" that supports symbols.
      Specified by:
      has in interface PropHolder<VarScope>
      Overrides:
      has in class SlotMapOwner<VarScope>
    • get

      public Object get(String name, VarScope start)
      Returns the value of the named property or NOT_FOUND.

      If the property was created using defineProperty, the appropriate getter method is called.

      Specified by:
      get in interface PropHolder<VarScope>
      Overrides:
      get in class SlotMapOwner<VarScope>
      Parameters:
      name - the name of the property
      start - the object in which the lookup began
      Returns:
      the value of the property (may be null), or NOT_FOUND
    • get

      public Object get(int index, VarScope start)
      Returns the value of the indexed property or NOT_FOUND.
      Specified by:
      get in interface PropHolder<VarScope>
      Overrides:
      get in class SlotMapOwner<VarScope>
      Parameters:
      index - the numeric index for the property
      start - the object in which the lookup began
      Returns:
      the value of the property (may be null), or NOT_FOUND
    • get

      public Object get(Symbol key, VarScope start)
      Another version of Get that supports Symbol keyed properties.
      Specified by:
      get in interface PropHolder<VarScope>
      Overrides:
      get in class SlotMapOwner<VarScope>
    • delete

      public void delete(String name)
      Specified by:
      delete in interface PropHolder<VarScope>
      Overrides:
      delete in class SlotMapOwner<VarScope>
    • delete

      public void delete(int index)
      Specified by:
      delete in interface PropHolder<VarScope>
      Overrides:
      delete in class SlotMapOwner<VarScope>
    • delete

      public void delete(Symbol key)
      Specified by:
      delete in interface PropHolder<VarScope>
      Overrides:
      delete in class SlotMapOwner<VarScope>
    • defineProperty

      public void defineProperty(String propertyName, Object value, int attributes)
      Define a JavaScript property.

      Creates the property with an initial value and sets its attributes.

      Overrides:
      defineProperty in class SlotMapOwner<VarScope>
      Parameters:
      propertyName - the name of the property to define.
      value - the initial value of the property
      attributes - the attributes of the JavaScript property
      See Also:
    • defineProperty

      public void defineProperty(Symbol key, Object value, int attributes)
      A version of defineProperty that uses a Symbol key.
      Overrides:
      defineProperty in class SlotMapOwner<VarScope>
      Parameters:
      key - symbol of the property to define.
      value - the initial value of the property
      attributes - the attributes of the JavaScript property
    • setAttributes

      public void setAttributes(String name, int attributes)
      Set the attributes of a named property.

      The property is specified by name as defined for has.

      The possible attributes are READONLY, DONTENUM, and PERMANENT. Combinations of attributes are expressed by the bitwise OR of attributes. EMPTY is the state of no attributes set. Any unused bits are reserved for future use.

      Overrides:
      setAttributes in class SlotMapOwner<VarScope>
      Parameters:
      name - the name of the property
      attributes - the bitset of attributes
      Throws:
      EvaluatorException - if the named property is not found
      See Also:
    • setAttributes

      public void setAttributes(Symbol key, int attributes)
      Set attributes of a Symbol-keyed property.
      Overrides:
      setAttributes in class SlotMapOwner<VarScope>
    • putConst

      public void putConst(Context cx, String name, VarScope start, Object value)
      Sets the value of the named const property, creating it if need be.

      If the property was created using defineProperty, the appropriate setter method is called.

      If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.

      Specified by:
      putConst in interface ConstProperties<VarScope>
      Parameters:
      name - the name of the property
      start - the object whose property is being set
      value - value to set the property to
      See Also:
    • defineConst

      public void defineConst(Context cx, String name, VarScope start)
      Description copied from interface: ConstProperties
      Reserves a definition spot for a const. This will set up a definition of the const property, but set its value to undefined. The semantics of the start parameter is the same as for putConst.
      Specified by:
      defineConst in interface ConstProperties<VarScope>
      name - The name of the property.
      start - The object whose property is being reserved.
    • isConst

      public boolean isConst(Context cx, String name)
      Returns true if the named property is defined as a const on this object.
      Specified by:
      isConst in interface ConstProperties<VarScope>
      Parameters:
      name - the name of the property
      Returns:
      true if the named property is defined as a const, false otherwise.