Common — library colibrilib.safe_bits — module Export
274
module Export
275
use int.Int
276
use colibrilib.zarith.Zbit
277
use BitsSpec
278
use SafeBits
279
use colibrilib.spec.Value

Total versions: they raise TooBig exactly when the size condition of the version with a precondition is false

  Valid (35ms) (colibri2)
284
let
shift_right
(off a:int) : int
285
ensures { value_is (Zbit.asr a off) result }
286
raises { TooBig -> not (shift_ok off a) }
287
= if shift_ok off a then SafeBits.shift_right off a else raise TooBig
288
Valid (40ms) (colibri2)
289
let
extract
(off len a:int) : int
290
ensures { value_is (BitsSpec.extract off len a) result }
291
raises { TooBig -> not (extract_ok off len a) }
292
= if extract_ok off len a then SafeBits.extract off len a else raise TooBig
293
Valid (30ms) (colibri2)
294
let
signed_extract
(off len a:int) : int
295
ensures { value_is (BitsSpec.signed_extract off len a) result }
296
raises { TooBig -> not (signed_extract_ok off len) }
297
= if signed_extract_ok off len then SafeBits.signed_extract off len a else raise TooBig
298
Valid (32ms) (colibri2)
299
let
update
(off len src dst:int) : int
300
ensures { value_is (BitsSpec.update off len src dst) result }
301
raises { TooBig -> not (update_ok off len) }
302
= if update_ok off len then SafeBits.update off len src dst else raise TooBig
303
end