github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library@v0.2.0/UTF8/UTF8.go (about) 1 // Package UTF8 2 // Dafny module UTF8 compiled into Go 3 4 package UTF8 5 6 import ( 7 os "os" 8 9 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 10 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 11 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 12 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 13 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 14 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 15 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 16 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 17 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 18 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 19 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 20 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 21 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 22 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 23 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 24 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 25 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 26 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 27 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 28 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 29 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 30 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 31 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 32 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 33 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 34 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 35 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 36 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 37 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 38 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 39 ) 40 41 var _ = os.Args 42 var _ _dafny.Dummy__ 43 var _ m__System.Dummy__ 44 var _ m_Wrappers.Dummy__ 45 var _ m_Relations.Dummy__ 46 var _ m_Seq_MergeSort.Dummy__ 47 var _ m__Math.Dummy__ 48 var _ m_Seq.Dummy__ 49 var _ m_BoundedInts.Dummy__ 50 var _ m__Unicode.Dummy__ 51 var _ m_Functions.Dummy__ 52 var _ m_Utf8EncodingForm.Dummy__ 53 var _ m_Utf16EncodingForm.Dummy__ 54 var _ m_UnicodeStrings.Dummy__ 55 var _ m_FileIO.Dummy__ 56 var _ m_GeneralInternals.Dummy__ 57 var _ m_MulInternalsNonlinear.Dummy__ 58 var _ m_MulInternals.Dummy__ 59 var _ m_Mul.Dummy__ 60 var _ m_ModInternalsNonlinear.Dummy__ 61 var _ m_DivInternalsNonlinear.Dummy__ 62 var _ m_ModInternals.Dummy__ 63 var _ m_DivInternals.Dummy__ 64 var _ m_DivMod.Dummy__ 65 var _ m_Power.Dummy__ 66 var _ m_Logarithm.Dummy__ 67 var _ m_StandardLibraryInterop.Dummy__ 68 var _ m_StandardLibrary_UInt.Dummy__ 69 var _ m_StandardLibrary_Sequence.Dummy__ 70 var _ m_StandardLibrary_String.Dummy__ 71 var _ m_StandardLibrary.Dummy__ 72 73 type Dummy__ struct{} 74 75 // Definition of class Default__ 76 type Default__ struct { 77 dummy byte 78 } 79 80 func New_Default___() *Default__ { 81 _this := Default__{} 82 83 return &_this 84 } 85 86 type CompanionStruct_Default___ struct { 87 } 88 89 var Companion_Default___ = CompanionStruct_Default___{} 90 91 func (_this *Default__) Equals(other *Default__) bool { 92 return _this == other 93 } 94 95 func (_this *Default__) EqualsGeneric(x interface{}) bool { 96 other, ok := x.(*Default__) 97 return ok && _this.Equals(other) 98 } 99 100 func (*Default__) String() string { 101 return "UTF8.Default__" 102 } 103 func (_this *Default__) ParentTraits_() []*_dafny.TraitID { 104 return [](*_dafny.TraitID){} 105 } 106 107 var _ _dafny.TraitOffspring = &Default__{} 108 109 func (_static *CompanionStruct_Default___) CreateEncodeSuccess(bytes _dafny.Sequence) m_Wrappers.Result { 110 return m_Wrappers.Companion_Result_.Create_Success_(bytes) 111 } 112 func (_static *CompanionStruct_Default___) CreateEncodeFailure(error_ _dafny.Sequence) m_Wrappers.Result { 113 return m_Wrappers.Companion_Result_.Create_Failure_(error_) 114 } 115 func (_static *CompanionStruct_Default___) CreateDecodeSuccess(s _dafny.Sequence) m_Wrappers.Result { 116 return m_Wrappers.Companion_Result_.Create_Success_(s) 117 } 118 func (_static *CompanionStruct_Default___) CreateDecodeFailure(error_ _dafny.Sequence) m_Wrappers.Result { 119 return m_Wrappers.Companion_Result_.Create_Failure_(error_) 120 } 121 func (_static *CompanionStruct_Default___) IsASCIIString(s _dafny.Sequence) bool { 122 return _dafny.Quantifier(_dafny.IntegerRange(_dafny.Zero, _dafny.IntOfUint32((s).Cardinality())), true, func(_forall_var_0 _dafny.Int) bool { 123 var _0_i _dafny.Int 124 _0_i = interface{}(_forall_var_0).(_dafny.Int) 125 return !(((_0_i).Sign() != -1) && ((_0_i).Cmp(_dafny.IntOfUint32((s).Cardinality())) < 0)) || ((_dafny.IntOfInt32(rune((s).Select((_0_i).Uint32()).(_dafny.Char)))).Cmp(_dafny.IntOfInt64(128)) < 0) 126 }) 127 } 128 func (_static *CompanionStruct_Default___) EncodeAscii(s _dafny.Sequence) _dafny.Sequence { 129 var _0___accumulator _dafny.Sequence = _dafny.SeqOf() 130 _ = _0___accumulator 131 goto TAIL_CALL_START 132 TAIL_CALL_START: 133 if (_dafny.IntOfUint32((s).Cardinality())).Sign() == 0 { 134 return _dafny.Companion_Sequence_.Concatenate(_0___accumulator, _dafny.SeqOf()) 135 } else { 136 var _1_x _dafny.Sequence = _dafny.SeqOf(uint8((s).Select(0).(_dafny.Char))) 137 _ = _1_x 138 _0___accumulator = _dafny.Companion_Sequence_.Concatenate(_0___accumulator, _1_x) 139 var _in0 _dafny.Sequence = (s).Drop(1) 140 _ = _in0 141 s = _in0 142 goto TAIL_CALL_START 143 } 144 } 145 func (_static *CompanionStruct_Default___) Uses1Byte(s _dafny.Sequence) bool { 146 return ((uint8(0)) <= ((s).Select(0).(uint8))) && (((s).Select(0).(uint8)) <= (uint8(127))) 147 } 148 func (_static *CompanionStruct_Default___) Uses2Bytes(s _dafny.Sequence) bool { 149 return (((uint8(194)) <= ((s).Select(0).(uint8))) && (((s).Select(0).(uint8)) <= (uint8(223)))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191)))) 150 } 151 func (_static *CompanionStruct_Default___) Uses3Bytes(s _dafny.Sequence) bool { 152 return (((((((s).Select(0).(uint8)) == (uint8(224))) && (((uint8(160)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191))))) || (((((uint8(225)) <= ((s).Select(0).(uint8))) && (((s).Select(0).(uint8)) <= (uint8(236)))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191)))))) || (((((s).Select(0).(uint8)) == (uint8(237))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(159))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191)))))) || (((((uint8(238)) <= ((s).Select(0).(uint8))) && (((s).Select(0).(uint8)) <= (uint8(239)))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191))))) 153 } 154 func (_static *CompanionStruct_Default___) Uses4Bytes(s _dafny.Sequence) bool { 155 return (((((((s).Select(0).(uint8)) == (uint8(240))) && (((uint8(144)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(3).(uint8))) && (((s).Select(3).(uint8)) <= (uint8(191))))) || ((((((uint8(241)) <= ((s).Select(0).(uint8))) && (((s).Select(0).(uint8)) <= (uint8(243)))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(3).(uint8))) && (((s).Select(3).(uint8)) <= (uint8(191)))))) || ((((((s).Select(0).(uint8)) == (uint8(244))) && (((uint8(128)) <= ((s).Select(1).(uint8))) && (((s).Select(1).(uint8)) <= (uint8(143))))) && (((uint8(128)) <= ((s).Select(2).(uint8))) && (((s).Select(2).(uint8)) <= (uint8(191))))) && (((uint8(128)) <= ((s).Select(3).(uint8))) && (((s).Select(3).(uint8)) <= (uint8(191))))) 156 } 157 func (_static *CompanionStruct_Default___) ValidUTF8Range(a _dafny.Sequence, lo _dafny.Int, hi _dafny.Int) bool { 158 goto TAIL_CALL_START 159 TAIL_CALL_START: 160 if (lo).Cmp(hi) == 0 { 161 return true 162 } else { 163 var _0_r _dafny.Sequence = (a).Subsequence((lo).Uint32(), (hi).Uint32()) 164 _ = _0_r 165 if Companion_Default___.Uses1Byte(_0_r) { 166 var _in0 _dafny.Sequence = a 167 _ = _in0 168 var _in1 _dafny.Int = (lo).Plus(_dafny.One) 169 _ = _in1 170 var _in2 _dafny.Int = hi 171 _ = _in2 172 a = _in0 173 lo = _in1 174 hi = _in2 175 goto TAIL_CALL_START 176 } else if ((_dafny.IntOfInt64(2)).Cmp(_dafny.IntOfUint32((_0_r).Cardinality())) <= 0) && (Companion_Default___.Uses2Bytes(_0_r)) { 177 var _in3 _dafny.Sequence = a 178 _ = _in3 179 var _in4 _dafny.Int = (lo).Plus(_dafny.IntOfInt64(2)) 180 _ = _in4 181 var _in5 _dafny.Int = hi 182 _ = _in5 183 a = _in3 184 lo = _in4 185 hi = _in5 186 goto TAIL_CALL_START 187 } else if ((_dafny.IntOfInt64(3)).Cmp(_dafny.IntOfUint32((_0_r).Cardinality())) <= 0) && (Companion_Default___.Uses3Bytes(_0_r)) { 188 var _in6 _dafny.Sequence = a 189 _ = _in6 190 var _in7 _dafny.Int = (lo).Plus(_dafny.IntOfInt64(3)) 191 _ = _in7 192 var _in8 _dafny.Int = hi 193 _ = _in8 194 a = _in6 195 lo = _in7 196 hi = _in8 197 goto TAIL_CALL_START 198 } else if ((_dafny.IntOfInt64(4)).Cmp(_dafny.IntOfUint32((_0_r).Cardinality())) <= 0) && (Companion_Default___.Uses4Bytes(_0_r)) { 199 var _in9 _dafny.Sequence = a 200 _ = _in9 201 var _in10 _dafny.Int = (lo).Plus(_dafny.IntOfInt64(4)) 202 _ = _in10 203 var _in11 _dafny.Int = hi 204 _ = _in11 205 a = _in9 206 lo = _in10 207 hi = _in11 208 goto TAIL_CALL_START 209 } else { 210 return false 211 } 212 } 213 } 214 func (_static *CompanionStruct_Default___) ValidUTF8Seq(s _dafny.Sequence) bool { 215 return Companion_Default___.ValidUTF8Range(s, _dafny.Zero, _dafny.IntOfUint32((s).Cardinality())) 216 } 217 218 // End of class Default__ 219 220 // Definition of class ValidUTF8Bytes 221 type ValidUTF8Bytes struct { 222 } 223 224 func New_ValidUTF8Bytes_() *ValidUTF8Bytes { 225 _this := ValidUTF8Bytes{} 226 227 return &_this 228 } 229 230 type CompanionStruct_ValidUTF8Bytes_ struct { 231 } 232 233 var Companion_ValidUTF8Bytes_ = CompanionStruct_ValidUTF8Bytes_{} 234 235 func (*ValidUTF8Bytes) String() string { 236 return "UTF8.ValidUTF8Bytes" 237 } 238 func (_this *CompanionStruct_ValidUTF8Bytes_) Witness() _dafny.Sequence { 239 return _dafny.SeqOf() 240 } 241 242 // End of class ValidUTF8Bytes 243 244 func Type_ValidUTF8Bytes_() _dafny.TypeDescriptor { 245 return type_ValidUTF8Bytes_{} 246 } 247 248 type type_ValidUTF8Bytes_ struct { 249 } 250 251 func (_this type_ValidUTF8Bytes_) Default() interface{} { 252 return Companion_ValidUTF8Bytes_.Witness() 253 } 254 255 func (_this type_ValidUTF8Bytes_) String() string { 256 return "UTF8.ValidUTF8Bytes" 257 } 258 func (_this *CompanionStruct_ValidUTF8Bytes_) Is_(__source _dafny.Sequence) bool { 259 var _0_i _dafny.Sequence = (__source) 260 _ = _0_i 261 return Companion_Default___.ValidUTF8Seq(_0_i) 262 }