@grain/stdlib 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/regex.gr CHANGED
@@ -121,10 +121,10 @@ let withConfig = (buf: RegExBuf, config: RegExParserConfig) => {
121
121
 
122
122
  let parseErr = (buf: RegExBuf, msg: String, posShift) => {
123
123
  "Invalid Regular Expression: " ++
124
- msg ++
125
- " (position " ++
126
- toString(unbox(buf.cursor) + posShift) ++
127
- ")"
124
+ msg ++
125
+ " (position " ++
126
+ toString(unbox(buf.cursor) + posShift) ++
127
+ ")"
128
128
  }
129
129
 
130
130
  let next = (buf: RegExBuf) => {
@@ -241,7 +241,8 @@ let rec rangeAdd = (rng: CharRange, v: CharRangeElt) => {
241
241
  _ when rangeContains(rng, v) => rng,
242
242
  _ => rangeUnion(rng, [(v, v)]),
243
243
  }
244
- }, rangeUnion = (rng1, rng2) => {
244
+ },
245
+ rangeUnion = (rng1, rng2) => {
245
246
  match ((rng1, rng2)) {
246
247
  ([], _) => rng2,
247
248
  (_, []) => rng1,
@@ -636,7 +637,8 @@ let rec parseRangeNot = (buf: RegExBuf) => {
636
637
  Ok(_) => parseRange(buf),
637
638
  }
638
639
  }
639
- }, parseRange = (buf: RegExBuf) => {
640
+ },
641
+ parseRange = (buf: RegExBuf) => {
640
642
  if (!more(buf)) {
641
643
  Err(parseErr(buf, "Missing closing `]`", 0))
642
644
  } else {
@@ -659,7 +661,8 @@ let rec parseRangeNot = (buf: RegExBuf) => {
659
661
  Ok(_) => parseRangeRest(buf, [], None, None),
660
662
  }
661
663
  }
662
- }, parseClass = (buf: RegExBuf) => {
664
+ },
665
+ parseClass = (buf: RegExBuf) => {
663
666
  if (!more(buf)) {
664
667
  Err(
665
668
  "no chars"
@@ -694,7 +697,8 @@ let rec parseRangeNot = (buf: RegExBuf) => {
694
697
  Ok(c) => Err("unknown class: " ++ toString(c)),
695
698
  }
696
699
  }
697
- }, parsePosixCharClass = (buf: RegExBuf) => {
700
+ },
701
+ parsePosixCharClass = (buf: RegExBuf) => {
698
702
  if (!more(buf)) {
699
703
  Err(parseErr(buf, "Missing POSIX character class after `[`", 0))
700
704
  } else {
@@ -810,7 +814,8 @@ let rec parseRangeNot = (buf: RegExBuf) => {
810
814
  ),
811
815
  }
812
816
  }
813
- }, parseRangeRest =
817
+ },
818
+ parseRangeRest =
814
819
  (
815
820
  buf: RegExBuf,
816
821
  rng: CharRange,
@@ -962,7 +967,8 @@ let rec parseRangeNot = (buf: RegExBuf) => {
962
967
  },
963
968
  }
964
969
  }
965
- }, parseRangeRestSpan =
970
+ },
971
+ parseRangeRestSpan =
966
972
  (
967
973
  buf: RegExBuf,
968
974
  c,
@@ -1213,7 +1219,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1213
1219
  _ => parseLiteral(buf),
1214
1220
  },
1215
1221
  }
1216
- }, parseLook = (buf: RegExBuf) => {
1222
+ },
1223
+ parseLook = (buf: RegExBuf) => {
1217
1224
  let preNumGroups = unbox(buf.config.groupNumber)
1218
1225
  let spanNumGroups = () => unbox(buf.config.groupNumber) - preNumGroups
1219
1226
  // (isMatch, isAhead)
@@ -1279,7 +1286,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1279
1286
  }
1280
1287
  },
1281
1288
  }
1282
- }, parseTest = (buf: RegExBuf) => {
1289
+ },
1290
+ parseTest = (buf: RegExBuf) => {
1283
1291
  if (!more(buf)) {
1284
1292
  Err(parseErr(buf, "Expected test", 0))
1285
1293
  } else {
@@ -1316,7 +1324,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1316
1324
  ),
1317
1325
  }
1318
1326
  }
