@@ -499,49 +499,43 @@ let blockwrite_delegate
499499 Open
500500 end
501501 | Some xprxt ->
502+ let xlenterm =
503+ (* If the destination is external, but the length term cannot be
504+ externalized, an external predicate is created with a runtime
505+ value argument for its length. The rationale for still
506+ delegating this proof obligation is that communicating that
507+ this function writes to an external buffer takes priority over
508+ having an incomplete predicate, as the writing affects the
509+ semantics of the caller. *)
510+ match xprxt#xpr_to_bterm BCHBCTypeUtil. t_int bwlen with
511+ | Some bterm -> bterm
512+ | _ -> RunTimeValue in
502513 (match xprxt#xpr_to_bterm ty xpr with
503514 | Some (NumConstant n ) when n#gt CHNumerical. numerical_zero ->
504515 let dw = BCHDoubleword. numerical_mod_to_doubleword n in
505- (match xprxt#xpr_to_bterm BCHBCTypeUtil. t_int bwlen with
506- | Some (NumConstant ns ) ->
507- let xxp = XXBlockWrite (ty, NumConstant n, NumConstant ns) in
508- begin
509- global_system_state#add_precondition dw loc xxp;
510- log_diagnostics_result
511- ~tag: " blockwrite_delegate:delegate_global"
512- ~msg: (p2s loc#toPretty)
513- __FILE__ __LINE__
514- [" dw: " ^ dw#to_hex_string;
515- " xxp: " ^ (p2s (xxpredicate_to_pretty xxp))];
516- DelegatedGlobal (dw, xxp)
517- end
518- | _ ->
519- begin
520- log_diagnostics_result
521- ~tag: " blockwrite_delegate:delegate_global:open"
522- ~msg: (p2s loc#toPretty)
523- __FILE__ __LINE__
524- [" dw: " ^ dw#to_hex_string; " bwlen: " ^ (x2s bwlen)];
525- Open
526- end )
516+ let xxp = XXBlockWrite (ty, NumConstant n, xlenterm) in
517+ begin
518+ global_system_state#add_precondition dw loc xxp;
519+ log_diagnostics_result
520+ ~tag: " blockwrite_delegate:delegate_global"
521+ ~msg: (p2s loc#toPretty)
522+ __FILE__ __LINE__
523+ [" dw: " ^ dw#to_hex_string;
524+ " xxp: " ^ (p2s (xxpredicate_to_pretty xxp))];
525+ DelegatedGlobal (dw, xxp)
526+ end
527527 | Some dst ->
528- (match xprxt#xpr_to_bterm BCHBCTypeUtil. t_int bwlen with
529- | Some lenterm ->
530- let xpred = XXBlockWrite (ty, dst, lenterm) in
531- begin
532- finfo#add_precondition xpred;
533- finfo#add_sideeffect xpred;
534- Delegated xpred
535- end
536- | _ ->
537- begin
538- log_diagnostics_result
539- ~tag: " blockwrite_delegate:dest:open"
540- ~msg: (p2s loc#toPretty)
541- __FILE__ __LINE__
542- [" dst: " ^ (BCHBTerm. bterm_to_string dst); " bwlen: " ^ (x2s bwlen)];
543- Open
544- end )
528+ let xpred = XXBlockWrite (ty, dst, xlenterm) in
529+ begin
530+ finfo#add_precondition xpred;
531+ finfo#add_sideeffect xpred;
532+ log_diagnostics_result
533+ ~tag: " blockwrite_delegate:delegate_api_sideeffect"
534+ ~msg: (p2s loc#toPretty)
535+ __FILE__ __LINE__
536+ [" xpred: " ^ (p2s (xxpredicate_to_pretty xpred))];
537+ Delegated xpred
538+ end
545539 | _ ->
546540 begin
547541 log_diagnostics_result
0 commit comments