MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_debug_symbol

Function gjs_debug_symbol

gjs/jsapi-util-string.cpp:521–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521std::string gjs_debug_symbol(JS::Symbol* const sym) {
522 if (!sym)
523 return "<null symbol>";
524
525 /* This is OK because JS::GetSymbolCode() and JS::GetSymbolDescription()
526 * can't cause a garbage collection */
527 JS::HandleSymbol handle = JS::HandleSymbol::fromMarkedLocation(&sym);
528 JS::SymbolCode code = JS::GetSymbolCode(handle);
529 JSString* descr = JS::GetSymbolDescription(handle);
530
531 if (static_cast<size_t>(code) < JS::WellKnownSymbolLimit)
532 return gjs_debug_string(descr);
533
534 std::ostringstream out;
535 if (code == JS::SymbolCode::InSymbolRegistry) {
536 out << "Symbol.for(";
537 if (descr)
538 out << gjs_debug_string(descr);
539 else
540 out << "undefined";
541 out << ")";
542 return out.str();
543 }
544 if (code == JS::SymbolCode::UniqueSymbol) {
545 if (descr)
546 out << "Symbol(" << gjs_debug_string(descr) << ")";
547 else
548 out << "<Symbol at " << sym << ">";
549 return out.str();
550 }
551
552 out << "<unexpected symbol code " << static_cast<uint32_t>(code) << ">";
553 return out.str();
554}
555
556std::string gjs_debug_object(JSObject* const obj) {
557 if (!obj)

Callers 1

gjs_debug_valueFunction · 0.85

Calls 1

gjs_debug_stringFunction · 0.85

Tested by

no test coverage detected