Browse Source

LibJS: Convert SymbolObject::create() to NonnullGCPtr

Linus Groh 2 năm trước cách đây
mục cha
commit
dd3d133968

+ 2 - 2
Userland/Libraries/LibJS/Runtime/SymbolObject.cpp

@@ -10,9 +10,9 @@
 
 
 namespace JS {
 namespace JS {
 
 
-SymbolObject* SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
+NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
 {
 {
-    return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
+    return *realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
 }
 }
 
 
 SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
 SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)

+ 1 - 1
Userland/Libraries/LibJS/Runtime/SymbolObject.h

@@ -15,7 +15,7 @@ class SymbolObject : public Object {
     JS_OBJECT(SymbolObject, Object);
     JS_OBJECT(SymbolObject, Object);
 
 
 public:
 public:
-    static SymbolObject* create(Realm&, Symbol&);
+    static NonnullGCPtr<SymbolObject> create(Realm&, Symbol&);
 
 
     virtual ~SymbolObject() override = default;
     virtual ~SymbolObject() override = default;
 
 

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Value.cpp

@@ -544,7 +544,7 @@ ThrowCompletionOr<Object*> Value::to_object(VM& vm) const
     // Symbol
     // Symbol
     case SYMBOL_TAG:
     case SYMBOL_TAG:
         // Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 20.4 for a description of Symbol objects.
         // Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 20.4 for a description of Symbol objects.
-        return SymbolObject::create(realm, const_cast<JS::Symbol&>(as_symbol()));
+        return SymbolObject::create(realm, const_cast<JS::Symbol&>(as_symbol())).ptr();
     // BigInt
     // BigInt
     case BIGINT_TAG:
     case BIGINT_TAG:
         // Return a new BigInt object whose [[BigIntData]] internal slot is set to argument. See 21.2 for a description of BigInt objects.
         // Return a new BigInt object whose [[BigIntData]] internal slot is set to argument. See 21.2 for a description of BigInt objects.