33// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44
55use super :: RealmIdentifier ;
6+ #[ cfg( feature = "weak-refs" ) ]
7+ use crate :: ecmascript:: builtins:: keyed_collections:: {
8+ weak_map_objects:: {
9+ weak_map_constructor:: WeakMapConstructor , weak_map_prototype:: WeakMapPrototype ,
10+ } ,
11+ weak_set_objects:: {
12+ weak_set_constructor:: WeakSetConstructor , weak_set_prototype:: WeakSetPrototype ,
13+ } ,
14+ } ;
15+ #[ cfg( feature = "weak-refs" ) ]
16+ use crate :: ecmascript:: builtins:: managing_memory:: weak_ref_objects:: {
17+ weak_ref_constructor:: WeakRefConstructor , weak_ref_prototype:: WeakRefPrototype ,
18+ } ;
619#[ cfg( feature = "date" ) ]
720use crate :: ecmascript:: builtins:: numbers_and_dates:: date_objects:: {
821 date_constructor:: DateConstructor , date_prototype:: DatePrototype ,
@@ -76,21 +89,10 @@ use crate::{
7689 set_iterator_objects:: set_iterator_prototype:: SetIteratorPrototype ,
7790 set_prototype:: SetPrototype ,
7891 } ,
79- weak_map_objects:: {
80- weak_map_constructor:: WeakMapConstructor , weak_map_prototype:: WeakMapPrototype ,
81- } ,
82- weak_set_objects:: {
83- weak_set_constructor:: WeakSetConstructor , weak_set_prototype:: WeakSetPrototype ,
84- } ,
8592 } ,
86- managing_memory:: {
87- finalization_registry_objects:: {
88- finalization_registry_constructor:: FinalizationRegistryConstructor ,
89- finalization_registry_prototype:: FinalizationRegistryPrototype ,
90- } ,
91- weak_ref_objects:: {
92- weak_ref_constructor:: WeakRefConstructor , weak_ref_prototype:: WeakRefPrototype ,
93- } ,
93+ managing_memory:: finalization_registry_objects:: {
94+ finalization_registry_constructor:: FinalizationRegistryConstructor ,
95+ finalization_registry_prototype:: FinalizationRegistryPrototype ,
9496 } ,
9597 primitive_objects:: PrimitiveObject ,
9698 reflection:: { proxy_constructor:: ProxyConstructor , reflect_object:: ReflectObject } ,
@@ -218,8 +220,11 @@ pub enum ProtoIntrinsics {
218220 #[ cfg( feature = "array-buffer" ) ]
219221 Uint8Array ,
220222 UriError ,
223+ #[ cfg( feature = "weak-refs" ) ]
221224 WeakMap ,
225+ #[ cfg( feature = "weak-refs" ) ]
222226 WeakRef ,
227+ #[ cfg( feature = "weak-refs" ) ]
223228 WeakSet ,
224229}
225230
@@ -304,9 +309,13 @@ impl Intrinsics {
304309 SetPrototype :: create_intrinsic ( agent, realm) ;
305310 SetConstructor :: create_intrinsic ( agent, realm) ;
306311 SetIteratorPrototype :: create_intrinsic ( agent, realm) ;
312+ #[ cfg( feature = "weak-refs" ) ]
307313 WeakMapPrototype :: create_intrinsic ( agent, realm) ;
314+ #[ cfg( feature = "weak-refs" ) ]
308315 WeakMapConstructor :: create_intrinsic ( agent, realm) ;
316+ #[ cfg( feature = "weak-refs" ) ]
309317 WeakSetPrototype :: create_intrinsic ( agent, realm) ;
318+ #[ cfg( feature = "weak-refs" ) ]
310319 WeakSetConstructor :: create_intrinsic ( agent, realm) ;
311320 #[ cfg( feature = "array-buffer" ) ]
312321 ArrayBufferPrototype :: create_intrinsic ( agent, realm) ;
@@ -323,7 +332,9 @@ impl Intrinsics {
323332 AtomicsObject :: create_intrinsic ( agent, realm) ;
324333 #[ cfg( feature = "json" ) ]
325334 JSONObject :: create_intrinsic ( agent, realm) ;
335+ #[ cfg( feature = "weak-refs" ) ]
326336 WeakRefPrototype :: create_intrinsic ( agent, realm) ;
337+ #[ cfg( feature = "weak-refs" ) ]
327338 WeakRefConstructor :: create_intrinsic ( agent, realm) ;
328339 FinalizationRegistryPrototype :: create_intrinsic ( agent, realm) ;
329340 FinalizationRegistryConstructor :: create_intrinsic ( agent, realm) ;
@@ -410,8 +421,11 @@ impl Intrinsics {
410421 ProtoIntrinsics :: Uint32Array => self . uint32_array_prototype ( ) . into ( ) ,
411422 #[ cfg( feature = "array-buffer" ) ]
412423 ProtoIntrinsics :: Uint8Array => self . uint8_array_prototype ( ) . into ( ) ,
424+ #[ cfg( feature = "weak-refs" ) ]
413425 ProtoIntrinsics :: WeakMap => self . weak_map_prototype ( ) . into ( ) ,
426+ #[ cfg( feature = "weak-refs" ) ]
414427 ProtoIntrinsics :: WeakRef => self . weak_ref_prototype ( ) . into ( ) ,
428+ #[ cfg( feature = "weak-refs" ) ]
415429 ProtoIntrinsics :: WeakSet => self . weak_set_prototype ( ) . into ( ) ,
416430 }
417431 }
@@ -1518,55 +1532,64 @@ impl Intrinsics {
15181532 }
15191533
15201534 /// %WeakMap.prototype%
1535+ #[ cfg( feature = "weak-refs" ) ]
15211536 pub ( crate ) fn weak_map_prototype ( & self ) -> OrdinaryObject {
15221537 IntrinsicObjectIndexes :: WeakMapPrototype
15231538 . get_object_index ( self . object_index_base )
15241539 . into ( )
15251540 }
15261541
15271542 /// %WeakMap%
1543+ #[ cfg( feature = "weak-refs" ) ]
15281544 pub ( crate ) fn weak_map ( & self ) -> BuiltinFunction {
15291545 IntrinsicConstructorIndexes :: WeakMap
15301546 . get_builtin_function_index ( self . builtin_function_index_base )
15311547 . into ( )
15321548 }
15331549
1550+ #[ cfg( feature = "weak-refs" ) ]
15341551 pub ( crate ) fn weak_map_base_object ( & self ) -> ObjectIndex {
15351552 IntrinsicConstructorIndexes :: WeakMap . get_object_index ( self . object_index_base )
15361553 }
15371554
15381555 /// %WeakRef.prototype%
1556+ #[ cfg( feature = "weak-refs" ) ]
15391557 pub ( crate ) fn weak_ref_prototype ( & self ) -> OrdinaryObject {
15401558 IntrinsicObjectIndexes :: WeakRefPrototype
15411559 . get_object_index ( self . object_index_base )
15421560 . into ( )
15431561 }
15441562
15451563 /// %WeakRef%
1564+ #[ cfg( feature = "weak-refs" ) ]
15461565 pub ( crate ) fn weak_ref ( & self ) -> BuiltinFunction {
15471566 IntrinsicConstructorIndexes :: WeakRef
15481567 . get_builtin_function_index ( self . builtin_function_index_base )
15491568 . into ( )
15501569 }
15511570
1571+ #[ cfg( feature = "weak-refs" ) ]
15521572 pub ( crate ) fn weak_ref_base_object ( & self ) -> ObjectIndex {
15531573 IntrinsicConstructorIndexes :: WeakRef . get_object_index ( self . object_index_base )
15541574 }
15551575
15561576 /// %WeakSet.prototype%
1577+ #[ cfg( feature = "weak-refs" ) ]
15571578 pub ( crate ) fn weak_set_prototype ( & self ) -> OrdinaryObject {
15581579 IntrinsicObjectIndexes :: WeakSetPrototype
15591580 . get_object_index ( self . object_index_base )
15601581 . into ( )
15611582 }
15621583
15631584 /// %WeakSet%
1585+ #[ cfg( feature = "weak-refs" ) ]
15641586 pub ( crate ) fn weak_set ( & self ) -> BuiltinFunction {
15651587 IntrinsicConstructorIndexes :: WeakSet
15661588 . get_builtin_function_index ( self . builtin_function_index_base )
15671589 . into ( )
15681590 }
15691591
1592+ #[ cfg( feature = "weak-refs" ) ]
15701593 pub ( crate ) fn weak_set_base_object ( & self ) -> ObjectIndex {
15711594 IntrinsicConstructorIndexes :: WeakSet . get_object_index ( self . object_index_base )
15721595 }
@@ -1735,11 +1758,17 @@ impl HeapMarkAndSweep for Intrinsics {
17351758 self . unescape ( ) . mark_values ( queues) ;
17361759 self . uri_error_prototype ( ) . mark_values ( queues) ;
17371760 self . uri_error ( ) . mark_values ( queues) ;
1761+ #[ cfg( feature = "weak-refs" ) ]
17381762 self . weak_map_prototype ( ) . mark_values ( queues) ;
1763+ #[ cfg( feature = "weak-refs" ) ]
17391764 self . weak_map ( ) . mark_values ( queues) ;
1765+ #[ cfg( feature = "weak-refs" ) ]
17401766 self . weak_ref_prototype ( ) . mark_values ( queues) ;
1767+ #[ cfg( feature = "weak-refs" ) ]
17411768 self . weak_ref ( ) . mark_values ( queues) ;
1769+ #[ cfg( feature = "weak-refs" ) ]
17421770 self . weak_set_prototype ( ) . mark_values ( queues) ;
1771+ #[ cfg( feature = "weak-refs" ) ]
17431772 self . weak_set ( ) . mark_values ( queues) ;
17441773 }
17451774
0 commit comments