Class NativeSymbol
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
org.mozilla.javascript.NativeSymbol
- All Implemented Interfaces:
Serializable, ConstProperties, DebuggableObject, IdFunctionCall, Scriptable, Symbol, SymbolScriptable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class ScriptableObject
ScriptableObject.KeyComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate static final Objectprivate static final intprivate static final intprivate static final Objectprivate static final intprivate static final intprivate static final intprivate final SymbolKeyprivate static final intprivate static final longprivate final NativeSymbolprivate static final intprivate static final intstatic final StringFields inherited from class ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNativeSymbol(String desc) This has to be used only for constructing the prototype instance.privateNativeSymbol(SymbolKey key) -
Method Summary
Modifier and TypeMethodDescriptionstatic NativeSymbolconstruct(Context cx, Scriptable scope, 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, String name, SymbolKey key) booleanexecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) 'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.protected voidprotected intprotected intfindPrototypeId(Symbol key) Return the name of the class.private Map<String, NativeSymbol> (package private) SymbolKeygetKey()private static NativeSymbolgetSelf(Context cx, Scriptable scope, Object thisObj) 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 booleanbooleanisSymbol()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(Object[] args) private Objectjs_for(Context cx, Scriptable scope, Object[] args) private Objectjs_keyFor(Context cx, Scriptable scope, Object[] args) private Objectvoidput(int index, Scriptable start, Object value) Sets the value of the indexed property, creating it if need be.voidput(String name, Scriptable start, Object value) Sets the value of the named property, creating it if need be.voidput(Symbol key, Scriptable start, Object value) Implementation of put required by SymbolScriptable objects.toString()Methods inherited from class 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, setInstanceIdValueMethods inherited from class 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, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, 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, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
CLASS_NAME
- See Also:
-
TYPE_NAME
- See Also:
-
GLOBAL_TABLE_KEY
-
CONSTRUCTOR_SLOT
-
key
-
symbolData
-
ConstructorId_keyFor
private static final int ConstructorId_keyFor- See Also:
-
ConstructorId_for
private static final int ConstructorId_for- See Also:
-
Id_constructor
private static final int Id_constructor- See Also:
-
Id_toString
private static final int Id_toString- See Also:
-
Id_valueOf
private static final int Id_valueOf- See Also:
-
SymbolId_toStringTag
private static final int SymbolId_toStringTag- See Also:
-
SymbolId_toPrimitive
private static final int SymbolId_toPrimitive- See Also:
-
MAX_PROTOTYPE_ID
private static final int MAX_PROTOTYPE_ID- See Also:
-
-
Constructor Details
-
NativeSymbol
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
-
-
Method Details
-
init
-
construct
Use this when we need to create symbols internally because of the convoluted way we have to construct them. -
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
- Overrides:
fillConstructorPropertiesin classIdScriptableObject
-
createStandardSymbol
private static void createStandardSymbol(Context cx, Scriptable scope, ScriptableObject ctor, String name, SymbolKey key) -
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
initPrototypeId
protected void initPrototypeId(int id) - Overrides:
initPrototypeIdin classIdScriptableObject
-
execIdCall
public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, 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
-
js_constructor
-
js_valueOf
-
js_for
-
js_keyFor
-
toString
-
isStrictMode
private static boolean isStrictMode() -
put
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:
-
put
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:
-
put
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
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
-
equals
-
getKey
SymbolKey getKey() -
getGlobalMap
-