@@ -195,10 +195,16 @@ object (self)
195195 ~(tgtbtype : btype_t option )
196196 (c : bcompinfo_t )
197197 (xoffset : xpr_t ): memory_offset_t traceresult =
198+ let is_void_tgtbtype =
199+ match tgtbtype with
200+ | Some (TVoid _ ) -> true
201+ | _ -> false in
198202 let check_tgttype_compliance (t : btype_t ) (s : int ) =
199203 match tgtsize, tgtbtype with
200204 | None , None -> true
201205 | Some size , None -> size = s
206+ | Some size , Some (TVoid _ ) -> size = s
207+ | None , Some (TVoid _ ) -> true
202208 | None , Some ty -> btype_equal ty t
203209 | Some size , Some ty -> size = s && btype_equal ty t in
204210 let compliance_failure (t : btype_t ) (s : int ) =
@@ -246,7 +252,10 @@ object (self)
246252 let offset = offset - foff in
247253 tbind
248254 (fun fldtype ->
249- if offset = 0
255+ if offset = 0 && is_void_tgtbtype then
256+ Ok (Some (FieldOffset
257+ ((finfo.bfname, finfo.bfckey), NoOffset )))
258+ else if offset = 0
250259 && (is_scalar fldtype)
251260 && (check_tgttype_compliance fldtype sz) then
252261 Ok (Some (FieldOffset
@@ -305,6 +314,47 @@ object (self)
305314 Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " :"
306315 ^ " xoffset: " ^ (x2s xoffset)
307316 ^ " ; btype: " ^ (btype_to_string btype)]
317+ | XOp (XPlus , [XOp (XMult , [XConst (IntConst n); XVar v]);
318+ XConst (IntConst m)]) when is_struct_type btype ->
319+ let compinfo = get_struct_type_compinfo btype in
320+ let fldoffset = XConst (IntConst m) in
321+ let memoffset_r =
322+ self#get_field_memory_offset_at
323+ ~tgtsize: None ~tgtbtype: None compinfo fldoffset in
324+ TR. tbind
325+ (fun memoffset ->
326+ match memoffset with
327+ | FieldOffset ((fname , fckey ), NoOffset) ->
328+ let fcinfo = get_compinfo_by_key fckey in
329+ let field = get_compinfo_field fcinfo fname in
330+ let fieldtype = field.bftype in
331+ if is_array_type fieldtype then
332+ let eltype = get_element_type fieldtype in
333+ let elsize_r = size_of_btype eltype in
334+ TR. tbind
335+ (fun elsize ->
336+ if elsize = n#toInt then
337+ let aoffset = ArrayIndexOffset (XVar v, NoOffset ) in
338+ let moffset =
339+ BCHMemoryReference. add_offset memoffset aoffset in
340+ Ok moffset
341+ else
342+ Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " :"
343+ ^ " field: " ^ fname
344+ ^ " ; fieldtype: " ^ (btype_to_string fieldtype)
345+ ^ " ; elementsize: " ^ (string_of_int elsize)
346+ ^ " ; expected: " ^ n#toString])
347+ elsize_r
348+ else
349+ Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " : "
350+ ^ " not an array type" ]
351+ | _ ->
352+ Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " :"
353+ ^ " fldoffset: " ^ (x2s fldoffset)
354+ ^ " ; memoffset: "
355+ ^ (BCHMemoryReference. memory_offset_to_string memoffset)])
356+ memoffset_r
357+
308358 | _ ->
309359 Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " :"
310360 ^ " xoffset: " ^ (x2s xoffset)
0 commit comments