1319
- }, parseInteger = (buf: RegExBuf, n) => {
1327
+ },
1328
+ parseInteger = (buf: RegExBuf, n) => {
1320
1329
  if (!more(buf)) {
1321
1330
  Ok(n)
1322
1331
  } else {
@@ -1331,7 +1340,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1331
1340
  Ok(_) => Ok(n),
1332
1341
  }
1333
1342
  }
1334
- }, parseMode = (buf: RegExBuf) => {
1343
+ },
1344
+ parseMode = (buf: RegExBuf) => {
1335
1345
  let processState = ((cs, ml)) => {
1336
1346
  let withCs = match (cs) {
1337
1347
  None => buf.config,
@@ -1390,7 +1400,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1390
1400
  }
1391
1401
  }
1392
1402
  help((None, None))
1393
- }, parseUnicodeCategories = (buf: RegExBuf, pC: String) => {
1403
+ },
1404
+ parseUnicodeCategories = (buf: RegExBuf, pC: String) => {
1394
1405
  if (!more(buf)) {
1395
1406
  Err(parseErr(buf, "Expected unicode category", 0))
1396
1407
  } else {
@@ -1558,7 +1569,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1558
1569
  Ok(_) => Err(parseErr(buf, "Expected `{` after `\\" ++ pC ++ "`", 0)),
1559
1570
  }
1560
1571
  }
1561
- }, parseLiteral = (buf: RegExBuf) => {
1572
+ },
1573
+ parseLiteral = (buf: RegExBuf) => {
1562
1574
  if (!more(buf)) {
1563
1575
  Err(parseErr(buf, "Expected literal", 0))
1564
1576
  } else {
@@ -1592,7 +1604,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1592
1604
  },
1593
1605
  }
1594
1606
  }
1595
- }, parseBackslashLiteral = (buf: RegExBuf) => {
1607
+ },
1608
+ parseBackslashLiteral = (buf: RegExBuf) => {
1596
1609
  if (!more(buf)) {
1597
1610
  // Special case: EOS after backslash matches null
1598
1611
  Err(parseErr(buf, "Expected to find escaped value after backslash", 0))
@@ -1655,7 +1668,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1655
1668
  },
1656
1669
  }
1657
1670
  }
1658
- }, parseNonGreedy = (buf: RegExBuf) => {
1671
+ },
1672
+ parseNonGreedy = (buf: RegExBuf) => {
1659
1673
  let checkNotNested = res => {
1660
1674
  if (!more(buf)) {
1661
1675
  res
@@ -1681,7 +1695,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1681
1695
  Ok(_) => checkNotNested(Ok(false)),
1682
1696
  }
1683
1697
  }
1684
- }, parsePCE = (buf: RegExBuf) => {
1698
+ },
1699
+ parsePCE = (buf: RegExBuf) => {
1685
1700
  match (parseAtom(buf)) {
1686
1701
  Err(e) => Err(e),
1687
1702
  Ok(atom) => {
@@ -1775,7 +1790,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1775
1790
  }
1776
1791
  },
1777
1792
  }
1778
- }, parsePCEs = (buf: RegExBuf, toplevel: Bool) => {
1793
+ },
1794
+ parsePCEs = (buf: RegExBuf, toplevel: Bool) => {
1779
1795
  if (!more(buf)) {
1780
1796
  Ok([])
1781
1797
  } else {
@@ -1801,7 +1817,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1801
1817
  },
1802
1818
  }
1803
1819
  }
1804
- }, parseRegex = (buf: RegExBuf) => {
1820
+ },
1821
+ parseRegex = (buf: RegExBuf) => {
1805
1822
  if (!more(buf)) {
1806
1823
  Ok(REEmpty)
1807
1824
  } else {
@@ -1836,7 +1853,8 @@ let rec parseAtom = (buf: RegExBuf) => {
1836
1853
  },
1837
1854
  }
1838
1855
  }
