Package org.htmlunit.corejs.javascript
Class NativeSymbol
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.corejs.javascript.IdScriptableObject
-
- org.htmlunit.corejs.javascript.NativeSymbol
-
- All Implemented Interfaces:
java.io.Serializable,ConstProperties,DebuggableObject,IdFunctionCall,Scriptable,Symbol,SymbolScriptable
public class NativeSymbol extends IdScriptableObject implements Symbol
This is an implementation of the standard "Symbol" type that implements all of its weird properties. One of them is that some objects can have an "internal data slot" that makes them a Symbol and others cannot.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASS_NAMEprivate static java.lang.ObjectCONSTRUCTOR_SLOTprivate static intConstructorId_forprivate static intConstructorId_keyForprivate static java.lang.ObjectGLOBAL_TABLE_KEYprivate static intId_constructorprivate static intId_toStringprivate static intId_valueOfprivate SymbolKeykeyprivate static intMAX_PROTOTYPE_IDprivate static longserialVersionUIDprivate NativeSymbolsymbolDataprivate static intSymbolId_toPrimitiveprivate static intSymbolId_toStringTagstatic java.lang.StringTYPE_NAME-
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Modifier Constructor Description privateNativeSymbol(java.lang.String desc)This has to be used only for constructing the prototype instance.NativeSymbol(NativeSymbol s)(package private)NativeSymbol(SymbolKey key)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NativeSymbolconstruct(Context cx, Scriptable scope, java.lang.Object[] args)Use this when we need to create symbols internally because of the convoluted way we have to construct them.private static voidcreateStandardSymbol(Context cx, Scriptable scope, ScriptableObject ctor, java.lang.String name, SymbolKey key)booleanequals(java.lang.Object x)java.lang.ObjectexecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.protected voidfillConstructorProperties(IdFunctionObject ctor)protected intfindPrototypeId(java.lang.String s)protected intfindPrototypeId(Symbol key)java.lang.StringgetClassName()Return the name of the class.private java.util.Map<java.lang.String,NativeSymbol>getGlobalMap()(package private) SymbolKeygetKey()private static NativeSymbolgetSelf(Context cx, Scriptable scope, java.lang.Object thisObj)java.lang.StringgetTypeOf()Gets the value that will be returned by calling the typeof operator on this object.inthashCode()static voidinit(Context cx, Scriptable scope, boolean sealed)protected voidinitPrototypeId(int id)private static booleanisStrictMode()booleanisSymbol()Object() on a Symbol constructs an object which is NOT a symbol, but which has an "internal data slot" that is.private static NativeSymboljs_constructor(java.lang.Object[] args)private java.lang.Objectjs_for(Context cx, Scriptable scope, java.lang.Object[] args)private java.lang.Objectjs_keyFor(Context cx, Scriptable scope, java.lang.Object[] args)private java.lang.Objectjs_valueOf()voidput(int index, Scriptable start, java.lang.Object value)Sets the value of the indexed property, creating it if need be.voidput(java.lang.String name, Scriptable start, java.lang.Object value)Sets the value of the named property, creating it if need be.voidput(Symbol key, Scriptable start, java.lang.Object value)Implementation of put required by SymbolScriptable objects.java.lang.StringtoString()-
Methods inherited from class org.htmlunit.corejs.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, ensureType, exportAsJSClass, findInstanceIdInfo, findInstanceIdInfo, get, get, getAttributes, getAttributes, getIds, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getOwnPropertyDescriptor, has, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, setAttributes, setInstanceIdAttributes, setInstanceIdValue
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getBase, getBase, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, putConst, putConstProperty, putImpl, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
CLASS_NAME
public static final java.lang.String CLASS_NAME
- See Also:
- Constant Field Values
-
TYPE_NAME
public static final java.lang.String TYPE_NAME
- See Also:
- Constant Field Values
-
GLOBAL_TABLE_KEY
private static final java.lang.Object GLOBAL_TABLE_KEY
-
CONSTRUCTOR_SLOT
private static final java.lang.Object CONSTRUCTOR_SLOT
-
key
private final SymbolKey key
-
symbolData
private final NativeSymbol symbolData
-
ConstructorId_keyFor
private static final int ConstructorId_keyFor
- See Also:
- Constant Field Values
-
ConstructorId_for
private static final int ConstructorId_for
- See Also:
- Constant Field Values
-
Id_constructor
private static final int Id_constructor
- See Also:
- Constant Field Values
-
Id_toString
private static final int Id_toString
- See Also:
- Constant Field Values
-
Id_valueOf
private static final int Id_valueOf
- See Also:
- Constant Field Values
-
SymbolId_toStringTag
private static final int SymbolId_toStringTag
- See Also:
- Constant Field Values
-
SymbolId_toPrimitive
private static final int SymbolId_toPrimitive
- See Also:
- Constant Field Values
-
MAX_PROTOTYPE_ID
private static final int MAX_PROTOTYPE_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeSymbol
private NativeSymbol(java.lang.String desc)
This has to be used only for constructing the prototype instance. This sets symbolData to null (see isSymbol() for more).- Parameters:
desc- the description
-
NativeSymbol
NativeSymbol(SymbolKey key)
-
NativeSymbol
public NativeSymbol(NativeSymbol s)
-
-
Method Detail
-
init
public static void init(Context cx, Scriptable scope, boolean sealed)
-
construct
public static NativeSymbol construct(Context cx, Scriptable scope, java.lang.Object[] args)
Use this when we need to create symbols internally because of the convoluted way we have to construct them.
-
getClassName
public java.lang.String getClassName()
Description copied from class:ScriptableObjectReturn the name of the class.This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
- Specified by:
getClassNamein interfaceScriptable- Specified by:
getClassNamein classScriptableObject
-
fillConstructorProperties
protected void fillConstructorProperties(IdFunctionObject ctor)
- Overrides:
fillConstructorPropertiesin classIdScriptableObject
-
createStandardSymbol
private static void createStandardSymbol(Context cx, Scriptable scope, ScriptableObject ctor, java.lang.String name, SymbolKey key)
-
findPrototypeId
protected int findPrototypeId(java.lang.String s)
- Overrides:
findPrototypeIdin classIdScriptableObject
-
findPrototypeId
protected int findPrototypeId(Symbol key)
- Overrides:
findPrototypeIdin classIdScriptableObject
-
initPrototypeId
protected void initPrototypeId(int id)
- Overrides:
initPrototypeIdin classIdScriptableObject
-
execIdCall
public java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Description copied from class:IdScriptableObject'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.- Specified by:
execIdCallin interfaceIdFunctionCall- Overrides:
execIdCallin classIdScriptableObject
-
getSelf
private static NativeSymbol getSelf(Context cx, Scriptable scope, java.lang.Object thisObj)
-
js_constructor
private static NativeSymbol js_constructor(java.lang.Object[] args)
-
js_valueOf
private java.lang.Object js_valueOf()
-
js_for
private java.lang.Object js_for(Context cx, Scriptable scope, java.lang.Object[] args)
-
js_keyFor
private java.lang.Object js_keyFor(Context cx, Scriptable scope, java.lang.Object[] args)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isStrictMode
private static boolean isStrictMode()
-
put
public void put(java.lang.String name, Scriptable start, java.lang.Object value)Description copied from class:ScriptableObjectSets 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:
putin interfaceScriptable- Overrides:
putin classIdScriptableObject- Parameters:
name- the name of the propertystart- the object whose property is being setvalue- value to set the property to- See Also:
Scriptable.has(String, Scriptable),Scriptable.get(String, Scriptable),ScriptableObject.putProperty(Scriptable, String, Object),Context.toObject(Object, Scriptable)
-
put
public void put(int index, Scriptable start, java.lang.Object value)Description copied from class:ScriptableObjectSets the value of the indexed property, creating it if need be.- Specified by:
putin interfaceScriptable- Overrides:
putin classScriptableObject- Parameters:
index- the numeric index for the propertystart- the object whose property is being setvalue- value to set the property to- See Also:
Scriptable.has(int, Scriptable),Scriptable.get(int, Scriptable),ScriptableObject.putProperty(Scriptable, int, Object),Context.toObject(Object, Scriptable)
-
put
public void put(Symbol key, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObjectImplementation of put required by SymbolScriptable objects.- Specified by:
putin interfaceSymbolScriptable- Overrides:
putin classIdScriptableObject
-
isSymbol
public boolean isSymbol()
Object() on a Symbol constructs an object which is NOT a symbol, but which has an "internal data slot" that is. Furthermore, such an object has the Symbol prototype so this particular object is still used. Account for that here: an "Object" that was created from a Symbol has a different value of the slot.
-
getTypeOf
public java.lang.String getTypeOf()
Description copied from class:ScriptableObjectGets the value that will be returned by calling the typeof operator on this object.- Overrides:
getTypeOfin classScriptableObject- Returns:
- default is "object" unless
ScriptableObject.avoidObjectDetection()istruein which case it returns "undefined"
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x)
- Overrides:
equalsin classjava.lang.Object
-
getKey
SymbolKey getKey()
-
getGlobalMap
private java.util.Map<java.lang.String,NativeSymbol> getGlobalMap()
-
-