V8 Project
v8::Symbol Class Reference

A JavaScript symbol (ECMA-262 edition 6) More...

#include <v8.h>

+ Inheritance diagram for v8::Symbol:
+ Collaboration diagram for v8::Symbol:

Public Member Functions

Local< ValueName () const
 
- Public Member Functions inherited from v8::Value
bool IsUndefined () const
 Returns true if this value is the undefined value. More...
 
bool IsNull () const
 Returns true if this value is the null value. More...
 
bool IsTrue () const
 Returns true if this value is true. More...
 
bool IsFalse () const
 Returns true if this value is false. More...
 
bool IsName () const
 Returns true if this value is a symbol or a string. More...
 
bool IsString () const
 Returns true if this value is an instance of the String type. More...
 
bool IsSymbol () const
 Returns true if this value is a symbol. More...
 
bool IsFunction () const
 Returns true if this value is a function. More...
 
bool IsArray () const
 Returns true if this value is an array. More...
 
bool IsObject () const
 Returns true if this value is an object. More...
 
bool IsBoolean () const
 Returns true if this value is boolean. More...
 
bool IsNumber () const
 Returns true if this value is a number. More...
 
bool IsExternal () const
 Returns true if this value is external. More...
 
bool IsInt32 () const
 Returns true if this value is a 32-bit signed integer. More...
 
bool IsUint32 () const
 Returns true if this value is a 32-bit unsigned integer. More...
 
bool IsDate () const
 Returns true if this value is a Date. More...
 
bool IsArgumentsObject () const
 Returns true if this value is an Arguments object. More...
 
bool IsBooleanObject () const
 Returns true if this value is a Boolean object. More...
 
bool IsNumberObject () const
 Returns true if this value is a Number object. More...
 
bool IsStringObject () const
 Returns true if this value is a String object. More...
 
bool IsSymbolObject () const
 Returns true if this value is a Symbol object. More...
 
bool IsNativeError () const
 Returns true if this value is a NativeError. More...
 
bool IsRegExp () const
 Returns true if this value is a RegExp. More...
 
bool IsGeneratorFunction () const
 Returns true if this value is a Generator function. More...
 
bool IsGeneratorObject () const
 Returns true if this value is a Generator object (iterator). More...
 
bool IsPromise () const
 Returns true if this value is a Promise. More...
 
bool IsMap () const
 Returns true if this value is a Map. More...
 
bool IsSet () const
 Returns true if this value is a Set. More...
 
bool IsWeakMap () const
 Returns true if this value is a WeakMap. More...
 
bool IsWeakSet () const
 Returns true if this value is a WeakSet. More...
 
bool IsArrayBuffer () const
 Returns true if this value is an ArrayBuffer. More...
 
bool IsArrayBufferView () const
 Returns true if this value is an ArrayBufferView. More...
 
bool IsTypedArray () const
 Returns true if this value is one of TypedArrays. More...
 
bool IsUint8Array () const
 Returns true if this value is an Uint8Array. More...
 
bool IsUint8ClampedArray () const
 Returns true if this value is an Uint8ClampedArray. More...
 
bool IsInt8Array () const
 Returns true if this value is an Int8Array. More...
 
bool IsUint16Array () const
 Returns true if this value is an Uint16Array. More...
 
bool IsInt16Array () const
 Returns true if this value is an Int16Array. More...
 
bool IsUint32Array () const
 Returns true if this value is an Uint32Array. More...
 
bool IsInt32Array () const
 Returns true if this value is an Int32Array. More...
 
bool IsFloat32Array () const
 Returns true if this value is a Float32Array. More...
 
bool IsFloat64Array () const
 Returns true if this value is a Float64Array. More...
 
bool IsDataView () const
 Returns true if this value is a DataView. More...
 
Local< BooleanToBoolean () const
 
Local< NumberToNumber () const
 
Local< StringToString () const
 
Local< StringToDetailString () const
 
Local< ObjectToObject () const
 
Local< IntegerToInteger () const
 
Local< Uint32ToUint32 () const
 
Local< Int32ToInt32 () const
 
Local< Uint32ToArrayIndex () const
 Attempts to convert a string to an array index. More...
 
bool BooleanValue () const
 
double NumberValue () const
 
int64_t IntegerValue () const
 
uint32_t Uint32Value () const
 
int32_t Int32Value () const
 
bool Equals (Handle< Value > that) const
 JS ==. More...
 
bool StrictEquals (Handle< Value > that) const
 
bool SameValue (Handle< Value > that) const
 

Static Public Member Functions

