porffor 0.61.11 → 0.61.13
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/compiler/builtins/string.ts +103 -13
- package/compiler/builtins_precompiled.js +347 -347
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
|
@@ -1602,16 +1602,22 @@ memory.copy 0 0`;
|
|
|
1602
1602
|
|
|
1603
1603
|
|
|
1604
1604
|
export const __String_prototype_split = (_this: string, separator: any, limit: any) => {
|
|
1605
|
-
const out: any[] = Porffor.malloc()
|
|
1605
|
+
const out: any[] = Porffor.malloc();
|
|
1606
|
+
let outLen: i32 = 0;
|
|
1606
1607
|
|
|
1607
|
-
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined)
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1608
|
+
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined) {
|
|
1609
|
+
limit = Number.MAX_SAFE_INTEGER;
|
|
1610
|
+
} else {
|
|
1611
|
+
limit = ecma262.ToIntegerOrInfinity(limit);
|
|
1612
|
+
if (limit < 0) limit = Number.MAX_SAFE_INTEGER;
|
|
1612
1613
|
}
|
|
1613
1614
|
|
|
1614
1615
|
if (Porffor.wasm`local.get ${separator+1}` == Porffor.TYPES.undefined) {
|
|
1616
|
+
if (limit == 0) {
|
|
1617
|
+
out.length = 0;
|
|
1618
|
+
return out;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1615
1621
|
out.length = 1;
|
|
1616
1622
|
// out[0] = _this; (but in wasm as it is a f64 array and we are in i32 space)
|
|
1617
1623
|
Porffor.wasm`
|
|
@@ -1626,7 +1632,46 @@ i32.store8 0 12`;
|
|
|
1626
1632
|
return out;
|
|
1627
1633
|
}
|
|
1628
1634
|
|
|
1635
|
+
if (Porffor.wasm`local.get ${separator+1}` == Porffor.TYPES.regexp) {
|
|
1636
|
+
if (limit == 0) {
|
|
1637
|
+
out.length = 0;
|
|
1638
|
+
return out;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
let lastIndex: number = 0;
|
|
1642
|
+
let lastWasEmptyMatch: boolean = false;
|
|
1643
|
+
const thisLen: number = _this.length;
|
|
1644
|
+
while (lastIndex < thisLen && outLen < limit) {
|
|
1645
|
+
const match: string[] = separator.exec(__String_prototype_substring(_this, lastIndex, thisLen));
|
|
1646
|
+
if (match == 0) break;
|
|
1647
|
+
|
|
1648
|
+
const matchIndex: number = lastIndex + match.index;
|
|
1649
|
+
const matchLen: number = __Array_prototype_at(match, 0).length;
|
|
1650
|
+
if (matchLen == 0 && matchIndex == lastIndex) {
|
|
1651
|
+
outLen = Porffor.array.fastPush(out, __String_prototype_substring(_this, lastIndex, lastIndex + 1));
|
|
1652
|
+
lastIndex++;
|
|
1653
|
+
lastWasEmptyMatch = true;
|
|
1654
|
+
continue;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
outLen = Porffor.array.fastPush(out, __String_prototype_substring(_this, lastIndex, matchIndex));
|
|
1658
|
+
lastIndex = matchIndex + matchLen;
|
|
1659
|
+
lastWasEmptyMatch = false;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
if (outLen < limit && (lastIndex < thisLen || !lastWasEmptyMatch)) {
|
|
1663
|
+
outLen = Porffor.array.fastPush(out, __String_prototype_substring(_this, lastIndex, thisLen));
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
out.length = outLen;
|
|
1667
|
+
return out;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1629
1670
|
separator = ecma262.ToString(separator);
|
|
1671
|
+
if (limit == 0) {
|
|
1672
|
+
out.length = 0;
|
|
1673
|
+
return out;
|
|
1674
|
+
}
|
|
1630
1675
|
|
|
1631
1676
|
let tmp: string = Porffor.malloc(), tmpLen: i32 = 0;
|
|
1632
1677
|
const thisLen: i32 = _this.length * 2, sepLen: i32 = separator.length;
|
|
@@ -1772,16 +1817,22 @@ i32.store8 0 12`;
|
|
|
1772
1817
|
};
|
|
1773
1818
|
|
|
1774
1819
|
export const __ByteString_prototype_split = (_this: bytestring, separator: any, limit: any) => {
|
|
1775
|
-
const out: any[] = Porffor.malloc()
|
|
1820
|
+
const out: any[] = Porffor.malloc();
|
|
1821
|
+
let outLen: i32 = 0;
|
|
1776
1822
|
|
|
1777
|
-
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined)
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1823
|
+
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined) {
|
|
1824
|
+
limit = Number.MAX_SAFE_INTEGER;
|
|
1825
|
+
} else {
|
|
1826
|
+
limit = ecma262.ToIntegerOrInfinity(limit);
|
|
1827
|
+
if (limit < 0) limit = Number.MAX_SAFE_INTEGER;
|
|
1782
1828
|
}
|
|
1783
1829
|
|
|
1784
1830
|
if (Porffor.wasm`local.get ${separator+1}` == Porffor.TYPES.undefined) {
|
|
1831
|
+
if (limit == 0) {
|
|
1832
|
+
out.length = 0;
|
|
1833
|
+
return out;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1785
1836
|
out.length = 1;
|
|
1786
1837
|
// out[0] = _this; (but in wasm as it is a f64 array and we are in i32 space)
|
|
1787
1838
|
Porffor.wasm`
|
|
@@ -1796,7 +1847,46 @@ i32.store8 0 12`;
|
|
|
1796
1847
|
return out;
|
|
1797
1848
|
}
|
|
1798
1849
|
|
|
1850
|
+
if (Porffor.wasm`local.get ${separator+1}` == Porffor.TYPES.regexp) {
|
|
1851
|
+
if (limit == 0) {
|
|
1852
|
+
out.length = 0;
|
|
1853
|
+
return out;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
let lastIndex: number = 0;
|
|
1857
|
+
let lastWasEmptyMatch: boolean = false;
|
|
1858
|
+
const thisLen: number = _this.length;
|
|
1859
|
+
while (lastIndex < thisLen && outLen < limit) {
|
|
1860
|
+
const match: bytestring[] = separator.exec(__ByteString_prototype_substring(_this, lastIndex, thisLen));
|
|
1861
|
+
if (match == 0) break;
|
|
1862
|
+
|
|
1863
|
+
const matchIndex: number = lastIndex + match.index;
|
|
1864
|
+
const matchLen: number = __Array_prototype_at(match, 0).length;
|
|
1865
|
+
if (matchLen == 0 && matchIndex == lastIndex) {
|
|
1866
|
+
outLen = Porffor.array.fastPush(out, __ByteString_prototype_substring(_this, lastIndex, lastIndex + 1));
|
|
1867
|
+
lastIndex++;
|
|
1868
|
+
lastWasEmptyMatch = true;
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
outLen = Porffor.array.fastPush(out, __ByteString_prototype_substring(_this, lastIndex, matchIndex));
|
|
1873
|
+
lastIndex = matchIndex + matchLen;
|
|
1874
|
+
lastWasEmptyMatch = false;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
if (outLen < limit && (lastIndex < thisLen || !lastWasEmptyMatch)) {
|
|
1878
|
+
outLen = Porffor.array.fastPush(out, __ByteString_prototype_substring(_this, lastIndex, thisLen));
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
out.length = outLen;
|
|
1882
|
+
return out;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1799
1885
|
separator = ecma262.ToString(separator);
|
|
1886
|
+
if (limit == 0) {
|
|
1887
|
+
out.length = 0;
|
|
1888
|
+
return out;
|
|
1889
|
+
}
|
|
1800
1890
|
|
|
1801
1891
|
let tmp: bytestring = Porffor.malloc(), tmpLen: i32 = 0;
|
|
1802
1892
|
const thisLen: i32 = _this.length, sepLen: i32 = separator.length;
|
|
@@ -2085,4 +2175,4 @@ export const __String_prototype_valueOf = (_this: string) => {
|
|
|
2085
2175
|
export const __ByteString_prototype_valueOf = (_this: bytestring) => {
|
|
2086
2176
|
// 1. Return ? ThisStringValue(this value).
|
|
2087
2177
|
return _this;
|
|
2088
|
-
};
|
|
2178
|
+
};
|