porffor 0.60.15 → 0.60.16

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.
@@ -347,7 +347,7 @@ export const __ecma262_WeekDayName = (tv: number): bytestring => {
347
347
  const lut: bytestring = 'SunMonTueWedThuFriSat';
348
348
  const weekday: number = __ecma262_WeekDay(tv);
349
349
 
350
- let out: bytestring = Porffor.allocateBytes(7);
350
+ let out: bytestring = Porffor.allocateBytes(8);
351
351
  out.length = 3;
352
352
 
353
353
  let outPtr: number = Porffor.wasm`local.get ${out}`;
@@ -365,7 +365,7 @@ export const __ecma262_MonthName = (tv: number): bytestring => {
365
365
  const lut: bytestring = 'JanFebMarAprMayJunJulAugSepOctNovDec';
366
366
  const month: number = __ecma262_MonthFromTime(tv);
367
367
 
368
- let out: bytestring = Porffor.allocateBytes(7);
368
+ let out: bytestring = Porffor.allocateBytes(8);
369
369
  out.length = 3;
370
370
 
371
371
  let outPtr: number = Porffor.wasm`local.get ${out}`;
@@ -1472,7 +1472,7 @@ export const __Porffor_bytestring_appendPadNum = (str: bytestring, num: number,
1472
1472
  export const __ecma262_ToUTCDTSF = (t: number): bytestring => {
1473
1473
  const year: number = __ecma262_YearFromTime(t);
1474
1474
 
1475
- let out: bytestring = Porffor.allocateBytes(32);
1475
+ let out: bytestring = Porffor.allocateBytes(64);
1476
1476
  if (Porffor.fastOr(year < 0, year >= 10000)) {
1477
1477
  // extended year format
1478
1478
  // sign
@@ -1565,7 +1565,7 @@ export const __ecma262_TimeString = (tv: number): bytestring => {
1565
1565
  const second: number = __ecma262_SecFromTime(tv);
1566
1566
 
1567
1567
  // 4. Return the string-concatenation of hour, ":", minute, ":", second, the code unit 0x0020 (SPACE), and "GMT".
1568
- let out: bytestring = Porffor.allocateBytes(16);
1568
+ let out: bytestring = Porffor.allocateBytes(64);
1569
1569
  __Porffor_bytestring_appendPadNum(out, hour, 2);
1570
1570
  __Porffor_bytestring_appendChar(out, 58); // ':'
1571
1571
 
@@ -1601,7 +1601,7 @@ export const __ecma262_DateString = (tv: number): bytestring => {
1601
1601
  // 5. If yv is +0𝔽 or yv > +0𝔽, let yearSign be the empty String; otherwise, let yearSign be "-".
1602
1602
  // 6. Let paddedYear be ToZeroPaddedDecimalString(abs(ℝ(yv)), 4).
1603
1603
  // 7. Return the string-concatenation of weekday, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), yearSign, and paddedYear.
1604
- let out: bytestring = Porffor.allocateBytes(20);
1604
+ let out: bytestring = Porffor.allocateBytes(64);
1605
1605
 
1606
1606
  // weekday
1607
1607
  __Porffor_bytestring_appendStr(out, weekday);
@@ -1638,7 +1638,7 @@ export const __ecma262_ToDateString = (tv: number) => {
1638
1638
  const t: number = __ecma262_LocalTime(tv);
1639
1639
 
1640
1640
  // 3. Return the string-concatenation of DateString(t), the code unit 0x0020 (SPACE), TimeString(t), and TimeZoneString(tv).
1641
- const out: bytestring = Porffor.allocateBytes(44);
1641
+ const out: bytestring = Porffor.allocateBytes(64);
1642
1642
  __Porffor_bytestring_appendStr(out, __ecma262_DateString(t));
1643
1643
  __Porffor_bytestring_appendChar(out, 32);
1644
1644
 
@@ -1675,7 +1675,7 @@ export const __Date_prototype_toTimeString = (_this: any) => {
1675
1675
  const t: number = __ecma262_LocalTime(tv);
1676
1676
 
1677
1677
  // 6. Return the string-concatenation of TimeString(t) and TimeZoneString(tv).
1678
- const out: bytestring = Porffor.allocateBytes(27);
1678
+ const out: bytestring = Porffor.allocateBytes(64);
1679
1679
  __Porffor_bytestring_appendStr(out, __ecma262_TimeString(t));
1680
1680
  __Porffor_bytestring_appendStr(out, __ecma262_TimeZoneString(tv));
1681
1681
  return out;
@@ -1728,7 +1728,7 @@ export const __Date_prototype_toUTCString = (_this: any) => {
1728
1728
  // 11. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE),
1729
1729
  // day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE),
1730
1730
  // yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).
1731
- const out: bytestring = Porffor.allocateBytes(34);
1731
+ const out: bytestring = Porffor.allocateBytes(64);
1732
1732
 
1733
1733
  // weekday
1734
1734
  __Porffor_bytestring_appendStr(out, weekday);
@@ -1781,7 +1781,7 @@ export const __Date_prototype_valueOf = (_this: any) => {
1781
1781
 
1782
1782
  // 21.4.2.1 Date (...values)
1783
1783
  // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date
1784
- export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown, v4: unknown, v5: unknown, v6: unknown): bytestring|Date {
1784
+ export const Date = function (...values: any[]): bytestring|Date {
1785
1785
  // 1. If NewTarget is undefined, then
1786
1786
  if (!new.target) {
1787
1787
  // a. Let now be the time value (UTC) identifying the current time.
@@ -1789,18 +1789,8 @@ export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown
1789
1789
  return __ecma262_ToDateString(__Date_now());
1790
1790
  }
1791
1791
 
1792
- // todo: passing undefined to params should not act like no arg was passed
1793
-
1794
1792
  // 2. Let numberOfArgs be the number of elements in values.
1795
- // sorry.
1796
- const numberOfArgs: i32 =
1797
- (Porffor.type(v0) != Porffor.TYPES.undefined) +
1798
- (Porffor.type(v1) != Porffor.TYPES.undefined) +
1799
- (Porffor.type(v2) != Porffor.TYPES.undefined) +
1800
- (Porffor.type(v3) != Porffor.TYPES.undefined) +
1801
- (Porffor.type(v4) != Porffor.TYPES.undefined) +
1802
- (Porffor.type(v5) != Porffor.TYPES.undefined) +
1803
- (Porffor.type(v6) != Porffor.TYPES.undefined);
1793
+ const numberOfArgs: i32 = values.length;
1804
1794
 
1805
1795
  let dv: number = 0;
1806
1796
 
@@ -1809,19 +1799,20 @@ export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown
1809
1799
  // a. Let dv be the time value (UTC) identifying the current time.
1810
1800
  dv = __Date_now();
1811
1801
  } else if (numberOfArgs == 1) {
1812
- // 4. Else if numberOfArgs = 1, the n
1802
+ // 4. Else if numberOfArgs = 1, then
1813
1803
  // a. Let value be values[0].
1814
- const value: any = v0;
1804
+ const value: any = values[0];
1815
1805
  let tv: number = 0;
1816
1806
 
1817
1807
  // b. If value is an Object and value has a [[DateValue]] internal slot, then
1818
- if (Porffor.type(v0) == Porffor.TYPES.date) {
1808
+ if (Porffor.type(value) == Porffor.TYPES.date) {
1819
1809
  // i. Let tv be value.[[DateValue]].
1820
1810
  tv = __Porffor_date_read(value);
1821
1811
  } else {
1822
1812
  // c. Else,
1813
+ // i. Let v be ? ToPrimitive(value).
1823
1814
  // ii. If v is a String, then
1824
- if ((Porffor.type(v0) | 0b10000000) == Porffor.TYPES.bytestring) {
1815
+ if ((Porffor.type(value) | 0b10000000) == Porffor.TYPES.bytestring) {
1825
1816
  // 1. Assert: The next step never returns an abrupt completion because v is a String.
1826
1817
 
1827
1818
  // 2. Let tv be the result of parsing v as a date, in exactly the same manner as for the parse method (21.4.3.2).
@@ -1840,30 +1831,30 @@ export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown
1840
1831
  // a. Assert: numberOfArgs ≥ 2.
1841
1832
 
1842
1833
  // b. Let y be ? ToNumber(values[0]).
1843
- const y: number = ecma262.ToNumber(v0);
1834
+ const y: number = ecma262.ToNumber(values[0]);
1844
1835
 
1845
1836
  // c. Let m be ? ToNumber(values[1]).
1846
- const m: number = ecma262.ToNumber(v1);
1837
+ const m: number = ecma262.ToNumber(values[1]);
1847
1838
 
1848
1839
  // d. If numberOfArgs > 2, let dt be ? ToNumber(values[2]); else let dt be 1𝔽.
1849
1840
  let dt: number = 1;
1850
- if (numberOfArgs > 2) dt = ecma262.ToNumber(v2);
1841
+ if (numberOfArgs > 2) dt = ecma262.ToNumber(values[2]);
1851
1842
 
1852
1843
  // e. If numberOfArgs > 3, let h be ? ToNumber(values[3]); else let h be +0𝔽.
1853
1844
  let h: number = 0;
1854
- if (numberOfArgs > 3) h = ecma262.ToNumber(v3);
1845
+ if (numberOfArgs > 3) h = ecma262.ToNumber(values[3]);
1855
1846
 
1856
1847
  // f. If numberOfArgs > 4, let min be ? ToNumber(values[4]); else let min be +0𝔽.
1857
1848
  let min: number = 0;
1858
- if (numberOfArgs > 4) min = ecma262.ToNumber(v4);
1849
+ if (numberOfArgs > 4) min = ecma262.ToNumber(values[4]);
1859
1850
 
1860
1851
  // g. If numberOfArgs > 5, let s be ? ToNumber(values[5]); else let s be +0𝔽.
1861
1852
  let s: number = 0;
1862
- if (numberOfArgs > 5) s = ecma262.ToNumber(v5);
1853
+ if (numberOfArgs > 5) s = ecma262.ToNumber(values[5]);
1863
1854
 
1864
1855
  // h. If numberOfArgs > 6, let milli be ? ToNumber(values[6]); else let milli be +0𝔽.
1865
1856
  let milli: number = 0;
1866
- if (numberOfArgs > 6) milli = ecma262.ToNumber(v6);
1857
+ if (numberOfArgs > 6) milli = ecma262.ToNumber(values[6]);
1867
1858
 
1868
1859
  // i. Let yr be MakeFullYear(y).
1869
1860
  const yr: number = __ecma262_MakeFullYear(y);