forked from rogchap/v8go
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
symbol.cc
64 lines (61 loc) · 1.55 KB
/
symbol.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "symbol.h"
#include "context.h"
#include "isolate-macros.h"
#include "utils.h"
#include "value-macros.h"
using namespace v8;
ValuePtr BuiltinSymbol(IsolatePtr iso, SymbolIndex idx) {
ISOLATE_SCOPE(iso);
INTERNAL_CONTEXT(iso);
Local<Symbol> sym;
switch (idx) {
case SYMBOL_ASYNC_ITERATOR:
sym = Symbol::GetAsyncIterator(iso);
break;
case SYMBOL_HAS_INSTANCE:
sym = Symbol::GetHasInstance(iso);
break;
case SYMBOL_IS_CONCAT_SPREADABLE:
sym = Symbol::GetIsConcatSpreadable(iso);
break;
case SYMBOL_ITERATOR:
sym = Symbol::GetIterator(iso);
break;
case SYMBOL_MATCH:
sym = Symbol::GetMatch(iso);
break;
case SYMBOL_REPLACE:
sym = Symbol::GetReplace(iso);
break;
case SYMBOL_SEARCH:
sym = Symbol::GetSearch(iso);
break;
case SYMBOL_SPLIT:
sym = Symbol::GetSplit(iso);
break;
case SYMBOL_TO_PRIMITIVE:
sym = Symbol::GetToPrimitive(iso);
break;
case SYMBOL_TO_STRING_TAG:
sym = Symbol::GetToStringTag(iso);
break;
case SYMBOL_UNSCOPABLES:
sym = Symbol::GetUnscopables(iso);
break;
default:
return nullptr;
}
m_value* val = new m_value;
val->id = 0;
val->iso = iso;
val->ctx = ctx;
val->ptr = Global<Value>(iso, sym);
return tracked_value(ctx, val);
}
const char* SymbolDescription(ValuePtr ptr) {
LOCAL_VALUE(ptr);
Local<Symbol> sym = value.As<Symbol>();
Local<Value> descr = sym->Description(iso);
String::Utf8Value utf8(iso, descr);
return CopyString(utf8);
}