library colibrilib.safe_bits — module Exportmodule Export274use int.Int275use colibrilib.zarith.Zbit276use BitsSpec277use SafeBits278use colibrilib.spec.Value279
Total versions: they raise TooBig exactly when the size condition of the version with a precondition is false
Valid (35ms) (colibri2)let shift_right (off a:int) : int284ensures { value_is (Zbit.asr a off) result }285raises { TooBig -> not (shift_ok off a) }286= if shift_ok off a then SafeBits.shift_right off a else raise TooBig287Valid (40ms) (colibri2)288let extract (off len a:int) : int289ensures { value_is (BitsSpec.extract off len a) result }290raises { TooBig -> not (extract_ok off len a) }291= if extract_ok off len a then SafeBits.extract off len a else raise TooBig292Valid (30ms) (colibri2)293let signed_extract (off len a:int) : int294ensures { value_is (BitsSpec.signed_extract off len a) result }295raises { TooBig -> not (signed_extract_ok off len) }296= if signed_extract_ok off len then SafeBits.signed_extract off len a else raise TooBig297Valid (32ms) (colibri2)298let update (off len src dst:int) : int299ensures { value_is (BitsSpec.update off len src dst) result }300raises { TooBig -> not (update_ok off len) }301= if update_ok off len then SafeBits.update off len src dst else raise TooBig302end303