static Local< SymbolNew (Isolate *isolate, Local< String > name=Local< String >())
 
static Local< SymbolFor (Isolate *isolate, Local< String > name)
 
static Local< SymbolForApi (Isolate *isolate, Local< String > name)
 
static Local< SymbolGetIterator (Isolate *isolate)
 
static Local< SymbolGetUnscopables (Isolate *isolate)
 
static SymbolCast (v8::Value *obj)
 
- Static Public Member Functions inherited from v8::Name
static NameCast (v8::Value *obj)
 
- Static Public Member Functions inherited from v8::Value
template<class T >
static ValueCast (T *value)
 

Private Member Functions

 Symbol ()
 

Static Private Member Functions

static void CheckCast (v8::Value *obj)
 

Detailed Description

A JavaScript symbol (ECMA-262 edition 6)

This is an experimental feature. Use at your own risk.

Definition at line 2099 of file v8.h.

Constructor & Destructor Documentation

◆ Symbol()

v8::Symbol::Symbol ( )
private

Member Function Documentation

◆ Cast()

Symbol * v8::Symbol::Cast ( v8::Value obj)
inlinestatic

Definition at line 6582 of file v8.h.

6582  {
6583 #ifdef V8_ENABLE_CHECKS
6584  CheckCast(value);
6585 #endif
6586  return static_cast<Symbol*>(value);
6587 }
static void CheckCast(v8::Value *obj)
Definition: api.cc:2738

◆ CheckCast()

void v8::Symbol::CheckCast ( v8::Value obj)
staticprivate

Definition at line 2738 of file api.cc.

2738  {
2740  Utils::ApiCheck(obj->IsSymbol(),
2741  "v8::Symbol::Cast()",
2742  "Could not convert to symbol");
2743 }
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:177
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288

References v8::Utils::ApiCheck(), and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ For()

Local< Symbol > v8::Symbol::For ( Isolate isolate,
Local< String name 
)
static

Definition at line 6201 of file api.cc.

6201  {
6202  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6204  i::Handle<i::String> part = i_isolate->factory()->for_string();
6205  return Utils::ToLocal(SymbolFor(i_isolate, i_name, part));
6206 }
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
Factory * factory()
Definition: isolate.h:982
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
static i::Handle< i::Symbol > SymbolFor(i::Isolate *isolate, i::Handle< i::String > name, i::Handle< i::String > part)
Definition: api.cc:6182

References v8::internal::Isolate::factory(), name, v8::Utils::OpenHandle(), v8::SymbolFor(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ ForApi()

Local< Symbol > v8::Symbol::ForApi ( Isolate isolate,
Local< String name 
)
static

Definition at line 6209 of file api.cc.

6209  {
6210  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6212  i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6213  return Utils::ToLocal(SymbolFor(i_isolate, i_name, part));
6214 }

References v8::internal::Isolate::factory(), name, v8::Utils::OpenHandle(), v8::SymbolFor(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ GetIterator()

Local< Symbol > v8::Symbol::GetIterator ( Isolate isolate)
static

Definition at line 6226 of file api.cc.

6226  {
6227  return GetWellKnownSymbol(isolate, "Symbol.iterator");
6228 }
static Local< Symbol > GetWellKnownSymbol(Isolate *isolate, const char *name)
Definition: api.cc:6217

References v8::GetWellKnownSymbol().

+ Here is the call graph for this function:

◆ GetUnscopables()

Local< Symbol > v8::Symbol::GetUnscopables ( Isolate isolate)
static

Definition at line 6231 of file api.cc.

6231  {
6232  return GetWellKnownSymbol(isolate, "Symbol.unscopables");
6233 }

References v8::GetWellKnownSymbol().

+ Here is the call graph for this function:

◆ Name()

Local< Value > v8::Symbol::Name ( ) const

Definition at line 4932 of file api.cc.

4932  {
4934  i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
4935  return Utils::ToLocal(name);
4936 }

References name, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ New()

Local< Symbol > v8::Symbol::New ( Isolate isolate,
Local< String name = Local<String>() 
)
static

Definition at line 6172 of file api.cc.

6172  {
6173  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6174  LOG_API(i_isolate, "Symbol::New()");
6175  ENTER_V8(i_isolate);
6176  i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6177  if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
6178  return Utils::ToLocal(result);
6179 }
#define LOG_API(isolate, expr)
Definition: api.cc:52
#define ENTER_V8(isolate)
Definition: api.cc:54

References ENTER_V8, v8::internal::Isolate::factory(), LOG_API, name, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: