@@ -6,9 +6,13 @@ use crate::{
66 execution:: { Agent , ProtoIntrinsics } ,
77 types:: { InternalMethods , InternalSlots , Object , OrdinaryObject , Value } ,
88 } ,
9- engine:: context:: bindable_handle,
9+ engine:: {
10+ context:: { Bindable , bindable_handle} ,
11+ rootable:: { HeapRootData , HeapRootRef , Rootable } ,
12+ } ,
1013 heap:: {
11- CompactionLists , HeapMarkAndSweep , HeapSweepWeakReference , WorkQueues , indexes:: BaseIndex ,
14+ CompactionLists , CreateHeapData , Heap , HeapMarkAndSweep , HeapSweepWeakReference ,
15+ WorkQueues , indexes:: BaseIndex ,
1216 } ,
1317} ;
1418
@@ -19,10 +23,6 @@ pub(crate) mod data;
1923pub struct TemporalPlainTime < ' a > ( BaseIndex < ' a , PlainTimeHeapData < ' static > > ) ;
2024
2125impl TemporalPlainTime < ' _ > {
22- pub ( crate ) fn inner_plain_date_time ( self , agent : & Agent ) -> & temporal_rs:: PlainTime {
23- & agent[ self ] . plain_time
24- }
25-
2626 //TODO
2727 pub ( crate ) const fn _def ( ) -> Self {
2828 TemporalPlainTime ( BaseIndex :: from_u32_index ( 0 ) )
@@ -109,6 +109,29 @@ impl IndexMut<TemporalPlainTime<'_>> for Vec<PlainTimeHeapData<'static>> {
109109 }
110110}
111111
112+ impl Rootable for TemporalPlainTime < ' _ > {
113+ type RootRepr = HeapRootRef ;
114+
115+ fn to_root_repr ( value : Self ) -> Result < Self :: RootRepr , HeapRootData > {
116+ Err ( HeapRootData :: PlainTime ( value. unbind ( ) ) )
117+ }
118+
119+ fn from_root_repr ( value : & Self :: RootRepr ) -> Result < Self , HeapRootRef > {
120+ Err ( * value)
121+ }
122+
123+ fn from_heap_ref ( heap_ref : HeapRootRef ) -> Self :: RootRepr {
124+ heap_ref
125+ }
126+
127+ fn from_heap_data ( heap_data : HeapRootData ) -> Option < Self > {
128+ match heap_data {
129+ HeapRootData :: PlainTime ( object) => Some ( object) ,
130+ _ => None ,
131+ }
132+ }
133+ }
134+
112135impl HeapMarkAndSweep for TemporalPlainTime < ' static > {
113136 fn mark_values ( & self , queues : & mut WorkQueues ) {
114137 queues. plain_times . push ( * self ) ;
@@ -124,3 +147,11 @@ impl HeapSweepWeakReference for TemporalPlainTime<'static> {
124147 compactions. plain_times . shift_weak_index ( self . 0 ) . map ( Self )
125148 }
126149}
150+
151+ impl < ' a > CreateHeapData < PlainTimeHeapData < ' a > , TemporalPlainTime < ' a > > for Heap {
152+ fn create ( & mut self , data : PlainTimeHeapData < ' a > ) -> TemporalPlainTime < ' a > {
153+ self . plain_times . push ( data. unbind ( ) ) ;
154+ self . alloc_counter += core:: mem:: size_of :: < PlainTimeHeapData < ' static > > ( ) ;
155+ TemporalPlainTime ( BaseIndex :: last_t ( & self . plain_times ) )
156+ }
157+ }
0 commit comments