2525 UintT ,
2626)
2727from .value import (
28- NO_METADATA ,
28+ NO_SIZE ,
2929 AggregateValue ,
3030 AllocRefValue ,
3131 BoolValue ,
3232 DynamicSize ,
3333 IntValue ,
34+ Metadata ,
3435 RangeValue ,
3536 StaticSize ,
3637 StrValue ,
@@ -120,18 +121,30 @@ def _decode_memory_alloc_or_unable(
120121 except KeyError :
121122 return UnableToDecodeValue (f'Unknown pointee type: { pointee_ty } ' )
122123
123- metadata = _metadata (pointee_type_info )
124+ metadata_size = _metadata_size (pointee_type_info )
124125
125126 if len (data ) == 8 :
126127 # single slim pointer (assumes usize == u64)
127- return AllocRefValue (alloc_id = alloc_id , metadata = metadata )
128+ return AllocRefValue (
129+ alloc_id = alloc_id ,
130+ metadata = Metadata (
131+ size = metadata_size ,
132+ pointer_offset = 0 ,
133+ origin_size = metadata_size ,
134+ ),
135+ )
128136
129- if len (data ) == 16 and metadata == DynamicSize (1 ):
137+ if len (data ) == 16 and metadata_size == DynamicSize (1 ):
130138 # sufficient data to decode dynamic size (assumes usize == u64)
131139 # expect fat pointer
140+ actual_size = DynamicSize (int .from_bytes (data [8 :16 ], byteorder = 'little' , signed = False ))
132141 return AllocRefValue (
133142 alloc_id = alloc_id ,
134- metadata = DynamicSize (int .from_bytes (data [8 :16 ], byteorder = 'little' , signed = False )),
143+ metadata = Metadata (
144+ size = actual_size ,
145+ pointer_offset = 0 ,
146+ origin_size = actual_size ,
147+ ),
135148 )
136149
137150 return UnableToDecodeValue (f'Unable to decode alloc: { data !r} , of type: { type_info } ' )
@@ -145,14 +158,14 @@ def _pointee_ty(type_info: TypeMetadata) -> Ty | None:
145158 return None
146159
147160
148- def _metadata (type_info : TypeMetadata ) -> MetadataSize :
161+ def _metadata_size (type_info : TypeMetadata ) -> MetadataSize :
149162 match type_info :
150163 case ArrayT (length = None ):
151164 return DynamicSize (1 ) # 1 is a placeholder, the actual size is inferred from the slice data
152165 case ArrayT (length = int () as length ):
153166 return StaticSize (length )
154167 case _:
155- return NO_METADATA
168+ return NO_SIZE
156169
157170
158171def decode_value_or_unable (data : bytes , type_info : TypeMetadata , types : Mapping [Ty , TypeMetadata ]) -> Value :
0 commit comments