@@ -329,17 +329,19 @@ end
329
329
is_field_maybe_undef (t:: Const , i) = ! isdefined (t. val, i)
330
330
331
331
function n_initialized (pstruct:: PartialStruct )
332
- i = findfirst (pstruct. undef)
332
+ pstruct_undef = _getundef (pstruct)
333
+ i = findfirst (pstruct_undef)
333
334
nmin = datatype_min_ninitialized (pstruct. typ)
334
- i === nothing && return max (length (pstruct . undef ), nmin)
335
+ i === nothing && return max (length (pstruct_undef ), nmin)
335
336
n = i:: Int - 1
336
337
@assert n ≥ nmin
337
338
n
338
339
end
339
340
340
341
function is_field_maybe_undef (pstruct:: PartialStruct , fi)
341
342
fi ≥ 1 || return true
342
- fi ≤ length (pstruct. undef) && return pstruct. undef[fi]
343
+ pstruct_undef = _getundef (pstruct)
344
+ fi ≤ length (pstruct_undef) && return pstruct_undef[fi]
343
345
fi > datatype_min_ninitialized (pstruct. typ)
344
346
end
345
347
@@ -350,8 +352,9 @@ function partialstruct_getfield(pstruct::PartialStruct, fi::Integer)
350
352
end
351
353
352
354
function refines_definedness_information (pstruct:: PartialStruct )
353
- nflds = length (pstruct. undef)
354
- something (findfirst (pstruct. undef), nflds + 1 ) - 1 > datatype_min_ninitialized (pstruct. typ)
355
+ pstruct_undef = _getundef (pstruct)
356
+ nflds = length (pstruct_undef)
357
+ something (findfirst (pstruct_undef), nflds + 1 ) - 1 > datatype_min_ninitialized (pstruct. typ)
355
358
end
356
359
357
360
function define_field (pstruct:: PartialStruct , fi:: Int )
@@ -362,19 +365,20 @@ function define_field(pstruct::PartialStruct, fi::Int)
362
365
363
366
new = expand_partialstruct (pstruct, fi)
364
367
if new === nothing
365
- new = PartialStruct (fallback_lattice, pstruct. typ, copy (pstruct. undef ), copy (pstruct. fields))
368
+ new = PartialStruct (fallback_lattice, pstruct. typ, copy (_getundef ( pstruct) ), copy (pstruct. fields))
366
369
end
367
- new. undef [fi] = false
370
+ _getundef ( new) [fi] = false
368
371
return new
369
372
end
370
373
371
374
function expand_partialstruct (pstruct:: PartialStruct , until:: Int )
372
- n = length (pstruct. undef)
375
+ pstruct_undef = _getundef (pstruct)
376
+ n = length (pstruct_undef)
373
377
until ≤ n && return nothing
374
378
375
379
undef = partialstruct_init_undef (pstruct. typ, until; all_defined = false )
376
380
for i in 1 : n
377
- undef[i] &= pstruct . undef [i]
381
+ undef[i] &= pstruct_undef [i]
378
382
end
379
383
nf = length (pstruct. fields)
380
384
typ = pstruct. typ
393
397
@assert n_initialized (typea) ≤ n_initialized (typeb) " typeb ⊑ typea is assumed"
394
398
elseif typeb isa PartialStruct
395
399
@assert n_initialized (typea) ≤ n_initialized (typeb) &&
396
- all (b < a for (a, b) in zip (typea. undef, typeb. undef )) " typeb ⊑ typea is assumed"
400
+ all (b < a for (a, b) in zip (_getundef ( typea), _getundef ( typeb) )) " typeb ⊑ typea is assumed"
397
401
else
398
402
return false
399
403
end
0 commit comments