11//! Data structures that contain intrinsic objects and constructors.
22
3- use boa_gc:: { Finalize , Trace } ;
3+ use boa_gc:: { Finalize , Trace , WeakGc } ;
44use boa_macros:: js_str;
55
66use crate :: {
@@ -14,7 +14,7 @@ use crate::{
1414 JsFunction , JsObject , Object , CONSTRUCTOR , PROTOTYPE ,
1515 } ,
1616 property:: { Attribute , PropertyKey } ,
17- realm:: Realm ,
17+ realm:: { Realm , RealmInner } ,
1818 JsSymbol ,
1919} ;
2020
@@ -43,8 +43,8 @@ impl Intrinsics {
4343 /// To initialize all the intrinsics with their spec properties, see [`Realm::initialize`].
4444 ///
4545 /// [`Realm::initialize`]: crate::realm::Realm::initialize
46- pub ( crate ) fn uninit ( root_shape : & RootShape ) -> Option < Self > {
47- let constructors = StandardConstructors :: default ( ) ;
46+ pub ( crate ) fn uninit ( root_shape : & RootShape , realm_inner : WeakGc < RealmInner > ) -> Option < Self > {
47+ let constructors = StandardConstructors :: new ( realm_inner ) ;
4848 let templates = ObjectTemplates :: new ( root_shape, & constructors) ;
4949
5050 Some ( Self {
@@ -99,9 +99,9 @@ impl StandardConstructor {
9999 }
100100
101101 /// Similar to `with_prototype`, but the prototype is lazily initialized.
102- fn with_lazy ( init : fn ( & Realm ) -> ( ) ) -> Self {
102+ fn with_lazy ( init : fn ( & Realm ) -> ( ) , realm_inner : WeakGc < RealmInner > ) -> Self {
103103 Self {
104- constructor : JsFunction :: lazy_intrinsic_function ( true , init) ,
104+ constructor : JsFunction :: lazy_intrinsic_function ( true , init, realm_inner ) ,
105105 prototype : JsObject :: default ( ) ,
106106 }
107107 }
@@ -214,8 +214,8 @@ pub struct StandardConstructors {
214214 calendar : StandardConstructor ,
215215}
216216
217- impl Default for StandardConstructors {
218- fn default ( ) -> Self {
217+ impl StandardConstructors {
218+ fn new ( realm_inner : WeakGc < RealmInner > ) -> Self {
219219 Self {
220220 object : StandardConstructor :: with_prototype ( JsObject :: from_object_and_vtable (
221221 Object :: < OrdinaryObject > :: default ( ) ,
@@ -230,7 +230,7 @@ impl Default for StandardConstructors {
230230 } ,
231231 async_function : StandardConstructor :: default ( ) ,
232232 generator_function : StandardConstructor :: default ( ) ,
233- array : StandardConstructor :: with_lazy ( Array :: init) ,
233+ array : StandardConstructor :: with_lazy ( Array :: init, realm_inner ) ,
234234 bigint : StandardConstructor :: default ( ) ,
235235 number : StandardConstructor :: with_prototype ( JsObject :: from_proto_and_data ( None , 0.0 ) ) ,
236236 boolean : StandardConstructor :: with_prototype ( JsObject :: from_proto_and_data (
0 commit comments