1839
- }, parseRegexNonEmpty = (buf: RegExBuf) => {
1856
+ },
1857
+ parseRegexNonEmpty = (buf: RegExBuf) => {
1840
1858
  match (parsePCEs(buf, false)) {
1841
1859
  Err(e) => Err(e),
1842
1860
  Ok(pces) => {
@@ -1922,7 +1940,7 @@ let rec isAnchored = (re: ParsedRegularExpression) => {
1922
1940
  REAlts(a, b) => isAnchored(a) && isAnchored(b),
1923
1941
  REConditional(_, rx1, rx2, _, _, _) =>
1924
1942
  isAnchored(rx1) &&
1925
- Option.mapWithDefault(isAnchored, false, rx2),
1943
+ Option.mapWithDefault(isAnchored, false, rx2),
1926
1944
  REGroup(rx, _) => isAnchored(rx),
1927
1945
  RECut(rx, _, _, _) => isAnchored(rx),
1928
1946
  _ => false,
@@ -2305,10 +2323,10 @@ let charMatcher = (toMatch, next_m) =>
2305
2323
  if (
2306
2324
  {
2307
2325
  pos < limit &&
2308
- match (matchBufChar(buf, pos)) {
2309
- Err(_) => false,
2310
- Ok(c) => toMatch == c,
2311
- }
2326
+ match (matchBufChar(buf, pos)) {
2327
+ Err(_) => false,
2328
+ Ok(c) => toMatch == c,
2329
+ }
2312
2330
  }
2313
2331
  ) next_m(buf, pos + 1, start, limit, end, state, stack) else None
2314
2332
  }
@@ -2326,10 +2344,10 @@ let charTailMatcher = toMatch =>
2326
2344
  if (
2327
2345
  {
2328
2346
  pos < limit &&
2329
- match (matchBufChar(buf, pos)) {
2330
- Err(_) => false,
2331
- Ok(c) => toMatch == c,
2332
- }
2347
+ match (matchBufChar(buf, pos)) {
2348
+ Err(_) => false,
2349
+ Ok(c) => toMatch == c,
2350
+ }
2333
2351
  }
2334
2352
  ) Some(pos + 1) else None
2335
2353
  }
@@ -2382,13 +2400,13 @@ let stringMatcher = (toMatch, len, next_m) =>
2382
2400
  if (
2383
2401
  {
2384
2402
  pos + len <= limit &&
2385
- subArraysEqual(
2386
- buf.matchInputExploded,
2387
- pos,
2388
- String.explode(toMatch),
2389
- 0,
2390
- len
2391
- )
2403
+ subArraysEqual(
2404
+ buf.matchInputExploded,
2405
+ pos,
2406
+ String.explode(toMatch),
2407
+ 0,
2408
+ len
2409
+ )
2392
2410
  }
2393
2411
  ) next_m(buf, pos + len, start, limit, end, state, stack) else None
2394
2412
  }
@@ -2406,13 +2424,13 @@ let stringTailMatcher = (toMatch, len) =>
2406
2424
  if (
2407
2425
  {
2408
2426
  pos + len <= limit &&
2409
- subArraysEqual(
2410
- buf.matchInputExploded,
2411
- pos,
2412
- String.explode(toMatch),
2413
- 0,
2414
- len
2415
- )
2427
+ subArraysEqual(
2428
+ buf.matchInputExploded,
2429
+ pos,
2430
+ String.explode(toMatch),
2431
+ 0,
2432
+ len
2433
+ )
2416
2434
  }
2417
2435
  ) Some(pos + len) else None
2418
2436
  }
@@ -2513,10 +2531,10 @@ let rangeMatcher = (rng: CharRange, next_m) =>
2513
2531
  if (
2514
2532
  {
2515
2533
  pos < limit &&
2516
- match (matchBufChar(buf, pos)) {
2517
- Err(_) => false,
2518
- Ok(c) => rangeContains(rng, Char.code(c)),
2519
- }
2534
+ match (matchBufChar(buf, pos)) {
2535
+ Err(_) => false,
2536
+ Ok(c) => rangeContains(rng, Char.code(c)),
2537
+ }
2520
2538
  }
2521
2539
  ) next_m(buf, pos + 1, start, limit, end, state, stack) else None
2522
2540
  }
@@ -2534,10 +2552,10 @@ let rangeTailMatcher = (rng: CharRange) =>
2534
2552
  if (
2535
2553
  {
2536
2554
  pos < limit &&
2537
- match (matchBufChar(buf, pos)) {
2538
- Err(_) => false,
2539
- Ok(c) => rangeContains(rng, Char.code(c)),
2540
- }
2555
+ match (matchBufChar(buf, pos)) {
2556
+ Err(_) => false,
2557
+ Ok(c) => rangeContains(rng, Char.code(c)),
2558
+ }
2541
2559
  }
2542
2560
  ) Some(pos + 1) else None
2543
2561
  }
