@@ -2134,7 +2134,11 @@ and vec_sty (word_bits:Il.bits) : Il.scalar_ty =
2134
2134
let ptr = Il. ScalarTy (Il. AddrTy Il. OpaqueTy ) in
2135
2135
Il. AddrTy (Il. StructTy [| word; word; word; ptr |])
2136
2136
2137
- and referent_type (cx :ctxt ) (t :Ast.ty ) : Il.referent_ty =
2137
+ and referent_type
2138
+ ?parent_tag :parent_tag
2139
+ (cx :ctxt )
2140
+ (t :Ast.ty )
2141
+ : Il.referent_ty =
2138
2142
let s t = Il. ScalarTy t in
2139
2143
let v b = Il. ValTy b in
2140
2144
let p t = Il. AddrTy t in
@@ -2149,12 +2153,7 @@ and referent_type (cx:ctxt) (t:Ast.ty) : Il.referent_ty =
2149
2153
let tag ttag =
2150
2154
let n = get_n_tag_tups cx ttag in
2151
2155
let union =
2152
- let rty t =
2153
- match t with
2154
- Ast. TY_box (Ast. TY_tag dst_tag ) when is_back_edge ttag dst_tag ->
2155
- sp (Il. StructTy [| word; Il. OpaqueTy |])
2156
- | _ -> referent_type cx t
2157
- in
2156
+ let rty t = referent_type ~parent_tag: ttag cx t in
2158
2157
let tup ttup = Il. StructTy (Array. map rty ttup) in
2159
2158
Array. init n (fun i -> tup (get_nth_tag_tup cx ttag i))
2160
2159
in
@@ -2194,7 +2193,13 @@ and referent_type (cx:ctxt) (t:Ast.ty) : Il.referent_ty =
2194
2193
| Ast. TY_fn _ -> fn_rty cx false
2195
2194
| Ast. TY_obj _ -> obj_rty word_bits
2196
2195
2197
- | Ast. TY_tag ttag -> tag ttag
2196
+ | Ast. TY_tag ttag ->
2197
+ begin
2198
+ match parent_tag with
2199
+ Some parent_tag when is_back_edge ttag parent_tag ->
2200
+ Il. OpaqueTy
2201
+ | _ -> tag ttag
2202
+ end
2198
2203
2199
2204
| Ast. TY_chan _
2200
2205
| Ast. TY_port _
@@ -2205,14 +2210,15 @@ and referent_type (cx:ctxt) (t:Ast.ty) : Il.referent_ty =
2205
2210
| Ast. TY_native _ -> ptr
2206
2211
2207
2212
| Ast. TY_box t ->
2208
- sp (Il. StructTy [| word; referent_type cx t |])
2213
+ sp (Il. StructTy
2214
+ [| word; referent_type ?parent_tag:parent_tag cx t |])
2209
2215
2210
- | Ast. TY_mutable t -> referent_type cx t
2216
+ | Ast. TY_mutable t -> referent_type ?parent_tag:parent_tag cx t
2211
2217
2212
2218
| Ast. TY_param (i , _ ) -> Il. ParamTy i
2213
2219
2214
2220
| Ast. TY_named _ -> bug () " named type in referent_type"
2215
- | Ast. TY_constrained (t , _ ) -> referent_type cx t
2221
+ | Ast. TY_constrained (t , _ ) -> referent_type ?parent_tag:parent_tag cx t
2216
2222
2217
2223
and slot_referent_type (cx :ctxt ) (sl :Ast.slot ) : Il.referent_ty =
2218
2224
let s t = Il. ScalarTy t in
0 commit comments