Rename and retype Symbol name to description
Change-Id: I2a1ad1835b751237b350e56d64e3475459bfb7a6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873715 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#64636}
This commit is contained in:
parent
572f536a54
commit
7bd4068101
19
include/v8.h
19
include/v8.h
@ -3246,30 +3246,35 @@ class V8_EXPORT String : public Name {
|
||||
class V8_EXPORT Symbol : public Name {
|
||||
public:
|
||||
/**
|
||||
* Returns the print name string of the symbol, or undefined if none.
|
||||
* Returns the description string of the symbol, or undefined if none.
|
||||
*/
|
||||
Local<Value> Name() const;
|
||||
Local<Value> Description() const;
|
||||
|
||||
V8_DEPRECATE_SOON("Use Symbol::Description()")
|
||||
Local<Value> Name() const { return Description(); }
|
||||
|
||||
/**
|
||||
* Create a symbol. If name is not empty, it will be used as the description.
|
||||
* Create a symbol. If description is not empty, it will be used as the
|
||||
* description.
|
||||
*/
|
||||
static Local<Symbol> New(Isolate* isolate,
|
||||
Local<String> name = Local<String>());
|
||||
Local<String> description = Local<String>());
|
||||
|
||||
/**
|
||||
* Access global symbol registry.
|
||||
* Note that symbols created this way are never collected, so
|
||||
* they should only be used for statically fixed properties.
|
||||
* Also, there is only one global name space for the names used as keys.
|
||||
* Also, there is only one global name space for the descriptions used as
|
||||
* keys.
|
||||
* To minimize the potential for clashes, use qualified names as keys.
|
||||
*/
|
||||
static Local<Symbol> For(Isolate *isolate, Local<String> name);
|
||||
static Local<Symbol> For(Isolate* isolate, Local<String> description);
|
||||
|
||||
/**
|
||||
* Retrieve a global symbol. Similar to |For|, but using a separate
|
||||
* registry that is not accessible by (and cannot clash with) JavaScript code.
|
||||
*/
|
||||
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
|
||||
static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
|
||||
|
||||
// Well-known symbols
|
||||
static Local<Symbol> GetAsyncIterator(Isolate* isolate);
|
||||
|
@ -5477,28 +5477,28 @@ v8::String::GetExternalOneByteStringResource() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Local<Value> Symbol::Name() const {
|
||||
Local<Value> Symbol::Description() const {
|
||||
i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
|
||||
|
||||
i::Isolate* isolate;
|
||||
if (!i::GetIsolateFromHeapObject(*sym, &isolate)) {
|
||||
// Symbol is in RO_SPACE, which means that its name is also in RO_SPACE.
|
||||
// Since RO_SPACE objects are immovable we can use the Handle(Address*)
|
||||
// constructor with the address of the name field in the Symbol object
|
||||
// without needing an isolate.
|
||||
// Symbol is in RO_SPACE, which means that its description is also in
|
||||
// RO_SPACE. Since RO_SPACE objects are immovable we can use the
|
||||
// Handle(Address*) constructor with the address of the description
|
||||
// field in the Symbol object without needing an isolate.
|
||||
DCHECK(!COMPRESS_POINTERS_BOOL);
|
||||
i::Handle<i::HeapObject> ro_name(reinterpret_cast<i::Address*>(
|
||||
sym->GetFieldAddress(i::Symbol::kNameOffset)));
|
||||
return Utils::ToLocal(ro_name);
|
||||
i::Handle<i::HeapObject> ro_description(reinterpret_cast<i::Address*>(
|
||||
sym->GetFieldAddress(i::Symbol::kDescriptionOffset)));
|
||||
return Utils::ToLocal(ro_description);
|
||||
}
|
||||
|
||||
i::Handle<i::Object> name(sym->name(), isolate);
|
||||
i::Handle<i::Object> description(sym->description(), isolate);
|
||||
|
||||
return Utils::ToLocal(name);
|
||||
return Utils::ToLocal(description);
|
||||
}
|
||||
|
||||
Local<Value> Private::Name() const {
|
||||
return reinterpret_cast<const Symbol*>(this)->Name();
|
||||
return reinterpret_cast<const Symbol*>(this)->Description();
|
||||
}
|
||||
|
||||
double Number::Value() const {
|
||||
@ -7860,7 +7860,7 @@ Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
|
||||
LOG_API(i_isolate, Symbol, New);
|
||||
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
|
||||
i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
|
||||
if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
|
||||
if (!name.IsEmpty()) result->set_description(*Utils::OpenHandle(*name));
|
||||
return Utils::ToLocal(result);
|
||||
}
|
||||
|
||||
@ -7907,7 +7907,7 @@ Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
|
||||
LOG_API(i_isolate, Private, New);
|
||||
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
|
||||
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
|
||||
if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
|
||||
if (!name.IsEmpty()) symbol->set_description(*Utils::OpenHandle(*name));
|
||||
Local<Symbol> result = Utils::ToLocal(symbol);
|
||||
return v8::Local<Private>(reinterpret_cast<Private*>(*result));
|
||||
}
|
||||
|
@ -582,7 +582,8 @@ void CallPrinter::PrintLiteral(Handle<Object> value, bool quote) {
|
||||
Print(isolate_->factory()->NumberToString(value));
|
||||
} else if (value->IsSymbol()) {
|
||||
// Symbols can only occur as literals if they were inserted by the parser.
|
||||
PrintLiteral(handle(Handle<Symbol>::cast(value)->name(), isolate_), false);
|
||||
PrintLiteral(handle(Handle<Symbol>::cast(value)->description(), isolate_),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ type AnyName = PrivateSymbol|PublicSymbol|String;
|
||||
@generateCppClass
|
||||
extern class Symbol extends Name {
|
||||
flags: int32;
|
||||
name: Object; // The print name of a symbol, or undefined if none.
|
||||
description: String|Undefined;
|
||||
}
|
||||
|
||||
type PublicSymbol extends Symbol;
|
||||
|
@ -28,7 +28,7 @@ BUILTIN(SymbolConstructor) {
|
||||
if (!description->IsUndefined(isolate)) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description,
|
||||
Object::ToString(isolate, description));
|
||||
result->set_name(*description);
|
||||
result->set_description(String::cast(*description));
|
||||
}
|
||||
return *result;
|
||||
}
|
||||
@ -55,7 +55,7 @@ BUILTIN(SymbolKeyFor) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
Object result;
|
||||
if (symbol->is_in_public_symbol_table()) {
|
||||
result = symbol->name();
|
||||
result = symbol->description();
|
||||
DCHECK(result.IsString());
|
||||
} else {
|
||||
result = ReadOnlyRoots(isolate).undefined_value();
|
||||
|
@ -13,13 +13,13 @@ namespace symbol {
|
||||
|
||||
// ES #sec-symbol.prototype.description
|
||||
transitioning javascript builtin SymbolPrototypeDescriptionGetter(
|
||||
js-implicit context: Context, receiver: JSAny)(): JSAny {
|
||||
js-implicit context: Context, receiver: JSAny)(): String|Undefined {
|
||||
// 1. Let s be the this value.
|
||||
// 2. Let sym be ? thisSymbolValue(s).
|
||||
const sym: Symbol =
|
||||
ThisSymbolValue(receiver, 'Symbol.prototype.description');
|
||||
// 3. Return sym.[[Description]].
|
||||
return Cast<JSAny>(sym.name) otherwise unreachable;
|
||||
return sym.description;
|
||||
}
|
||||
|
||||
// ES6 #sec-symbol.prototype-@@toprimitive
|
||||
|
@ -19,7 +19,7 @@ void WriteToFile(const char* prefix, FILE* file, Isolate* isolate,
|
||||
Local<Value> arg = args[i];
|
||||
Local<String> str_obj;
|
||||
|
||||
if (arg->IsSymbol()) arg = Local<Symbol>::Cast(arg)->Name();
|
||||
if (arg->IsSymbol()) arg = Local<Symbol>::Cast(arg)->Description();
|
||||
if (!arg->ToString(isolate->GetCurrentContext()).ToLocal(&str_obj)) return;
|
||||
|
||||
v8::String::Utf8Value str(isolate, str_obj);
|
||||
|
@ -1366,7 +1366,7 @@ void WriteToFile(FILE* file, const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Local<String> str_obj;
|
||||
|
||||
if (arg->IsSymbol()) {
|
||||
arg = Local<Symbol>::Cast(arg)->Name();
|
||||
arg = Local<Symbol>::Cast(arg)->Description();
|
||||
}
|
||||
if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
|
||||
.ToLocal(&str_obj)) {
|
||||
|
@ -275,7 +275,7 @@ void Symbol::SymbolVerify(Isolate* isolate) {
|
||||
TorqueGeneratedClassVerifiers::SymbolVerify(*this, isolate);
|
||||
CHECK(HasHashCode());
|
||||
CHECK_GT(Hash(), 0);
|
||||
CHECK(name().IsUndefined(isolate) || name().IsString());
|
||||
CHECK(description().IsUndefined(isolate) || description().IsString());
|
||||
CHECK_IMPLIES(IsPrivateName(), IsPrivate());
|
||||
}
|
||||
|
||||
|
@ -678,8 +678,8 @@ void JSRegExpStringIterator::JSRegExpStringIteratorPrint(
|
||||
void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
|
||||
PrintHeader(os, "Symbol");
|
||||
os << "\n - hash: " << Hash();
|
||||
os << "\n - name: " << Brief(name());
|
||||
if (name().IsUndefined()) {
|
||||
os << "\n - description: " << Brief(description());
|
||||
if (description().IsUndefined()) {
|
||||
os << " (" << PrivateSymbolToName() << ")";
|
||||
}
|
||||
os << "\n - private: " << is_private();
|
||||
@ -2333,10 +2333,10 @@ void Name::NameShortPrint() {
|
||||
} else {
|
||||
DCHECK(this->IsSymbol());
|
||||
Symbol s = Symbol::cast(*this);
|
||||
if (s.name().IsUndefined()) {
|
||||
if (s.description().IsUndefined()) {
|
||||
PrintF("#<%s>", s.PrivateSymbolToName());
|
||||
} else {
|
||||
PrintF("<%s>", String::cast(s.name()).ToCString().get());
|
||||
PrintF("<%s>", String::cast(s.description()).ToCString().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2348,10 +2348,11 @@ int Name::NameShortPrint(Vector<char> str) {
|
||||
} else {
|
||||
DCHECK(this->IsSymbol());
|
||||
Symbol s = Symbol::cast(*this);
|
||||
if (s.name().IsUndefined()) {
|
||||
if (s.description().IsUndefined()) {
|
||||
return SNPrintF(str, "#<%s>", s.PrivateSymbolToName());
|
||||
} else {
|
||||
return SNPrintF(str, "<%s>", String::cast(s.name()).ToCString().get());
|
||||
return SNPrintF(str, "<%s>",
|
||||
String::cast(s.description()).ToCString().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3871,7 +3871,7 @@ Handle<Symbol> Isolate::SymbolFor(RootIndex dictionary_index,
|
||||
if (entry.is_not_found()) {
|
||||
symbol =
|
||||
private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol();
|
||||
symbol->set_name(*key);
|
||||
symbol->set_description(*key);
|
||||
dictionary = NameDictionary::Add(this, dictionary, key, symbol,
|
||||
PropertyDetails::Empty(), &entry);
|
||||
switch (dictionary_index) {
|
||||
|
@ -1378,7 +1378,7 @@ Handle<Symbol> Factory::NewSymbol(AllocationType allocation) {
|
||||
Handle<Symbol> symbol(Symbol::cast(result), isolate());
|
||||
symbol->set_hash_field(Name::kIsNotArrayIndexMask |
|
||||
(hash << Name::kHashShift));
|
||||
symbol->set_name(*undefined_value());
|
||||
symbol->set_description(*undefined_value());
|
||||
symbol->set_flags(0);
|
||||
DCHECK(!symbol->is_private());
|
||||
return symbol;
|
||||
@ -1394,7 +1394,7 @@ Handle<Symbol> Factory::NewPrivateSymbol(AllocationType allocation) {
|
||||
Handle<Symbol> Factory::NewPrivateNameSymbol(Handle<String> name) {
|
||||
Handle<Symbol> symbol = NewSymbol();
|
||||
symbol->set_is_private_name();
|
||||
symbol->set_name(*name);
|
||||
symbol->set_description(*name);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
@ -706,7 +706,7 @@ void Heap::CreateInitialObjects() {
|
||||
#define SYMBOL_INIT(_, name, description) \
|
||||
Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
|
||||
Handle<String> name##d = factory->InternalizeUtf8String(#description); \
|
||||
name->set_name(*name##d); \
|
||||
name->set_description(*name##d); \
|
||||
roots_table()[RootIndex::k##name] = name->ptr();
|
||||
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
|
||||
#undef SYMBOL_INIT
|
||||
@ -715,7 +715,7 @@ void Heap::CreateInitialObjects() {
|
||||
Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
|
||||
Handle<String> name##d = factory->InternalizeUtf8String(#description); \
|
||||
name->set_is_well_known_symbol(true); \
|
||||
name->set_name(*name##d); \
|
||||
name->set_description(*name##d); \
|
||||
roots_table()[RootIndex::k##name] = name->ptr();
|
||||
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
|
||||
#undef SYMBOL_INIT
|
||||
|
@ -412,8 +412,8 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name,
|
||||
|
||||
if (name->IsPrivate()) {
|
||||
if (name->IsPrivateName() && !it.IsFound()) {
|
||||
Handle<String> name_string(String::cast(Symbol::cast(*name).name()),
|
||||
isolate());
|
||||
Handle<String> name_string(
|
||||
String::cast(Symbol::cast(*name).description()), isolate());
|
||||
return TypeError(MessageTemplate::kInvalidPrivateMemberRead, object,
|
||||
name_string);
|
||||
}
|
||||
@ -1451,8 +1451,8 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
|
||||
|
||||
if (name->IsPrivate()) {
|
||||
if (name->IsPrivateName() && !it.IsFound()) {
|
||||
Handle<String> name_string(String::cast(Symbol::cast(*name).name()),
|
||||
isolate());
|
||||
Handle<String> name_string(
|
||||
String::cast(Symbol::cast(*name).description()), isolate());
|
||||
return TypeError(MessageTemplate::kInvalidPrivateMemberWrite, object,
|
||||
name_string);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class V8ValueStringBuilder {
|
||||
|
||||
bool append(v8::Local<v8::Symbol> symbol) {
|
||||
m_builder.append("Symbol(");
|
||||
bool result = append(symbol->Name(), IgnoreUndefined);
|
||||
bool result = append(symbol->Description(), IgnoreUndefined);
|
||||
m_builder.append(')');
|
||||
return result;
|
||||
}
|
||||
|
@ -153,10 +153,10 @@ String16 abbreviateString(const String16& value, AbbreviateMode mode) {
|
||||
|
||||
String16 descriptionForSymbol(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Symbol> symbol) {
|
||||
return String16::concat(
|
||||
"Symbol(",
|
||||
toProtocolStringWithTypeCheck(context->GetIsolate(), symbol->Name()),
|
||||
")");
|
||||
return String16::concat("Symbol(",
|
||||
toProtocolStringWithTypeCheck(context->GetIsolate(),
|
||||
symbol->Description()),
|
||||
")");
|
||||
}
|
||||
|
||||
String16 descriptionForBigInt(v8::Local<v8::Context> context,
|
||||
|
@ -157,9 +157,9 @@ void Log::MessageBuilder::AppendSymbolName(Symbol symbol) {
|
||||
DCHECK(!symbol.is_null());
|
||||
OFStream& os = log_->os_;
|
||||
os << "symbol(";
|
||||
if (!symbol.name().IsUndefined()) {
|
||||
if (!symbol.description().IsUndefined()) {
|
||||
os << "\"";
|
||||
AppendSymbolNameDetails(String::cast(symbol.name()), false);
|
||||
AppendSymbolNameDetails(String::cast(symbol.description()), false);
|
||||
os << "\" ";
|
||||
}
|
||||
os << "hash " << std::hex << symbol.Hash() << std::dec << ")";
|
||||
|
@ -112,9 +112,9 @@ class CodeEventLogger::NameBuffer {
|
||||
} else {
|
||||
Symbol symbol = Symbol::cast(name);
|
||||
AppendBytes("symbol(");
|
||||
if (!symbol.name().IsUndefined()) {
|
||||
if (!symbol.description().IsUndefined()) {
|
||||
AppendBytes("\"");
|
||||
AppendString(String::cast(symbol.name()));
|
||||
AppendString(String::cast(symbol.description()));
|
||||
AppendBytes("\" ");
|
||||
}
|
||||
AppendBytes("hash ");
|
||||
|
@ -183,7 +183,7 @@ class Symbol : public TorqueGeneratedSymbol<Symbol, Name> {
|
||||
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
|
||||
#undef FLAGS_BIT_FIELDS
|
||||
|
||||
using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>;
|
||||
using BodyDescriptor = FixedBodyDescriptor<kDescriptionOffset, kSize, kSize>;
|
||||
|
||||
void SymbolShortPrint(std::ostream& os);
|
||||
|
||||
|
@ -469,13 +469,14 @@ Handle<String> Object::NoSideEffectsToString(Isolate* isolate,
|
||||
Handle<Symbol> symbol = Handle<Symbol>::cast(input);
|
||||
|
||||
if (symbol->is_private_name()) {
|
||||
return Handle<String>(String::cast(symbol->name()), isolate);
|
||||
return Handle<String>(String::cast(symbol->description()), isolate);
|
||||
}
|
||||
|
||||
IncrementalStringBuilder builder(isolate);
|
||||
builder.AppendCString("Symbol(");
|
||||
if (symbol->name().IsString()) {
|
||||
builder.AppendString(handle(String::cast(symbol->name()), isolate));
|
||||
if (symbol->description().IsString()) {
|
||||
builder.AppendString(
|
||||
handle(String::cast(symbol->description()), isolate));
|
||||
}
|
||||
builder.AppendCharacter(')');
|
||||
|
||||
@ -4352,7 +4353,8 @@ bool DescriptorArray::IsEqualTo(DescriptorArray other) {
|
||||
MaybeHandle<String> Name::ToFunctionName(Isolate* isolate, Handle<Name> name) {
|
||||
if (name->IsString()) return Handle<String>::cast(name);
|
||||
// ES6 section 9.2.11 SetFunctionName, step 4.
|
||||
Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate);
|
||||
Handle<Object> description(Handle<Symbol>::cast(name)->description(),
|
||||
isolate);
|
||||
if (description->IsUndefined(isolate)) {
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
@ -5725,11 +5727,11 @@ const char* Symbol::PrivateSymbolToName() const {
|
||||
|
||||
void Symbol::SymbolShortPrint(std::ostream& os) {
|
||||
os << "<Symbol:";
|
||||
if (!name().IsUndefined()) {
|
||||
if (!description().IsUndefined()) {
|
||||
os << " ";
|
||||
HeapStringAllocator allocator;
|
||||
StringStream accumulator(&allocator);
|
||||
String::cast(name()).StringShortPrint(&accumulator, false);
|
||||
String::cast(description()).StringShortPrint(&accumulator, false);
|
||||
os << accumulator.ToCString().get();
|
||||
} else {
|
||||
os << " (" << PrivateSymbolToName() << ")";
|
||||
|
@ -913,7 +913,8 @@ void V8HeapExplorer::ExtractStringReferences(HeapEntry* entry, String string) {
|
||||
}
|
||||
|
||||
void V8HeapExplorer::ExtractSymbolReferences(HeapEntry* entry, Symbol symbol) {
|
||||
SetInternalReference(entry, "name", symbol.name(), Symbol::kNameOffset);
|
||||
SetInternalReference(entry, "name", symbol.description(),
|
||||
Symbol::kDescriptionOffset);
|
||||
}
|
||||
|
||||
void V8HeapExplorer::ExtractJSCollectionReferences(HeapEntry* entry,
|
||||
|
@ -41,7 +41,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
|
||||
|
||||
if (!it.IsFound() && key->IsSymbol() &&
|
||||
Symbol::cast(*key).is_private_name()) {
|
||||
Handle<Object> name_string(Symbol::cast(*key).name(), isolate);
|
||||
Handle<Object> name_string(Symbol::cast(*key).description(), isolate);
|
||||
DCHECK(name_string->IsString());
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kInvalidPrivateMemberRead,
|
||||
@ -417,7 +417,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(
|
||||
|
||||
if (!it.IsFound() && key->IsSymbol() &&
|
||||
Symbol::cast(*key).is_private_name()) {
|
||||
Handle<Object> name_string(Symbol::cast(*key).name(), isolate);
|
||||
Handle<Object> name_string(Symbol::cast(*key).description(), isolate);
|
||||
DCHECK(name_string->IsString());
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kInvalidPrivateMemberWrite,
|
||||
|
@ -18,9 +18,10 @@ RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
|
||||
DCHECK_GE(1, args.length());
|
||||
Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
|
||||
if (args.length() == 1) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
|
||||
CHECK(name->IsString() || name->IsUndefined(isolate));
|
||||
if (name->IsString()) symbol->set_name(*name);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, description, 0);
|
||||
CHECK(description->IsString() || description->IsUndefined(isolate));
|
||||
if (description->IsString())
|
||||
symbol->set_description(String::cast(*description));
|
||||
}
|
||||
return *symbol;
|
||||
}
|
||||
@ -39,8 +40,8 @@ RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0);
|
||||
IncrementalStringBuilder builder(isolate);
|
||||
builder.AppendCString("Symbol(");
|
||||
if (symbol->name().IsString()) {
|
||||
builder.AppendString(handle(String::cast(symbol->name()), isolate));
|
||||
if (symbol->description().IsString()) {
|
||||
builder.AppendString(handle(String::cast(symbol->description()), isolate));
|
||||
}
|
||||
builder.AppendCharacter(')');
|
||||
RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
|
||||
|
@ -95,16 +95,16 @@ void SymbolAccessorGetter(Local<Name> name,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
CHECK(name->IsSymbol());
|
||||
Local<Symbol> sym = Local<Symbol>::Cast(name);
|
||||
if (sym->Name()->IsUndefined()) return;
|
||||
SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info);
|
||||
if (sym->Description()->IsUndefined()) return;
|
||||
SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info);
|
||||
}
|
||||
|
||||
void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
|
||||
const v8::PropertyCallbackInfo<void>& info) {
|
||||
CHECK(name->IsSymbol());
|
||||
Local<Symbol> sym = Local<Symbol>::Cast(name);
|
||||
if (sym->Name()->IsUndefined()) return;
|
||||
SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
|
||||
if (sym->Description()->IsUndefined()) return;
|
||||
SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info);
|
||||
}
|
||||
|
||||
void InterceptorGetter(Local<Name> generic_name,
|
||||
@ -154,7 +154,7 @@ void GenericInterceptorGetter(Local<Name> generic_name,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
Local<String> str;
|
||||
if (generic_name->IsSymbol()) {
|
||||
Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
|
||||
Local<Value> name = Local<Symbol>::Cast(generic_name)->Description();
|
||||
if (name->IsUndefined()) return;
|
||||
str = String::Concat(info.GetIsolate(), v8_str("_sym_"),
|
||||
Local<String>::Cast(name));
|
||||
@ -175,7 +175,7 @@ void GenericInterceptorSetter(Local<Name> generic_name, Local<Value> value,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
Local<String> str;
|
||||
if (generic_name->IsSymbol()) {
|
||||
Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
|
||||
Local<Value> name = Local<Symbol>::Cast(generic_name)->Description();
|
||||
if (name->IsUndefined()) return;
|
||||
str = String::Concat(info.GetIsolate(), v8_str("_sym_"),
|
||||
Local<String>::Cast(name));
|
||||
|
@ -2554,25 +2554,23 @@ void SymbolAccessorGetter(Local<Name> name,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
CHECK(name->IsSymbol());
|
||||
Local<Symbol> sym = Local<Symbol>::Cast(name);
|
||||
if (sym->Name()->IsUndefined())
|
||||
return;
|
||||
SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info);
|
||||
if (sym->Description()->IsUndefined()) return;
|
||||
SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info);
|
||||
}
|
||||
|
||||
void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
|
||||
const v8::PropertyCallbackInfo<void>& info) {
|
||||
CHECK(name->IsSymbol());
|
||||
Local<Symbol> sym = Local<Symbol>::Cast(name);
|
||||
if (sym->Name()->IsUndefined())
|
||||
return;
|
||||
SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
|
||||
if (sym->Description()->IsUndefined()) return;
|
||||
SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info);
|
||||
}
|
||||
|
||||
void SymbolAccessorGetterReturnsDefault(
|
||||
Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
CHECK(name->IsSymbol());
|
||||
Local<Symbol> sym = Local<Symbol>::Cast(name);
|
||||
if (sym->Name()->IsUndefined()) return;
|
||||
if (sym->Description()->IsUndefined()) return;
|
||||
info.GetReturnValue().Set(info.Data());
|
||||
}
|
||||
|
||||
@ -3201,7 +3199,8 @@ THREADED_TEST(SymbolProperties) {
|
||||
CHECK(!sym1->StrictEquals(sym2));
|
||||
CHECK(!sym2->StrictEquals(sym1));
|
||||
|
||||
CHECK(sym2->Name()->Equals(env.local(), v8_str("my-symbol")).FromJust());
|
||||
CHECK(
|
||||
sym2->Description()->Equals(env.local(), v8_str("my-symbol")).FromJust());
|
||||
|
||||
v8::Local<v8::Value> sym_val = sym2;
|
||||
CHECK(sym_val->IsSymbol());
|
||||
@ -14027,7 +14026,7 @@ void CheckIsSymbolAt(v8::Isolate* isolate, v8::Local<v8::Array> properties,
|
||||
.ToLocalChecked();
|
||||
CHECK(value->IsSymbol());
|
||||
v8::String::Utf8Value symbol_name(isolate,
|
||||
Local<Symbol>::Cast(value)->Name());
|
||||
Local<Symbol>::Cast(value)->Description());
|
||||
if (strcmp(name, *symbol_name) != 0) {
|
||||
FATAL("properties[%u] was Symbol('%s') instead of Symbol('%s').", index,
|
||||
name, *symbol_name);
|
||||
|
@ -378,7 +378,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
v8::Local<v8::String> str_obj;
|
||||
|
||||
if (arg->IsSymbol()) {
|
||||
arg = v8::Local<v8::Symbol>::Cast(arg)->Name();
|
||||
arg = v8::Local<v8::Symbol>::Cast(arg)->Description();
|
||||
}
|
||||
if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
|
||||
.ToLocal(&str_obj)) {
|
||||
|
@ -277,7 +277,7 @@ extras_accessors = [
|
||||
'ConsString, second, String, kSecondOffset',
|
||||
'SlicedString, offset, SMI, kOffsetOffset',
|
||||
'ThinString, actual, String, kActualOffset',
|
||||
'Symbol, name, Object, kNameOffset',
|
||||
'Symbol, name, Object, kDescriptionOffset',
|
||||
];
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user