@@ -2636,7 +2654,7 @@ let isWordChar = c => {
2636
2654
 
2637
2655
  let isWordBoundary = (buf, pos, start, limit, end) => {
2638
2656
  !((pos == start || !isWordChar(matchBufChar(buf, pos - 1))) ==
2639
- (pos == end || !isWordChar(matchBufChar(buf, pos))))
2657
+ (pos == end || !isWordChar(matchBufChar(buf, pos))))
2640
2658
  }
2641
2659
 
2642
2660
  let wordBoundaryMatcher = next_m =>
@@ -3672,10 +3690,12 @@ let makeMatchResult = (origString, start, end, state) => {
3672
3690
  // Helpers for user-facing match functionality
3673
3691
 
3674
3692
  let fastDriveRegexIsMatch = (rx, string, startOffset, endOffset) => {
3675
- let state = if (rx.reReferences) Array.make(rx.reNumGroups, None)
3693
+ let state =
3694
+ if (rx.reReferences) Array.make(rx.reNumGroups, None)
3676
3695
  else Array.make(0, None)
3677
- let toWrap = if (startOffset == 0 && endOffset == String.length(string))
3678
- string else String.slice(startOffset, endOffset, string)
3696
+ let toWrap =
3697
+ if (startOffset == 0 && endOffset == String.length(string)) string
3698
+ else String.slice(startOffset, endOffset, string)
3679
3699
  let buf = makeMatchBuffer(toWrap)
3680
3700
  Option.isSome(
3681
3701
  searchMatch(rx, buf, 0, 0, Array.length(buf.matchInputExploded), state)
@@ -3687,8 +3707,9 @@ let rec fastDriveRegexMatchAll = (rx, string, startOffset, endOffset) => {
3687
3707
  []
3688
3708
  } else {
3689
3709
  let state = Array.make(rx.reNumGroups, None)
3690
- let toWrap = if (startOffset == 0 && endOffset == String.length(string))
3691
- string else String.slice(startOffset, endOffset, string)
3710
+ let toWrap =
3711
+ if (startOffset == 0 && endOffset == String.length(string)) string
3712
+ else String.slice(startOffset, endOffset, string)
3692
3713
  let buf = makeMatchBuffer(toWrap)
3693
3714
  match (searchMatch(
3694
3715
  rx,
@@ -3726,8 +3747,9 @@ let rec fastDriveRegexMatchAll = (rx, string, startOffset, endOffset) => {
3726
3747
 
3727
3748
  let fastDriveRegexMatch = (rx, string, startOffset, endOffset) => {
3728
3749
  let state = Array.make(rx.reNumGroups, None)
3729
- let toWrap = if (startOffset == 0 && endOffset == String.length(string))
3730
- string else String.slice(startOffset, endOffset, string)
3750
+ let toWrap =
3751
+ if (startOffset == 0 && endOffset == String.length(string)) string
3752
+ else String.slice(startOffset, endOffset, string)
3731
3753
  let buf = makeMatchBuffer(toWrap)
3732
3754
  match (searchMatch(
3733
3755
  rx,
@@ -3954,11 +3976,12 @@ let regexReplaceHelp =
3954
3976
  let mut out = []
3955
3977
  let rec loop = searchPos => {
3956
3978
  let state = Array.make(rx.reNumGroups, None)
3979
+ let inStart = max(0, searchPos - rx.reMaxLookbehind)
3957
3980
  let poss = searchMatch(
3958
3981
  rx,
3959
3982
  buf,
3960
3983
  searchPos,
3961
- searchPos,
3984
+ inStart,
3962
3985
  Array.length(buf.matchInputExploded),
3963
3986
  state
3964
3987
  )
package/runtime/bigint.gr CHANGED
@@ -1827,10 +1827,10 @@ let baseCaseDivRem = (a: WasmI32, b: WasmI32, result: WasmI32) => {
1827
1827
  let n = getHalfSize(b)
1828
1828
  let m = getHalfSize(a) - n
1829
1829
  let qsize = (if (WasmI32.eqz(WasmI32.and(m + 1n, 1n))) {
1830
- m + 1n
1831
- } else {
1832
- m + 2n
1833
- }) >>
1830
+ m + 1n
1831
+ } else {
1832
+ m + 2n
1833
+ }) >>
1834
1834
  1n
1835
1835
  let mut q = init(qsize)
1836
1836
  let mut a = 0n
@@ -146,7 +146,8 @@ let rec heapCompareHelp = (heapTag, xptr, yptr) => {
146
146
  tagSimpleNumber(xptr - yptr)
147
147
  },
148
148
  }
149
- }, compareHelp = (x, y) => {
149
+ },
150
+ compareHelp = (x, y) => {
150
151
  let xtag = x & Tags._GRAIN_GENERIC_TAG_MASK
151
152
  let ytag = y & Tags._GRAIN_GENERIC_TAG_MASK
152
153
  if ((xtag & ytag) != Tags._GRAIN_GENERIC_HEAP_TAG_TYPE) {
package/runtime/equal.gr CHANGED
@@ -189,7 +189,8 @@ let rec heapEqualHelp = (heapTag, xptr, yptr) => {
189
189
  xptr == yptr
190
190
  },
191
191
  }
192
- }, equalHelp = (x, y) => {
192
+ },
193
+ equalHelp = (x, y) => {
193
194
  if (
194
195
  (x & Tags._GRAIN_GENERIC_TAG_MASK) != 0n &&
195
196
  (y & Tags._GRAIN_GENERIC_TAG_MASK) != 0n
@@ -9,6 +9,8 @@ import foreign wasm fd_write: (
9
9
  WasmI32,
10
10
  ) -> WasmI32 from "wasi_snapshot_preview1"
11
11
 
12
+ primitive unreachable: () -> a = "@unreachable"
13
+
12
14
  enum Option<a> {
13
15
  Some(a),
14
16
  None,
@@ -79,8 +81,8 @@ let exceptionToString = (e: Exception) => {
79
81
  // the runtime heap, but this is the only module that needs to do it
80
82
  let iov = WasmI32.fromGrain([> 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n])
81
83
 
82
- export let printException = (e: Exception) => {
83
- let ptr = WasmI32.fromGrain(exceptionToString(e))
84
+ export let panic = (msg: String) => {
85
+ let ptr = WasmI32.fromGrain(msg)
84
86
  let written = iov + 32n
85
87
  let lf = iov + 36n
86
88
  WasmI32.store(iov, ptr + 8n, 0n)
@@ -89,7 +91,11 @@ export let printException = (e: Exception) => {
89
91
  WasmI32.store(iov, lf, 8n)
90
92
  WasmI32.store(iov, 1n, 12n)
91
93
  fd_write(2n, iov, 2n, written)
92
- void
94
+ unreachable()
95
+ }
96
+
97
+ export let panicWithException = (e: Exception) => {
98
+ panic(exceptionToString(e))
93
99
  }
94
100
 
95
101
  export exception IndexOutOfBounds
@@ -109,7 +115,6 @@ export exception MatchFailure
109
115
  */
110
116
  export exception AssertionError(String)
111
117
  export exception InvalidArgument(String)
112
- export exception OutOfMemory
113
118
 
114
119
  let runtimeErrorPrinter = e => {
115
120
  match (e) {
@@ -123,7 +128,6 @@ let runtimeErrorPrinter = e => {
123
128
  Some("NumberNotRational: Can't coerce number to rational"),
124
129
  MatchFailure => Some("MatchFailure: No matching pattern"),
125
130
  AssertionError(s) => Some(s),
126
- OutOfMemory => Some("OutOfMemory: Maximum memory size exceeded"),
127
131
  InvalidArgument(msg) => Some(msg),
128
132
  _ => None,
129
133
  }
@@ -22,9 +22,15 @@ dangerouslyRegisterBasePrinter : a -> Void
22
22
  dangerouslyRegisterPrinter : a -> Void
23
23
  ```
24
24
 
25
- ### Exception.**printException**
25
+ ### Exception.**panic**
26
26
 
27
27
  ```grain
28
- printException : Exception -> Void
28
+ panic : String -> a
29
+ ```
30
+
31
+ ### Exception.**panicWithException**
32
+
33
+ ```grain
34
+ panicWithException : Exception -> a
29
35
  ```
30
36
 
package/runtime/gc.gr CHANGED
@@ -213,7 +213,8 @@ let rec decRef = (userPtr: WasmI32, ignoreZeros: Bool) => {
213
213
  } else {
214
214
  userPtr
215
215
  }
216
- }, decRefChildren = (userPtr: WasmI32) => {
216
+ },
217
+ decRefChildren = (userPtr: WasmI32) => {
217
218
  match (WasmI32.load(userPtr, 0n)) {
218
219
  t when t == Tags._GRAIN_BOXED_NUM_HEAP_TAG => {
219
220
  let tag = WasmI32.load(userPtr, 4n)
package/runtime/malloc.gr CHANGED
@@ -28,8 +28,6 @@ primitive (!): Bool -> Bool = "@not"
28
28
  primitive (&&): (Bool, Bool) -> Bool = "@and"
29
29
  primitive (||): (Bool, Bool) -> Bool = "@or"
30
30
 
31
- primitive throw: Exception -> a = "@throw"
32
-
33
31
  primitive heapBase: WasmI32 = "@heap.base"
34
32
 
35
33
  /* UNDERSTANDING THE STRUCTURE OF THE FREE LIST
@@ -221,7 +219,7 @@ let morecore = (nbytes: WasmI32) => {
221
219
 
222
220
  // If there was an error, fail
223
221
  if (cp == -1n) {
224
- throw Exception.OutOfMemory
222
+ Exception.panic("OutOfMemory: Maximum memory size exceeded")
225
223
  } else {
226
224
  // Set the size of the new block to the amount the
227
225
  // heap was grown.
@@ -728,16 +728,16 @@ export let decimalCount32 = value => {
728
728
  1n + (if (WasmI32.geU(value, 10n)) 1n else 0n)
729
729
  } else {
730
730
  3n +
731
- (if (WasmI32.geU(value, 10000n)) 1n else 0n) +
732
- (if (WasmI32.geU(value, 1000n)) 1n else 0n)
731
+ (if (WasmI32.geU(value, 10000n)) 1n else 0n) +
732
+ (if (WasmI32.geU(value, 1000n)) 1n else 0n)
733
733
  }
734
734
  } else {
735
735
  if (WasmI32.ltU(value, 10000000n)) {
736
736
  6n + (if (WasmI32.geU(value, 1000000n)) 1n else 0n)
737
737
  } else {
738
738
  8n +
739
- (if (WasmI32.geU(value, 1000000000n)) 1n else 0n) +
740
- (if (WasmI32.geU(value, 100000000n)) 1n else 0n)
739
+ (if (WasmI32.geU(value, 1000000000n)) 1n else 0n) +
740
+ (if (WasmI32.geU(value, 100000000n)) 1n else 0n)
741
741
  }
742
742
  }
743
743
  }
@@ -749,20 +749,20 @@ let decimalCount64High = value => {
749
749
  if (WasmI64.ltU(value, 1000000000000000N)) {
750
750
  if (WasmI64.ltU(value, 1000000000000N)) {
751
751
  10n +
752
- (if (WasmI64.geU(value, 100000000000N)) 1n else 0n) +
753
- (if (WasmI64.geU(value, 10000000000N)) 1n else 0n)
752
+ (if (WasmI64.geU(value, 100000000000N)) 1n else 0n) +
753
+ (if (WasmI64.geU(value, 10000000000N)) 1n else 0n)
754
754
  } else {
755
755
  13n +
756
- (if (WasmI64.geU(value, 100000000000000N)) 1n else 0n) +
757
- (if (WasmI64.geU(value, 10000000000000N)) 1n else 0n)
756
+ (if (WasmI64.geU(value, 100000000000000N)) 1n else 0n) +
757
+ (if (WasmI64.geU(value, 10000000000000N)) 1n else 0n)
758
758
  }
759
759
  } else {
760
760
  if (WasmI64.ltU(value, 100000000000000000N)) {
761
761
  16n + (if (WasmI64.geU(value, 10000000000000000N)) 1n else 0n)
762
762
  } else {
763
763
  18n +
764
- (if (WasmI64.geU(value, 0x8AC7230489E80000N)) 1n else 0n) +
765
- (if (WasmI64.geU(value, 1000000000000000000N)) 1n else 0n)
764
+ (if (WasmI64.geU(value, 0x8AC7230489E80000N)) 1n else 0n) +
765
+ (if (WasmI64.geU(value, 1000000000000000000N)) 1n else 0n)
766
766
  }
767
767
  }
768
768
  }
@@ -774,7 +774,7 @@ let ulog_base = (num, base) => {
774
774
  63n - WasmI32.wrapI64(WasmI64.clz(num)),
775
775
  31n - WasmI32.clz(base)
776
776
  ) +
777
- 1n
777
+ 1n
778
778
  } else {
779
779
  let b64 = WasmI64.extendI32U(base)
780
780
  let mut b = b64