Skip to content

Commit 13340ed

Browse files
authored
Fix isFinalSigma related non-portable type conversions (#1173)
1 parent 7353942 commit 13340ed

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

std/assembly/util/string.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ export function isCaseIgnorable(c: u32): bool {
551551

552552
// @ts-ignore: decorator
553553
@inline
554-
export function isFinalSigma(buffer: usize, index: i32, len: i32): bool {
554+
export function isFinalSigma(buffer: usize, index: isize, len: isize): bool {
555555
const lookaheadLimit = 30; // max lookahead limit
556556
var found = false;
557557
var pos = index;
@@ -565,34 +565,34 @@ export function isFinalSigma(buffer: usize, index: i32, len: i32): bool {
565565
return false;
566566
}
567567
}
568-
pos -= i32(c >= 0x10000) + 1;
568+
pos -= isize(c >= 0x10000) + 1;
569569
}
570570
if (!found) return false;
571571
pos = index + 1;
572572
var maxPos = min(pos + lookaheadLimit, len);
573573
while (pos < maxPos) {
574-
let c = <u32>load<u16>(buffer + (<usize>pos << 1));
574+
let c = <u32>load<u16>(buffer + (pos << 1));
575575
if (u32((c & 0xFC00) == 0xD800) & u32(pos + 1 != len)) {
576-
let c1 = <u32>load<u16>(buffer + (<usize>pos << 1), 2);
576+
let c1 = <u32>load<u16>(buffer + (pos << 1), 2);
577577
if ((c1 & 0xFC00) == 0xDC00) {
578578
c = (c - 0xD800 << 10) + (c1 - 0xDC00) + 0x10000;
579579
}
580580
}
581581
if (!isCaseIgnorable(c)) {
582582
return !isCased(c);
583583
}
584-
pos += i32(c >= 0x10000) + 1;
584+
pos += isize(c >= 0x10000) + 1;
585585
}
586586
return true;
587587
}
588588

589589
// @ts-ignore: decorator
590590
@inline
591-
function codePointBefore(buffer: usize, index: i32): i32 {
591+
function codePointBefore(buffer: usize, index: isize): i32 {
592592
if (index <= 0) return -1;
593-
var c = <u32>load<u16>(buffer + (<usize>index - 1 << 1));
593+
var c = <u32>load<u16>(buffer + (index - 1 << 1));
594594
if (u32((c & 0xFC00) == 0xDC00) & u32(index - 2 >= 0)) {
595-
let c1 = <u32>load<u16>(buffer + (<usize>index - 2 << 1));
595+
let c1 = <u32>load<u16>(buffer + (index - 2 << 1));
596596
if ((c1 & 0xFC00) == 0xD800) {
597597
return ((c1 & 0x3FF) << 10) + (c & 0x3FF) + 0x10000;
598598
}

0 commit comments

Comments
 (0)