porffor 0.2.0-6352ecf → 0.2.0-664913c

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.
@@ -0,0 +1,248 @@
1
+ # Contributing to Porffor
2
+
3
+ Hello! Thanks for your potential interest in contributing to Porffor :)
4
+
5
+ This document hopes to help you understand Porffor-specific TS, specifically for writing built-ins (inside `compiler/builtins/*.ts` eg `btoa`, `String.prototype.trim`, ...). This guide isn't really meant for modifying the compiler itself yet (eg `compiler/codegen.js`), as built-ins are ~easier to implement and more useful at the moment.
6
+
7
+ I mostly presume decent JS knowledge, with some basic TS too but nothing complicated. Knowing low-level stuff generally (pointers, etc) and/or Wasm (bytecode) is also a plus but hopefully not required.
8
+
9
+ If you have any questions you can ask in [the Porffor Discord](https://discord.gg/6crs9Znx9R), please feel free to ask anything if you get stuck :)
10
+
11
+ Please read this entire document before beginning as there are important things throughout.
12
+
13
+ <br>
14
+
15
+ ## Setup
16
+
17
+ 1. Clone the repo and enter the repo (`git clone https://github.com/CanadaHonk/porffor.git`)
18
+ 2. `npm install`
19
+
20
+ ### Precompile
21
+
22
+ **If you update any file inside `compiler/builtins` you will need to do this for it to update inside Porffor otherwise your changes will have no effect.** Run `node compiler/precompile.js` to precompile. It may error during this, if so, you might have an error in your code or there could be a compiler error with Porffor (feel free to ask for help as soon as you encounter any errors with it).
23
+
24
+ <br>
25
+
26
+ ## Types
27
+
28
+ Porffor has usual JS types (or at least the ones it supports), but also internal types for various reasons.
29
+
30
+ ### ByteString
31
+
32
+ The most important and widely used internal type is ByteString (also called `bytestring` or `_bytestring` in code). Regular strings in Porffor are UTF-16 encoded, so each character uses 2 bytes. ByteStrings are special strings which are used when the characters in a string only use ASCII/LATIN-1 characters, so the lower byte of the UTF-16 characters are unused. Instead of wasting memory with all the unused memory, ByteStrings instead use 1 byte per character. This halves memory usage of such strings and also makes operating on them faster. The downside is that many Porffor built-ins have to be written twice, slightly different, for both `String` and `ByteString` types.
33
+
34
+ ### i32
35
+
36
+ This is complicated internally but essentially, only use it for pointers. (This is not signed or unsigned, instead it is the Wasm valtype `i32` so the signage is ~instruction dependant).
37
+
38
+ <br>
39
+
40
+ ## Pointers
41
+
42
+ Pointers are the main (and most difficult) unique feature you ~need to understand when dealing with objects (arrays, strings, ...).
43
+
44
+ We'll explain things per common usage you will likely need to know:
45
+
46
+ ## Commonly used Wasm code
47
+
48
+ ### Get a pointer
49
+
50
+ ```js
51
+ Porffor.wasm`local.get ${foobar}`
52
+ ```
53
+
54
+ Gets the pointer to the variable `foobar`. You don't really need to worry about how it works in detail, but essentially it gets the pointer as a number (type) instead of as the object it is.
55
+
56
+ ### Store a character in a ByteString
57
+
58
+ ```js
59
+ Porffor.wasm.i32.store8(pointer, characterCode, 0, 4)
60
+ ```
61
+
62
+ Stores the character code `characterCode` at the pointer `pointer` **for a ByteString**.[^1]
63
+
64
+ ### Store a character in a String
65
+
66
+ ```js
67
+ Porffor.wasm.i32.store16(pointer, characterCode, 0, 4)
68
+ ```
69
+
70
+ Stores the character code `characterCode` at the pointer `pointer` **for a String**.[^1]
71
+
72
+ ### Load a character from a ByteString
73
+
74
+ ```js
75
+ Porffor.wasm.i32.load8_u(pointer, 0, 4)
76
+ ```
77
+
78
+ Loads the character code at the pointer `pointer` **for a ByteString**.[^1]
79
+
80
+ ### Load a character from a String
81
+
82
+ ```js
83
+ Porffor.wasm.i32.load16_u(pointer, 0, 4)
84
+ ```
85
+
86
+ Loads the character code at the pointer `pointer` **for a String**.[^1]
87
+
88
+ ### Manually store the length of an object
89
+
90
+ ```js
91
+ Porffor.wasm.i32.store(pointer, length, 0, 0)
92
+ ```
93
+
94
+ Stores the length `length` at pointer `pointer`, setting the length of an object. This is mostly unneeded today as you can just do `obj.length = length`. [^2]
95
+
96
+ <br>
97
+
98
+ ## Example
99
+
100
+ Here is the code for `ByteString.prototype.toUpperCase()`:
101
+
102
+ ```ts
103
+ export const ___bytestring_prototype_toUpperCase = (_this: bytestring) => {
104
+ const len: i32 = _this.length;
105
+
106
+ let out: bytestring = '';
107
+ Porffor.wasm.i32.store(out, len, 0, 0);
108
+
109
+ let i: i32 = Porffor.wasm`local.get ${_this}`,
110
+ j: i32 = Porffor.wasm`local.get ${out}`;
111
+
112
+ const endPtr: i32 = i + len;
113
+ while (i < endPtr) {
114
+ let chr: i32 = Porffor.wasm.i32.load8_u(i++, 0, 4);
115
+
116
+ if (chr >= 97) if (chr <= 122) chr -= 32;
117
+
118
+ Porffor.wasm.i32.store8(j++, chr, 0, 4);
119
+ }
120
+
121
+ return out;
122
+ };
123
+ ```
124
+
125
+ Now let's go through it section by section:
126
+
127
+ ```ts
128
+ export const ___bytestring_prototype_toUpperCase = (_this: bytestring) => {
129
+ ```
130
+
131
+ Here we define a built-in for Porffor. Notably:
132
+ - We do not use `a.b.c`, instead we use `__a_b_c`
133
+ - The ByteString type is actually `_bytestring`, as internal types have an extra `_` at the beginning (this is due to be fixed/simplified soon(tm))
134
+ - We use a `_this` argument, as `this` does not exist in Porffor yet
135
+ - We use an arrow function
136
+
137
+ ---
138
+
139
+ ```ts
140
+ const len: i32 = _this.length;
141
+
142
+ let out: bytestring = '';
143
+ Porffor.wasm.i32.store(out, len, 0, 0);
144
+ ```
145
+
146
+ This sets up the `out` variable we are going to write to for the output of this function. We set the length in advance to be the same as `_this`, as `foo.length == foo.toLowerCase().length`, because we will later be manually writing to it using Wasm intrinsics, which will not update the length themselves.
147
+
148
+ ---
149
+
150
+ ```ts
151
+ let i: i32 = Porffor.wasm`local.get ${_this}`,
152
+ j: i32 = Porffor.wasm`local.get ${out}`;
153
+ ```
154
+
155
+ Get the pointers for `_this` and `out` as `i32`s (~`number`s).
156
+
157
+ ---
158
+
159
+ ```ts
160
+ const endPtr: i32 = i + len;
161
+ while (i < endPtr) {
162
+ ```
163
+
164
+ Set up an end target pointer as the pointer variable for `_this` plus the length of it. Loop below until that pointer reaches the end target, so we iterate through the entire string.
165
+
166
+ ---
167
+
168
+ ```ts
169
+ let chr: i32 = Porffor.wasm.i32.load8_u(i++, 0, 4);
170
+ ```
171
+
172
+ Read the character (code) from the current `_this` pointer variable, and increment it so next iteration it reads the next character, etc.
173
+
174
+ ---
175
+
176
+ ```ts
177
+ if (chr >= 97) if (chr <= 122) chr -= 32;
178
+ ```
179
+
180
+ If the character code is >= 97 (`a`) and <= 122 (`z`), decrease it by 32, making it an upper case character. eg: 97 (`a`) - 32 = 65 (`A`).
181
+
182
+ ---
183
+
184
+ ```ts
185
+ Porffor.wasm.i32.store8(j++, chr, 0, 4);
186
+ ```
187
+
188
+ Store the character code into the `out` pointer variable, and increment it.
189
+
190
+ <br>
191
+
192
+ ## Porffor-specific TS notes
193
+
194
+ - For declaring variables, you must use explicit type annotations currently (eg `let a: number = 1`, not `let a = 1`)
195
+ - You might spot `Porffor.fastOr`/`Porffor.fastAnd`, these are non-short circuiting versions of `||`/`&&`, taking any number of conditions as arguments. You shouldn't don't need to use or worry about these.
196
+ - **There are ~no objects, you cannot use them/literals.**
197
+ - Attempt to avoid string/array-heavy code and use more variables instead if possible, easier on memory and CPU/perf.
198
+
199
+ <br>
200
+
201
+ ## Formatting/linting
202
+
203
+ There is 0 setup for this (right now). You can try looking through the other built-ins files but do not worry about it a lot, I honestly do not mind going through and cleaning up after a PR as long as the code itself is good :^)
204
+
205
+ <br>
206
+
207
+ ## Commit (message) style
208
+
209
+ You should ideally have one commit per notable change (using amend/force push). Commit messages should be like `${file}: ${description}`. Don't be afraid to use long titles if needed, but try and be short if possible. Bonus points for detail in commit description. ~~Gold star for jokes in description too.~~
210
+
211
+ Examples:
212
+ ```
213
+ builtins/date: impl toJSON
214
+ builtins/date: fix ToIntegerOrInfinity returning -0
215
+ codegen: fix inline wasm for unreachable
216
+ builtins/array: wip toReversed
217
+ builtins/tostring_number: impl radix
218
+ ```
219
+
220
+ <br>
221
+
222
+ ## Test262
223
+
224
+ Make sure you have Test262 cloned already **inside of `test262/`** (`git clone https://github.com/tc39/test262.git test262/test262`).
225
+
226
+ Run `node test262` to run all the tests and get an output of total overall test results. The main thing you want to pay attention to is the emoji summary (lol):
227
+ ```
228
+ 🧪 50005 | 🤠 7007 (-89) | ❌ 1914 (-32) | 💀 13904 (-61) | 📝 23477 (-120) | ⏰ 2 | 🏗 2073 (+302) | 💥 1628
229
+ ```
230
+
231
+ To break this down:
232
+ 🧪 total 🤠 pass ❌ fail 💀 runtime error 📝 todo (error) ⏰ timeout 🏗️ wasm compile error 💥 compile error
233
+
234
+ The diff compared to the last commit (with test262 data) is shown in brackets. Basically, you can passes 🤠 up, and errors 💀📝🏗💥 down. It is fine if some errors change balance/etc, as long as they are not new failures.
235
+
236
+ It will also log new passes/fails. Be careful as sometimes the overall passes can increase, but other files have also regressed into failures which you might miss. Also keep in mind some tests may have been false positives before, but we can investigate the diff together :)
237
+
238
+ ### Debugging tips
239
+
240
+ - Use `node test262 path/to/tests` to run specific test262 dirs/files (eg `node test262 built-ins/Date`).
241
+ - Use `--log-errors` to log the errors of individual tests.
242
+ - Use `--debug-asserts` to log expected/actual of assertion failures (experimental).
243
+
244
+ <br>
245
+
246
+ [^1]: The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `4` byte offset for length).
247
+
248
+ [^2]: The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `0` byte offset).
@@ -1,6 +1,5 @@
1
1
  // @porf --funsafe-no-unlikely-proto-checks --valtype=i32
2
2
 
3
- // todo: trimLeft, trimRight
4
3
  export const __String_prototype_trimLeft = (_this: string) => {
5
4
  return __String_prototype_trimStart(_this);
6
5
  };
@@ -1,83 +1,5 @@
1
1
  // @porf --funsafe-no-unlikely-proto-checks --valtype=i32
2
2
 
3
- // while (len >= 8) {
4
- // Porffor.wasm`
5
- // local tmp i64
6
- // local.get ${i}
7
- // i64.load 0 4
8
- // local.set tmp
9
-
10
- // local k i64
11
- // i64.const 0
12
- // local.set k
13
-
14
- // loop 64
15
- // local.get ${j}
16
-
17
- // local.get ${keyStrPtr}
18
-
19
- // local.get tmp
20
-
21
- // ;; k * 6
22
- // i64.const 58
23
-
24
- // local.get k
25
- // i64.const 6
26
- // i64.mul
27
-
28
- // i64.sub
29
-
30
- // ;; tmp >> (58 - (k * 6))
31
- // i64.shr_u
32
-
33
- // ;; (tmp >> (58 - (k * 6))) & 0x3f
34
- // i64.const 63
35
- // i64.and
36
-
37
- // i32.wrap_i64
38
-
39
- // ;; keyStrPtr + ...
40
- // i32.add
41
-
42
- // ;; load character from keyStr
43
- // i32.load8_u 0 4
44
-
45
- // ;; store in output at j
46
- // i32.store8 0 4
47
-
48
- // local.get ${j}
49
- // i32.const 1
50
- // i32.add
51
- // local.set ${j}
52
-
53
- // local.get k
54
- // i64.const 1
55
- // i64.add
56
- // local.tee k
57
-
58
- // i64.const 8
59
- // i64.lt_s
60
- // br_if 0
61
- // end
62
-
63
- // `;
64
-
65
- // // len -= 6;
66
- // i += 6;
67
- // }
68
-
69
- // // while (k < 8) {
70
- // // Porffor.wasm.i32.store8(j++, Porffor.wasm.i32.load8_u(keyStrPtr + Porffor.wasm.i32.wrap_i64(Porffor.wasm.i64.and(
71
- // // Porffor.wasm.i64.shr_u(tmp, Porffor.wasm.i64.extend_i32_u(58 - k * 6)),
72
- // // Porffor.wasm.i64.const(0x3f)
73
- // // )), 0, 4), 0, 4);
74
- // // k += 1;
75
- // // }
76
-
77
- // i += 6;
78
- // len -= 6;
79
- // }
80
-
81
3
  export const btoa = (input: bytestring): bytestring => {
82
4
  const keyStr: bytestring = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
83
5
  const keyStrPtr: i32 = Porffor.wasm`local.get ${keyStr}`;
@@ -89,6 +11,8 @@ export const btoa = (input: bytestring): bytestring => {
89
11
  let i: i32 = Porffor.wasm`local.get ${input}`,
90
12
  j: i32 = Porffor.wasm`local.get ${output}`;
91
13
 
14
+ // todo/perf: add some per 6 char variant using bitwise magic
15
+
92
16
  const endPtr = i + len;
93
17
  while (i < endPtr) {
94
18
  const chr1: i32 = Porffor.wasm.i32.load8_u(i++, 0, 4);
@@ -116,6 +40,7 @@ export const btoa = (input: bytestring): bytestring => {
116
40
  return output;
117
41
  };
118
42
 
43
+ // todo: impl atob by converting below to "porf ts"
119
44
  /* var atob = function (input) {
120
45
  const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
121
46
 
@@ -359,7 +359,7 @@ export const __ecma262_MakeFullYear = (year: number): number => {
359
359
  const truncated: number = __ecma262_ToIntegerOrInfinity(year);
360
360
 
361
361
  // 3. If truncated is in the inclusive interval from 0 to 99, return 1900𝔽 + 𝔽(truncated).
362
- if (truncated >= 0 && truncated <= 99) return 1900 + truncated;
362
+ if (Porffor.fastAnd(truncated >= 0, truncated <= 99)) return 1900 + truncated;
363
363
 
364
364
  // 4. Return 𝔽(truncated).
365
365
  return truncated;
@@ -385,12 +385,6 @@ export const __ecma262_TimeClip = (time: number): number => {
385
385
  // This function returns the time value designating the UTC date and time of the occurrence of the call to it.
386
386
  export const __Date_now = (): number => Math.trunc(performance.timeOrigin + performance.now());
387
387
 
388
- // 21.4.3.2 Date.parse (string)
389
- // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse
390
- export const __Date_parse = (string: bytestring): number => {
391
-
392
- };
393
-
394
388
  // 21.4.3.4 Date.UTC (year [, month [, date [, hours [, minutes [, seconds [, ms ]]]]]])
395
389
  // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.utc
396
390
  export const __Date_UTC = (year: unknown, month: unknown, date: unknown, hours: unknown, minutes: unknown, seconds: unknown, ms: unknown): number => {
@@ -431,6 +425,298 @@ export const __Date_UTC = (year: unknown, month: unknown, date: unknown, hours:
431
425
  };
432
426
 
433
427
 
428
+ export const __ecma262_WeekDayName = (tv: number): bytestring => {
429
+ // Name of the entry in Table 62 with the Number WeekDay(tv).
430
+ // Table 62: Names of days of the week
431
+ // Number Name
432
+ // +0𝔽 "Sun"
433
+ // 1𝔽 "Mon"
434
+ // 2𝔽 "Tue"
435
+ // 3𝔽 "Wed"
436
+ // 4𝔽 "Thu"
437
+ // 5𝔽 "Fri"
438
+ // 6𝔽 "Sat"
439
+
440
+ const weekday: number = __ecma262_WeekDay(tv);
441
+
442
+ const lut: bytestring = 'SunMonTueWedThuFriSat';
443
+
444
+ let out: bytestring = '';
445
+ out.length = 3;
446
+
447
+ let outPtr: number = Porffor.wasm`local.get ${out}`;
448
+ let lutPtr: number = Porffor.wasm`local.get ${lut}` + (weekday * 3);
449
+
450
+ Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
451
+ Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
452
+ Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
453
+
454
+ return out;
455
+ };
456
+
457
+ export const __ecma262_MonthName = (tv: number): bytestring => {
458
+ // Name of the entry in Table 63 with the Number MonthFromTime(tv).
459
+ // Table 63: Names of months of the year
460
+ // Number Name
461
+ // +0𝔽 "Jan"
462
+ // 1𝔽 "Feb"
463
+ // 2𝔽 "Mar"
464
+ // 3𝔽 "Apr"
465
+ // 4𝔽 "May"
466
+ // 5𝔽 "Jun"
467
+ // 6𝔽 "Jul"
468
+ // 7𝔽 "Aug"
469
+ // 8𝔽 "Sep"
470
+ // 9𝔽 "Oct"
471
+ // 10𝔽 "Nov"
472
+ // 11𝔽 "Dec"
473
+
474
+ const month: number = __ecma262_MonthFromTime(tv);
475
+
476
+ const lut: bytestring = 'JanFebMarAprMayJunJulAugSepOctNovDec';
477
+
478
+ let out: bytestring = '';
479
+ out.length = 3;
480
+
481
+ let outPtr: number = Porffor.wasm`local.get ${out}`;
482
+ let lutPtr: number = Porffor.wasm`local.get ${lut}` + (month * 3);
483
+
484
+ Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
485
+ Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
486
+ Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
487
+
488
+ return out;
489
+ };
490
+
491
+ export const __ecma262_ParseMonthName = (ptr: number): number => {
492
+ const a: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 4);
493
+
494
+ if (a == 74) { // J
495
+ const b: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 5);
496
+
497
+ if (b == 97) return 0; // a - Jan
498
+ if (b == 117) { // u
499
+ const c: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 6);
500
+ if (c == 110) return 5; // n - Jun
501
+ if (c == 108) return 6; // l - Jul
502
+ }
503
+ }
504
+
505
+ if (a == 77) { // M
506
+ const b: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 5);
507
+ if (b == 97) { // a
508
+ const c: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 6);
509
+ if (c == 114) return 2; // r - Mar
510
+ if (c == 121) return 4; // y - May
511
+ }
512
+ }
513
+
514
+ if (a == 65) { // A
515
+ const b: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 5);
516
+ if (b == 112) return 3; // p - Apr
517
+ if (b == 117) return 7; // u - Aug
518
+ }
519
+
520
+ if (a == 70) return 1; // F - Feb
521
+ if (a == 83) return 8; // S - Sep
522
+ if (a == 79) return 9; // O - Oct
523
+ if (a == 78) return 10; // N - Nov
524
+ if (a == 68) return 11; // D - Dec
525
+
526
+ return -1;
527
+ };
528
+
529
+
530
+ // DTSF parser
531
+ export const __ecma262_ParseDTSF = (string: bytestring): number => {
532
+ // formats we need to support:
533
+ // > new Date().toISOString()
534
+ // '2024-05-12T02:44:01.529Z'
535
+
536
+ let y: number = 0;
537
+ let m: number = 0;
538
+ let dt: number = 1;
539
+ let h: number = 0;
540
+ let min: number = 0;
541
+ let s: number = 0;
542
+ let milli: number = 0;
543
+ let tzHour: number = 0;
544
+ let tzMin: number = 0;
545
+
546
+ let n: number = 0;
547
+ let nInd: number = 0;
548
+ let z: boolean = false;
549
+
550
+ const len: i32 = string.length;
551
+ const endPtr: i32 = Porffor.wasm`local.get ${string}` + len;
552
+ let ptr: i32 = Porffor.wasm`local.get ${string}`;
553
+
554
+ while (ptr <= endPtr) { // <= to include extra null byte to set last n
555
+ const chr: i32 = Porffor.wasm.i32.load8_u(ptr++, 0, 4);
556
+ if (Porffor.fastAnd(chr >= 48, chr <= 57)) { // 0-9
557
+ n *= 10;
558
+ n += chr - 48;
559
+ continue;
560
+ }
561
+
562
+ if (chr == 45) { // -
563
+ if (Porffor.fastOr(ptr == Porffor.wasm`local.get ${string}`, nInd == 7)) n = -n;
564
+ }
565
+
566
+ if (n > 0) {
567
+ if (nInd == 0) y = n;
568
+ else if (nInd == 1) m = n - 1;
569
+ else if (nInd == 2) dt = n;
570
+ else if (nInd == 3) h = n;
571
+ else if (nInd == 4) min = n;
572
+ else if (nInd == 5) s = n;
573
+ else if (nInd == 6) milli = n;
574
+ else if (nInd == 7) tzHour = n;
575
+ else if (nInd == 8) tzMin = n;
576
+
577
+ n = 0;
578
+ nInd++;
579
+ }
580
+
581
+ if (chr == 90) { // Z
582
+ if (ptr == len) z = true;
583
+ }
584
+ }
585
+
586
+ h += tzHour;
587
+ min += tzMin;
588
+
589
+ return __ecma262_TimeClip(__ecma262_MakeDate(__ecma262_MakeDay(y, m, dt), __ecma262_MakeTime(h, min, s, milli)));
590
+
591
+ // we do not support local time yet so useless check
592
+ // let t: number = __ecma262_TimeClip(__ecma262_MakeDate(__ecma262_MakeDay(y, m, dt), __ecma262_MakeTime(h, min, s, milli)));
593
+
594
+ // "When the time zone offset is absent, date-only forms are interpreted as a UTC time
595
+ // and date-time forms are interpreted as local time.
596
+ // This is due to a historical spec error that was not consistent with ISO 8601
597
+ // but could not be changed due to web compatibility." :))
598
+ // if (Porffor.fastAnd(
599
+ // nInd > 3, // not date-only
600
+ // z == false, // not utc (ending with Z)
601
+ // nInd < 8, // no time zone offset
602
+ // )) {
603
+ // t = __ecma262_UTC(t);
604
+ // }
605
+
606
+ // return t;
607
+ };
608
+
609
+ // RFC 7231 or Date.prototype.toString() parser
610
+ export const __ecma262_ParseRFC7231OrToString = (string: bytestring): number => {
611
+ // formats we need to support:
612
+ // > new Date().toUTCString()
613
+ // 'Sun, 12 May 2024 02:44:10 GMT'
614
+ // > new Date().toString()
615
+ // 'Sun May 12 2024 02:44:13 GMT+0000 (UTC)'
616
+
617
+ // skip week day
618
+ let ptr: i32 = Porffor.wasm`local.get ${string}` + 4;
619
+
620
+ // skip potential ' '
621
+ if (Porffor.wasm.i32.load8_u(ptr, 0, 4) == 32) ptr++;
622
+
623
+ let dt: number = 0;
624
+ let m: number = -1;
625
+
626
+ // check if date now via numerical
627
+ let chr: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 4);
628
+ if (Porffor.fastAnd(chr >= 48, chr <= 57)) { // 0-9
629
+ // date, month name
630
+ while (true) { // use >0 check instead of !=' ' to handle malformed
631
+ chr = Porffor.wasm.i32.load8_u(ptr++, 0, 4);
632
+ if (chr < 48) break;
633
+
634
+ dt *= 10;
635
+ dt += chr - 48;
636
+ }
637
+
638
+ m = __ecma262_ParseMonthName(ptr);
639
+ ptr += 3;
640
+ } else {
641
+ // month name, date
642
+ m = __ecma262_ParseMonthName(ptr);
643
+ ptr += 4;
644
+
645
+ while (true) { // use >0 check instead of !=' ' to handle malformed
646
+ chr = Porffor.wasm.i32.load8_u(ptr++, 0, 4);
647
+ if (chr < 48) break;
648
+
649
+ dt *= 10;
650
+ dt += chr - 48;
651
+ }
652
+ }
653
+
654
+ // check we parsed month and date correctly
655
+ if (Porffor.fastOr(m == -1, dt == 0, dt > 31)) {
656
+ return NaN;
657
+ }
658
+
659
+ let y: number = 0;
660
+ let h: number = 0;
661
+ let min: number = 0;
662
+ let s: number = 0;
663
+ let tz: number = 0;
664
+
665
+ let n: number = 0;
666
+ let nInd: number = 0;
667
+
668
+ const len: i32 = string.length;
669
+ const endPtr: i32 = Porffor.wasm`local.get ${string}` + len;
670
+
671
+ while (ptr <= endPtr) { // <= to include extra null byte to set last n
672
+ const chr: i32 = Porffor.wasm.i32.load8_u(ptr++, 0, 4);
673
+ if (Porffor.fastAnd(chr >= 48, chr <= 57)) { // 0-9
674
+ n *= 10;
675
+ n += chr - 48;
676
+ continue;
677
+ }
678
+
679
+ if (chr == 45) { // -
680
+ if (nInd == 4) n = -n;
681
+ }
682
+
683
+ if (n > 0) {
684
+ if (nInd == 0) y = n;
685
+ else if (nInd == 1) h = n;
686
+ else if (nInd == 2) min = n;
687
+ else if (nInd == 3) s = n;
688
+ else if (nInd == 4) tz = n;
689
+
690
+ n = 0;
691
+ nInd++;
692
+ }
693
+ }
694
+
695
+ return __ecma262_TimeClip(__ecma262_MakeDate(__ecma262_MakeDay(y, m, dt), __ecma262_MakeTime(h, min, s, 0)));
696
+ };
697
+
698
+ // 21.4.3.2 Date.parse (string)
699
+ // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse
700
+ export const __Date_parse = (string: bytestring): number => {
701
+ // formats we need to support:
702
+ // > new Date().toISOString()
703
+ // '2024-05-12T02:44:01.529Z'
704
+ // > new Date().toUTCString()
705
+ // 'Sun, 12 May 2024 02:44:10 GMT'
706
+ // > new Date().toString()
707
+ // 'Sun May 12 2024 02:44:13 GMT+0000 (UTC)'
708
+
709
+ // if first char is numerical, use DTSF parser
710
+ const chr: i32 = Porffor.wasm.i32.load8_u(string, 0, 4);;
711
+ if (Porffor.fastAnd(chr >= 48, chr <= 57)) { // 0-9
712
+ return __ecma262_ParseDTSF(string);
713
+ }
714
+
715
+ // else, use RFC 7231 or Date.prototype.toString() parser
716
+ return __ecma262_ParseRFC7231OrToString(string);
717
+ };
718
+
719
+
434
720
  // dark wasm magic for a basic allocator, sorry.
435
721
  export const __Porffor_date_allocate = (): Date => {
436
722
  const hack: bytestring = '';
@@ -496,7 +782,7 @@ export const Date$constructor = (v0: unknown, v1: unknown, v2: unknown, v3: unkn
496
782
  } else {
497
783
  // c. Else,
498
784
  // ii. If v is a String, then
499
- if (valueType == Porffor.TYPES.string || valueType == Porffor.TYPES._bytestring) {
785
+ if (Porffor.fastOr(valueType == Porffor.TYPES.string, valueType == Porffor.TYPES._bytestring)) {
500
786
  // 1. Assert: The next step never returns an abrupt completion because v is a String.
501
787
 
502
788
  // 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).
@@ -1438,7 +1724,7 @@ export const __ecma262_ToUTCDTSF = (t: number): bytestring => {
1438
1724
  let out: bytestring = '';
1439
1725
  out.length = 0;
1440
1726
 
1441
- if (year < 0 || year >= 10000) {
1727
+ if (Porffor.fastOr(year < 0, year >= 10000)) {
1442
1728
  // extended year format
1443
1729
  // sign
1444
1730
  __Porffor_bytestring_appendChar(out, year > 0 ? 43 : 45);
@@ -1551,69 +1837,6 @@ export const __ecma262_TimeString = (tv: number): bytestring => {
1551
1837
  return out;
1552
1838
  };
1553
1839
 
1554
- export const __ecma262_WeekDayName = (tv: number): bytestring => {
1555
- // Name of the entry in Table 62 with the Number WeekDay(tv).
1556
- // Table 62: Names of days of the week
1557
- // Number Name
1558
- // +0𝔽 "Sun"
1559
- // 1𝔽 "Mon"
1560
- // 2𝔽 "Tue"
1561
- // 3𝔽 "Wed"
1562
- // 4𝔽 "Thu"
1563
- // 5𝔽 "Fri"
1564
- // 6𝔽 "Sat"
1565
-
1566
- const weekday: number = __ecma262_WeekDay(tv);
1567
-
1568
- const lut: bytestring = 'SunMonTueWedThuFriSat';
1569
-
1570
- let out: bytestring = '';
1571
- out.length = 3;
1572
-
1573
- let outPtr: number = Porffor.wasm`local.get ${out}`;
1574
- let lutPtr: number = Porffor.wasm`local.get ${lut}` + (weekday * 3);
1575
-
1576
- Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
1577
- Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
1578
- Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
1579
-
1580
- return out;
1581
- };
1582
-
1583
- export const __ecma262_MonthName = (tv: number): bytestring => {
1584
- // Name of the entry in Table 63 with the Number MonthFromTime(tv).
1585
- // Table 63: Names of months of the year
1586
- // Number Name
1587
- // +0𝔽 "Jan"
1588
- // 1𝔽 "Feb"
1589
- // 2𝔽 "Mar"
1590
- // 3𝔽 "Apr"
1591
- // 4𝔽 "May"
1592
- // 5𝔽 "Jun"
1593
- // 6𝔽 "Jul"
1594
- // 7𝔽 "Aug"
1595
- // 8𝔽 "Sep"
1596
- // 9𝔽 "Oct"
1597
- // 10𝔽 "Nov"
1598
- // 11𝔽 "Dec"
1599
-
1600
- const month: number = __ecma262_MonthFromTime(tv);
1601
-
1602
- const lut: bytestring = 'JanFebMarAprMayJunJulAugSepOctNovDec';
1603
-
1604
- let out: bytestring = '';
1605
- out.length = 3;
1606
-
1607
- let outPtr: number = Porffor.wasm`local.get ${out}`;
1608
- let lutPtr: number = Porffor.wasm`local.get ${lut}` + (month * 3);
1609
-
1610
- Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
1611
- Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
1612
- Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
1613
-
1614
- return out;
1615
- };
1616
-
1617
1840
  // 21.4.4.41.2 DateString (tv)
1618
1841
  // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-datestring
1619
1842
  export const __ecma262_DateString = (tv: number): bytestring => {
@@ -7,23 +7,40 @@ type PorfforGlobal = {
7
7
  wasm: {
8
8
  (...args: any[]): any;
9
9
  i32: {
10
- or(a: i32, b: i32): i32;
11
-
12
10
  load(pointer: i32, align: i32, offset: i32): i32;
13
11
  store(pointer: i32, value: i32, align: i32, offset: i32): i32;
14
12
  load8_u(pointer: i32, align: i32, offset: i32): i32;
15
13
  store8(pointer: i32, value: i32, align: i32, offset: i32): i32;
16
14
  load16_u(pointer: i32, align: i32, offset: i32): i32;
17
15
  store16(pointer: i32, value: i32, align: i32, offset: i32): i32;
16
+ const(value: i32): i32;
17
+ }
18
+
19
+ f64: {
20
+ load(pointer: i32, align: i32, offset: i32): i32;
21
+ store(pointer: i32, value: f64, align: i32, offset: i32): f64;
18
22
  }
19
23
  }
20
24
 
21
- // randomInt(): i32;
22
25
  randomByte(): i32;
23
26
 
24
27
  type(x: any): bytestring;
25
28
  rawType(x: any): i32;
26
- TYPES: Record<string, i32>;
29
+ TYPES: {
30
+ number: i32;
31
+ boolean: i32;
32
+ string: i32;
33
+ undefined: i32;
34
+ object: i32;
35
+ function: i32;
36
+ symbol: i32;
37
+ bigint: i32;
38
+
39
+ _array: i32;
40
+ _regexp: i32;
41
+ _bytestring: i32;
42
+ _date: i32;
43
+ }
27
44
 
28
45
  fastOr(...args: any): boolean;
29
46
  fastAnd(...args: any): boolean;
@@ -915,27 +915,6 @@ export const BuiltinFuncs = function() {
915
915
  ]
916
916
  };
917
917
 
918
- // this.__Porffor_randomInt = {
919
- // params: [],
920
- // locals: prng.locals,
921
- // localNames: [ 's1', 's0' ],
922
- // globals: prng.globals,
923
- // globalNames: [ 'state0', 'state1' ],
924
- // globalInits: [ prngSeed0, prngSeed1 ],
925
- // returns: [ Valtype.i32 ],
926
- // wasm: [
927
- // ...prng.wasm,
928
-
929
- // ...(prng.returns === Valtype.i64 ? [
930
- // // the lowest bits of the output generated by xorshift128+ have low quality
931
- // ...number(56, Valtype.i64),
932
- // [ Opcodes.i64_shr_u ],
933
-
934
- // [ Opcodes.i32_wrap_i64 ],
935
- // ] : []),
936
- // ]
937
- // };
938
-
939
918
  this.__Porffor_randomByte = {
940
919
  params: [],
941
920
  locals: prng.locals,
@@ -1872,9 +1872,6 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
1872
1872
 
1873
1873
  // value
1874
1874
  i32_const: { imms: 1, args: [], returns: 1 },
1875
-
1876
- // a, b
1877
- i32_or: { imms: 0, args: [ true, true ], returns: 1 },
1878
1875
  };
1879
1876
 
1880
1877
  const opName = name.slice('__Porffor_wasm_'.length);
@@ -507,13 +507,13 @@ export const BuiltinFuncs = function() {
507
507
  localNames: ["day","day#type","time","time#type","tv"],
508
508
  };
509
509
  this.__ecma262_MakeFullYear = {
510
- wasm: (scope, { allocPage, builtin }) => [[32,0],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,0],[65,0],[16, builtin('__ecma262_ToIntegerOrInfinity')],[34,2],[68,0,0,0,0,0,0,0,0],[102],[34,3],[4,127],[32,2],[68,0,0,0,0,0,192,88,64],[101],[65,1],[33,4],[5],[32,3],[65,1],[33,4],[11],[4,64],[68,0,0,0,0,0,176,157,64],[32,2],[160],[15],[11],[32,2],[15]],
510
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,0],[65,0],[16, builtin('__ecma262_ToIntegerOrInfinity')],[34,2],[68,0,0,0,0,0,0,0,0],[102],[32,2],[68,0,0,0,0,0,192,88,64],[101],[113],[4,64],[68,0,0,0,0,0,176,157,64],[32,2],[160],[15],[11],[32,2],[15]],
511
511
  params: [124,127],
512
512
  typedParams: true,
513
513
  returns: [124],
514
514
  returnType: 0,
515
- locals: [124,127,127],
516
- localNames: ["year","year#type","truncated","logictmpi","#last_type"],
515
+ locals: [124],
516
+ localNames: ["year","year#type","truncated"],
517
517
  };
518
518
  this.__ecma262_TimeClip = {
519
519
  wasm: (scope, { allocPage, builtin }) => [[32,0],[16, builtin('__Number_isFinite')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,0],[16, builtin('__Math_abs')],[68,0,0,220,194,8,178,62,67],[100],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,0],[65,0],[16, builtin('__ecma262_ToIntegerOrInfinity')],[15]],
@@ -524,6 +524,80 @@ export const BuiltinFuncs = function() {
524
524
  locals: [],
525
525
  localNames: ["time","time#type"],
526
526
  };
527
+ this.__Date_now = {
528
+ wasm: (scope, { allocPage, builtin }) => [[16,3],[16, builtin('__performance_now')],[160],[16, builtin('__Math_trunc')],[15]],
529
+ params: [],
530
+ typedParams: true,
531
+ returns: [124],
532
+ returnType: 0,
533
+ locals: [],
534
+ localNames: [],
535
+ };
536
+ this.__Date_UTC = {
537
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[16, builtin('Number')],[33,14],[68,0,0,0,0,0,0,0,0],[33,15],[32,2],[32,3],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,2],[16, builtin('Number')],[33,15],[11],[68,0,0,0,0,0,0,240,63],[33,16],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,4],[16, builtin('Number')],[33,16],[11],[68,0,0,0,0,0,0,0,0],[33,17],[32,6],[32,7],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,6],[16, builtin('Number')],[33,17],[11],[68,0,0,0,0,0,0,0,0],[33,18],[32,8],[32,9],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,8],[16, builtin('Number')],[33,18],[11],[68,0,0,0,0,0,0,0,0],[33,19],[32,10],[32,11],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,10],[16, builtin('Number')],[33,19],[11],[68,0,0,0,0,0,0,0,0],[33,20],[32,12],[32,13],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,12],[16, builtin('Number')],[33,17],[11],[32,14],[65,0],[16, builtin('__ecma262_MakeFullYear')],[34,21],[65,0],[32,15],[65,0],[32,16],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,17],[65,0],[32,18],[65,0],[32,19],[65,0],[32,20],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[65,0],[16, builtin('__ecma262_TimeClip')],[15]],
538
+ params: [124,127,124,127,124,127,124,127,124,127,124,127,124,127],
539
+ typedParams: true,
540
+ returns: [124],
541
+ returnType: 0,
542
+ locals: [124,124,124,124,124,124,124,124],
543
+ localNames: ["year","year#type","month","month#type","date","date#type","hours","hours#type","minutes","minutes#type","seconds","seconds#type","ms","ms#type","y","m","dt","h","min","s","milli","yr"],
544
+ };
545
+ this.__ecma262_WeekDayName = {
546
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_WeekDay')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_WeekDayName/lut', 'i8') * pageSize, 124),[33,3],...number(allocPage(scope, 'bytestring: __ecma262_WeekDayName/out', 'i8') * pageSize, 124),[34,4],[252,3],[68,0,0,0,0,0,0,8,64],[34,5],[252,3],[54,1,0],[32,4],[33,6],[32,3],[32,2],[68,0,0,0,0,0,0,8,64],[162],[160],[33,7],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[252,2],[32,7],[252,2],[45,0,4],[58,0,4],[32,4],[15]],
547
+ params: [124,127],
548
+ typedParams: true,
549
+ returns: [124],
550
+ returnType: 18,
551
+ locals: [124,124,124,124,124,124],
552
+ localNames: ["tv","tv#type","weekday","lut","out","__length_setter_tmp","outPtr","lutPtr"],
553
+ data: [{"offset":0,"bytes":[21,0,0,0,83,117,110,77,111,110,84,117,101,87,101,100,84,104,117,70,114,105,83,97,116]}],
554
+ };
555
+ this.__ecma262_MonthName = {
556
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_MonthFromTime')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_MonthName/lut', 'i8') * pageSize, 124),[33,3],...number(allocPage(scope, 'bytestring: __ecma262_MonthName/out', 'i8') * pageSize, 124),[34,4],[252,3],[68,0,0,0,0,0,0,8,64],[34,5],[252,3],[54,1,0],[32,4],[33,6],[32,3],[32,2],[68,0,0,0,0,0,0,8,64],[162],[160],[33,7],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[252,2],[32,7],[252,2],[45,0,4],[58,0,4],[32,4],[15]],
557
+ params: [124,127],
558
+ typedParams: true,
559
+ returns: [124],
560
+ returnType: 18,
561
+ locals: [124,124,124,124,124,124],
562
+ localNames: ["tv","tv#type","month","lut","out","__length_setter_tmp","outPtr","lutPtr"],
563
+ data: [{"offset":0,"bytes":[36,0,0,0,74,97,110,70,101,98,77,97,114,65,112,114,77,97,121,74,117,110,74,117,108,65,117,103,83,101,112,79,99,116,78,111,118,68,101,99]}],
564
+ };
565
+ this.__ecma262_ParseMonthName = {
566
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[252,2],[45,0,4],[183],[34,2],[68,0,0,0,0,0,128,82,64],[97],[4,64],[32,0],[252,2],[45,0,5],[183],[34,3],[68,0,0,0,0,0,64,88,64],[97],[4,64],[68,0,0,0,0,0,0,0,0],[15],[11],[32,3],[68,0,0,0,0,0,64,93,64],[97],[4,64],[32,0],[252,2],[45,0,6],[183],[34,4],[68,0,0,0,0,0,128,91,64],[97],[4,64],[68,0,0,0,0,0,0,20,64],[15],[11],[32,4],[68,0,0,0,0,0,0,91,64],[97],[4,64],[68,0,0,0,0,0,0,24,64],[15],[11],[11],[11],[32,2],[68,0,0,0,0,0,64,83,64],[97],[4,64],[32,0],[252,2],[45,0,5],[183],[34,3],[68,0,0,0,0,0,64,88,64],[97],[4,64],[32,0],[252,2],[45,0,6],[183],[34,4],[68,0,0,0,0,0,128,92,64],[97],[4,64],[68,0,0,0,0,0,0,0,64],[15],[11],[32,4],[68,0,0,0,0,0,64,94,64],[97],[4,64],[68,0,0,0,0,0,0,16,64],[15],[11],[11],[11],[32,2],[68,0,0,0,0,0,64,80,64],[97],[4,64],[32,0],[252,2],[45,0,5],[183],[34,3],[68,0,0,0,0,0,0,92,64],[97],[4,64],[68,0,0,0,0,0,0,8,64],[15],[11],[32,3],[68,0,0,0,0,0,64,93,64],[97],[4,64],[68,0,0,0,0,0,0,28,64],[15],[11],[11],[32,2],[68,0,0,0,0,0,128,81,64],[97],[4,64],[68,0,0,0,0,0,0,240,63],[15],[11],[32,2],[68,0,0,0,0,0,192,84,64],[97],[4,64],[68,0,0,0,0,0,0,32,64],[15],[11],[32,2],[68,0,0,0,0,0,192,83,64],[97],[4,64],[68,0,0,0,0,0,0,34,64],[15],[11],[32,2],[68,0,0,0,0,0,128,83,64],[97],[4,64],[68,0,0,0,0,0,0,36,64],[15],[11],[32,2],[68,0,0,0,0,0,0,81,64],[97],[4,64],[68,0,0,0,0,0,0,38,64],[15],[11],[68,0,0,0,0,0,0,240,191],[15]],
567
+ params: [124,127],
568
+ typedParams: true,
569
+ returns: [124],
570
+ returnType: 0,
571
+ locals: [124,124,124],
572
+ localNames: ["ptr","ptr#type","a","b","c"],
573
+ };
574
+ this.__ecma262_ParseDTSF = {
575
+ wasm: (scope, { allocPage, builtin }) => [[68,0,0,0,0,0,0,0,0],[33,2],[68,0,0,0,0,0,0,0,0],[33,3],[68,0,0,0,0,0,0,240,63],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[68,0,0,0,0,0,0,0,0],[33,6],[68,0,0,0,0,0,0,0,0],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[68,0,0,0,0,0,0,0,0],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[68,0,0,0,0,0,0,0,0],[33,11],[68,0,0,0,0,0,0,0,0],[33,12],[68,0,0,0,0,0,0,0,0],[33,13],[32,0],[252,3],[40,1,0],[184],[33,14],[32,0],[32,14],[160],[33,15],[32,0],[33,16],[3,64],[32,16],[32,15],[101],[4,64],[32,16],[32,16],[68,0,0,0,0,0,0,240,63],[160],[33,16],[252,2],[45,0,4],[183],[34,17],[68,0,0,0,0,0,0,72,64],[102],[32,17],[68,0,0,0,0,0,128,76,64],[101],[113],[4,64],[32,11],[68,0,0,0,0,0,0,36,64],[162],[34,11],[32,17],[68,0,0,0,0,0,0,72,64],[161],[160],[33,11],[12,2],[11],[32,17],[68,0,0,0,0,0,128,70,64],[97],[4,64],[32,16],[32,0],[97],[32,12],[68,0,0,0,0,0,0,28,64],[97],[114],[4,64],[32,11],[154],[33,11],[11],[11],[32,11],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,12],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,11],[33,2],[5],[32,12],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,11],[68,0,0,0,0,0,0,240,63],[161],[33,3],[5],[32,12],[68,0,0,0,0,0,0,0,64],[97],[4,64],[32,11],[33,4],[5],[32,12],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,11],[33,5],[5],[32,12],[68,0,0,0,0,0,0,16,64],[97],[4,64],[32,11],[33,6],[5],[32,12],[68,0,0,0,0,0,0,20,64],[97],[4,64],[32,11],[33,7],[5],[32,12],[68,0,0,0,0,0,0,24,64],[97],[4,64],[32,11],[33,8],[5],[32,12],[68,0,0,0,0,0,0,28,64],[97],[4,64],[32,11],[33,9],[5],[32,12],[68,0,0,0,0,0,0,32,64],[97],[4,64],[32,11],[33,10],[11],[11],[11],[11],[11],[11],[11],[11],[11],[68,0,0,0,0,0,0,0,0],[33,11],[32,12],[68,0,0,0,0,0,0,240,63],[160],[33,12],[11],[32,17],[68,0,0,0,0,0,128,86,64],[97],[4,64],[32,16],[32,14],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,13],[11],[11],[12,1],[11],[11],[32,5],[32,9],[160],[33,5],[32,6],[32,10],[160],[33,6],[32,2],[65,0],[32,3],[65,0],[32,4],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,5],[65,0],[32,6],[65,0],[32,7],[65,0],[32,8],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[65,0],[16, builtin('__ecma262_TimeClip')],[15]],
576
+ params: [124,127],
577
+ typedParams: true,
578
+ returns: [124],
579
+ returnType: 0,
580
+ locals: [124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124],
581
+ localNames: ["string","string#type","y","m","dt","h","min","s","milli","tzHour","tzMin","n","nInd","z","len","endPtr","ptr","chr"],
582
+ };
583
+ this.__ecma262_ParseRFC7231OrToString = {
584
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[68,0,0,0,0,0,0,16,64],[160],[34,2],[252,2],[45,0,4],[183],[68,0,0,0,0,0,0,64,64],[97],[4,64],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[11],[68,0,0,0,0,0,0,0,0],[33,3],[68,0,0,0,0,0,0,240,191],[33,4],[32,2],[252,2],[45,0,4],[183],[34,5],[68,0,0,0,0,0,0,72,64],[102],[32,5],[68,0,0,0,0,0,128,76,64],[101],[113],[4,64],[3,64],[65,1],[4,64],[32,2],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[252,2],[45,0,4],[183],[34,5],[68,0,0,0,0,0,0,72,64],[99],[4,64],[12,1],[11],[32,3],[68,0,0,0,0,0,0,36,64],[162],[34,3],[32,5],[68,0,0,0,0,0,0,72,64],[161],[160],[33,3],[12,1],[11],[11],[32,2],[65,0],[16, builtin('__ecma262_ParseMonthName')],[33,4],[32,2],[68,0,0,0,0,0,0,8,64],[160],[33,2],[5],[32,2],[65,0],[16, builtin('__ecma262_ParseMonthName')],[33,4],[32,2],[68,0,0,0,0,0,0,16,64],[160],[33,2],[3,64],[65,1],[4,64],[32,2],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[252,2],[45,0,4],[183],[34,5],[68,0,0,0,0,0,0,72,64],[99],[4,64],[12,1],[11],[32,3],[68,0,0,0,0,0,0,36,64],[162],[34,3],[32,5],[68,0,0,0,0,0,0,72,64],[161],[160],[33,3],[12,1],[11],[11],[11],[32,4],[68,0,0,0,0,0,0,240,191],[97],[32,3],[68,0,0,0,0,0,0,0,0],[97],[114],[32,3],[68,0,0,0,0,0,0,63,64],[100],[114],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[68,0,0,0,0,0,0,0,0],[33,6],[68,0,0,0,0,0,0,0,0],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[68,0,0,0,0,0,0,0,0],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[68,0,0,0,0,0,0,0,0],[33,11],[68,0,0,0,0,0,0,0,0],[33,12],[32,0],[252,3],[40,1,0],[184],[33,13],[32,0],[32,13],[160],[33,14],[3,64],[32,2],[32,14],[101],[4,64],[32,2],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[252,2],[45,0,4],[183],[34,5],[68,0,0,0,0,0,0,72,64],[102],[32,5],[68,0,0,0,0,0,128,76,64],[101],[113],[4,64],[32,11],[68,0,0,0,0,0,0,36,64],[162],[34,11],[32,5],[68,0,0,0,0,0,0,72,64],[161],[160],[33,11],[12,2],[11],[32,5],[68,0,0,0,0,0,128,70,64],[97],[4,64],[32,12],[68,0,0,0,0,0,0,16,64],[97],[4,64],[32,11],[154],[33,11],[11],[11],[32,11],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,12],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,11],[33,6],[5],[32,12],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,11],[33,7],[5],[32,12],[68,0,0,0,0,0,0,0,64],[97],[4,64],[32,11],[33,8],[5],[32,12],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,11],[33,9],[5],[32,12],[68,0,0,0,0,0,0,16,64],[97],[4,64],[32,11],[33,10],[11],[11],[11],[11],[11],[68,0,0,0,0,0,0,0,0],[33,11],[32,12],[68,0,0,0,0,0,0,240,63],[160],[33,12],[11],[12,1],[11],[11],[32,6],[65,0],[32,4],[65,0],[32,3],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,7],[65,0],[32,8],[65,0],[32,9],[65,0],[68,0,0,0,0,0,0,0,0],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[65,0],[16, builtin('__ecma262_TimeClip')],[15]],
585
+ params: [124,127],
586
+ typedParams: true,
587
+ returns: [124],
588
+ returnType: 0,
589
+ locals: [124,124,124,124,124,124,124,124,124,124,124,124,124],
590
+ localNames: ["string","string#type","ptr","dt","m","chr","y","h","min","s","tz","n","nInd","len","endPtr"],
591
+ };
592
+ this.__Date_parse = {
593
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[252,2],[45,0,4],[183],[34,2],[68,0,0,0,0,0,0,72,64],[102],[32,2],[68,0,0,0,0,0,128,76,64],[101],[113],[4,64],[32,0],[65,18],[16, builtin('__ecma262_ParseDTSF')],[15],[11],[32,0],[65,18],[16, builtin('__ecma262_ParseRFC7231OrToString')],[15]],
594
+ params: [124,127],
595
+ typedParams: true,
596
+ returns: [124],
597
+ returnType: 0,
598
+ locals: [124],
599
+ localNames: ["string","string#type","chr"],
600
+ };
527
601
  this.__Porffor_date_allocate = {
528
602
  wasm: (scope, { allocPage, builtin }) => [...number(allocPage(scope, 'bytestring: __Porffor_date_allocate/hack', 'i8') * pageSize, 124),[34,0],[252,3],[40,1,0],[184],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,0],[252,3],[65,1],[64,0],[26],[63,0],[65,1],[107],[65,128,128,4],[108],[184],[34,1],[252,3],[54,1,0],[11],[32,0],[252,3],[40,1,0],[184],[33,2],[32,0],[252,3],[32,2],[68,0,0,0,0,0,0,32,64],[160],[34,1],[252,3],[54,1,0],[32,2],[15]],
529
603
  params: [],
@@ -552,31 +626,13 @@ export const BuiltinFuncs = function() {
552
626
  localNames: ["ptr","ptr#type","val","val#type"],
553
627
  };
554
628
  this.Date$constructor = {
555
- wasm: (scope, { allocPage, builtin }) => [[32,0],[32,1],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[32,2],[32,3],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,6],[32,7],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,8],[32,9],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,10],[32,11],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,12],[32,13],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[33,14],[68,0,0,0,0,0,0,0,0],[33,15],[32,14],[68,0,0,0,0,0,0,0,0],[97],[4,64],[16, builtin('__Date_now')],[33,15],[5],[32,14],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,0],[33,16],[32,1],[33,17],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[33,18],[68,0,0,0,0,0,0,0,0],[33,19],[32,18],[68,0,0,0,0,0,0,51,64],[97],[4,64],[32,16],[32,17],[16, builtin('__Porffor_date_read')],[33,19],[5],[32,18],[68,0,0,0,0,0,0,0,64],[97],[34,20],[69],[4,127],[32,18],[68,0,0,0,0,0,0,50,64],[97],[65,1],[33,21],[5],[32,20],[65,1],[33,21],[11],[4,64],[5],[32,16],[16, builtin('Number')],[33,19],[11],[11],[32,19],[65,0],[16, builtin('__ecma262_TimeClip')],[33,15],[5],[32,0],[16, builtin('Number')],[33,22],[32,2],[16, builtin('Number')],[33,23],[68,0,0,0,0,0,0,240,63],[33,24],[32,14],[68,0,0,0,0,0,0,0,64],[100],[4,64],[32,4],[16, builtin('Number')],[33,24],[11],[68,0,0,0,0,0,0,0,0],[33,25],[32,14],[68,0,0,0,0,0,0,8,64],[100],[4,64],[32,6],[16, builtin('Number')],[33,25],[11],[68,0,0,0,0,0,0,0,0],[33,26],[32,14],[68,0,0,0,0,0,0,16,64],[100],[4,64],[32,8],[16, builtin('Number')],[33,26],[11],[68,0,0,0,0,0,0,0,0],[33,27],[32,14],[68,0,0,0,0,0,0,20,64],[100],[4,64],[32,10],[16, builtin('Number')],[33,27],[11],[68,0,0,0,0,0,0,0,0],[33,28],[32,14],[68,0,0,0,0,0,0,24,64],[100],[4,64],[32,12],[16, builtin('Number')],[33,28],[11],[32,22],[65,0],[16, builtin('__ecma262_MakeFullYear')],[34,29],[65,0],[32,23],[65,0],[32,24],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,25],[65,0],[32,26],[65,0],[32,27],[65,0],[32,28],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[34,30],[65,0],[16, builtin('__ecma262_UTC')],[65,0],[16, builtin('__ecma262_TimeClip')],[33,15],[11],[11],[16, builtin('__Porffor_date_allocate')],[34,31],[65,19],[32,15],[65,0],[16, builtin('__Porffor_date_write')],[33,21],[26],[32,31],[15]],
629
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[32,1],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[32,2],[32,3],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,6],[32,7],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,8],[32,9],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,10],[32,11],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[32,12],[32,13],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[184],[160],[33,14],[68,0,0,0,0,0,0,0,0],[33,15],[32,14],[68,0,0,0,0,0,0,0,0],[97],[4,64],[16, builtin('__Date_now')],[33,15],[5],[32,14],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,0],[33,16],[32,1],[33,17],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[33,18],[68,0,0,0,0,0,0,0,0],[33,19],[32,18],[68,0,0,0,0,0,0,51,64],[97],[4,64],[32,16],[32,17],[16, builtin('__Porffor_date_read')],[33,19],[5],[32,18],[68,0,0,0,0,0,0,0,64],[97],[32,18],[68,0,0,0,0,0,0,50,64],[97],[114],[4,64],[32,16],[32,17],[16, builtin('__Date_parse')],[33,19],[5],[32,16],[16, builtin('Number')],[33,19],[11],[11],[32,19],[65,0],[16, builtin('__ecma262_TimeClip')],[33,15],[5],[32,0],[16, builtin('Number')],[33,20],[32,2],[16, builtin('Number')],[33,21],[68,0,0,0,0,0,0,240,63],[33,22],[32,14],[68,0,0,0,0,0,0,0,64],[100],[4,64],[32,4],[16, builtin('Number')],[33,22],[11],[68,0,0,0,0,0,0,0,0],[33,23],[32,14],[68,0,0,0,0,0,0,8,64],[100],[4,64],[32,6],[16, builtin('Number')],[33,23],[11],[68,0,0,0,0,0,0,0,0],[33,24],[32,14],[68,0,0,0,0,0,0,16,64],[100],[4,64],[32,8],[16, builtin('Number')],[33,24],[11],[68,0,0,0,0,0,0,0,0],[33,25],[32,14],[68,0,0,0,0,0,0,20,64],[100],[4,64],[32,10],[16, builtin('Number')],[33,25],[11],[68,0,0,0,0,0,0,0,0],[33,26],[32,14],[68,0,0,0,0,0,0,24,64],[100],[4,64],[32,12],[16, builtin('Number')],[33,26],[11],[32,20],[65,0],[16, builtin('__ecma262_MakeFullYear')],[34,27],[65,0],[32,21],[65,0],[32,22],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,23],[65,0],[32,24],[65,0],[32,25],[65,0],[32,26],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[34,28],[65,0],[16, builtin('__ecma262_UTC')],[65,0],[16, builtin('__ecma262_TimeClip')],[33,15],[11],[11],[16, builtin('__Porffor_date_allocate')],[34,29],[65,19],[32,15],[65,0],[16, builtin('__Porffor_date_write')],[26],[26],[32,29],[15]],
556
630
  params: [124,127,124,127,124,127,124,127,124,127,124,127,124,127],
557
631
  typedParams: true,
558
632
  returns: [124],
559
633
  returnType: 19,
560
- locals: [124,124,124,127,124,124,127,127,124,124,124,124,124,124,124,124,124,124],
561
- localNames: ["v0","v0#type","v1","v1#type","v2","v2#type","v3","v3#type","v4","v4#type","v5","v5#type","v6","v6#type","numberOfArgs","dv","value","value#type","valueType","tv","logictmpi","#last_type","y","m","dt","h","min","s","milli","yr","finalDate","O"],
562
- };
563
- this.__Date_now = {
564
- wasm: (scope, { allocPage, builtin }) => [[16,3],[16, builtin('__performance_now')],[160],[16, builtin('__Math_trunc')],[15]],
565
- params: [],
566
- typedParams: true,
567
- returns: [124],
568
- returnType: 0,
569
- locals: [],
570
- localNames: [],
571
- };
572
- this.__Date_UTC = {
573
- wasm: (scope, { allocPage, builtin }) => [[32,0],[16, builtin('Number')],[33,14],[68,0,0,0,0,0,0,0,0],[33,15],[32,2],[32,3],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,2],[16, builtin('Number')],[33,15],[11],[68,0,0,0,0,0,0,240,63],[33,16],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,4],[16, builtin('Number')],[33,16],[11],[68,0,0,0,0,0,0,0,0],[33,17],[32,6],[32,7],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,6],[16, builtin('Number')],[33,17],[11],[68,0,0,0,0,0,0,0,0],[33,18],[32,8],[32,9],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,8],[16, builtin('Number')],[33,18],[11],[68,0,0,0,0,0,0,0,0],[33,19],[32,10],[32,11],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,10],[16, builtin('Number')],[33,19],[11],[68,0,0,0,0,0,0,0,0],[33,20],[32,12],[32,13],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[98],[4,64],[32,12],[16, builtin('Number')],[33,17],[11],[32,14],[65,0],[16, builtin('__ecma262_MakeFullYear')],[34,21],[65,0],[32,15],[65,0],[32,16],[65,0],[16, builtin('__ecma262_MakeDay')],[65,0],[32,17],[65,0],[32,18],[65,0],[32,19],[65,0],[32,20],[65,0],[16, builtin('__ecma262_MakeTime')],[65,0],[16, builtin('__ecma262_MakeDate')],[65,0],[16, builtin('__ecma262_TimeClip')],[15]],
574
- params: [124,127,124,127,124,127,124,127,124,127,124,127,124,127],
575
- typedParams: true,
576
- returns: [124],
577
- returnType: 0,
578
- locals: [124,124,124,124,124,124,124,124],
579
- localNames: ["year","year#type","month","month#type","date","date#type","hours","hours#type","minutes","minutes#type","seconds","seconds#type","ms","ms#type","y","m","dt","h","min","s","milli","yr"],
634
+ locals: [124,124,124,127,124,124,124,124,124,124,124,124,124,124,124,124,127],
635
+ localNames: ["v0","v0#type","v1","v1#type","v2","v2#type","v3","v3#type","v4","v4#type","v5","v5#type","v6","v6#type","numberOfArgs","dv","value","value#type","valueType","tv","y","m","dt","h","min","s","milli","yr","finalDate","O","#last_type"],
580
636
  };
581
637
  this.___date_prototype_getDate = {
582
638
  wasm: (scope, { allocPage, builtin }) => [[32,0],[65,19],[16, builtin('__Porffor_date_read')],[34,2],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[65,0],[15],[11],[32,2],[65,0],[16, builtin('__ecma262_LocalTime')],[65,0],[16, builtin('__ecma262_DateFromTime')],[65,0],[15]],
@@ -903,13 +959,13 @@ export const BuiltinFuncs = function() {
903
959
  localNames: ["str","str#type","num","num#type","len","len#type","numStr","#last_type","strPtr","numStrLen","strPtrEnd","numPtr","numPtrEnd","__length_setter_tmp"],
904
960
  };
905
961
  this.__ecma262_ToUTCDTSF = {
906
- wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_YearFromTime')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_ToUTCDTSF/out', 'i8') * pageSize, 124),[34,3],[252,3],[68,0,0,0,0,0,0,0,0],[34,4],[252,3],[54,1,0],[32,2],[68,0,0,0,0,0,0,0,0],[99],[34,5],[69],[4,127],[32,2],[68,0,0,0,0,0,136,195,64],[102],[65,1],[33,6],[5],[32,5],[65,1],[33,6],[11],[4,64],[32,3],[65,18],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,124],[68,0,0,0,0,0,128,69,64],[65,0],[33,6],[5],[68,0,0,0,0,0,128,70,64],[65,0],[33,6],[11],[32,6],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,2],[65,0],[68,0,0,0,0,0,0,24,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[5],[32,3],[65,18],[32,2],[65,0],[68,0,0,0,0,0,0,16,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[11],[32,3],[65,18],[68,0,0,0,0,0,128,70,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_MonthFromTime')],[68,0,0,0,0,0,0,240,63],[160],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,128,70,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_DateFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,85,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_HourFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,77,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_MinFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,77,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_SecFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,71,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_msFromTime')],[65,0],[68,0,0,0,0,0,0,8,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,128,86,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[15]],
962
+ wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_YearFromTime')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_ToUTCDTSF/out', 'i8') * pageSize, 124),[34,3],[252,3],[68,0,0,0,0,0,0,0,0],[34,4],[252,3],[54,1,0],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,136,195,64],[102],[114],[4,64],[32,3],[65,18],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,124],[68,0,0,0,0,0,128,69,64],[65,0],[33,5],[5],[68,0,0,0,0,0,128,70,64],[65,0],[33,5],[11],[32,5],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,2],[65,0],[68,0,0,0,0,0,0,24,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[5],[32,3],[65,18],[32,2],[65,0],[68,0,0,0,0,0,0,16,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[11],[32,3],[65,18],[68,0,0,0,0,0,128,70,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_MonthFromTime')],[68,0,0,0,0,0,0,240,63],[160],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,128,70,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_DateFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,85,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_HourFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,77,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_MinFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,77,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_SecFromTime')],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,0,71,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[65,18],[32,0],[65,0],[16, builtin('__ecma262_msFromTime')],[65,0],[68,0,0,0,0,0,0,8,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,3],[65,18],[68,0,0,0,0,0,128,86,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,3],[15]],
907
963
  params: [124,127],
908
964
  typedParams: true,
909
965
  returns: [124],
910
966
  returnType: 18,
911
- locals: [124,124,124,127,127],
912
- localNames: ["t","t#type","year","out","__length_setter_tmp","logictmpi","#last_type"],
967
+ locals: [124,124,124,127],
968
+ localNames: ["t","t#type","year","out","__length_setter_tmp","#last_type"],
913
969
  };
914
970
  this.___date_prototype_toISOString = {
915
971
  wasm: (scope, { allocPage, builtin }) => [[32,0],[65,19],[16, builtin('__Porffor_date_read')],[34,2],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[65,3],[15],[11],[32,2],[65,0],[16, builtin('__ecma262_ToUTCDTSF')],[65,18],[15]],
@@ -938,26 +994,6 @@ export const BuiltinFuncs = function() {
938
994
  locals: [124,124,124,124,124],
939
995
  localNames: ["tv","tv#type","hour","minute","second","out","__length_setter_tmp"],
940
996
  };
941
- this.__ecma262_WeekDayName = {
942
- wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_WeekDay')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_WeekDayName/lut', 'i8') * pageSize, 124),[33,3],...number(allocPage(scope, 'bytestring: __ecma262_WeekDayName/out', 'i8') * pageSize, 124),[34,4],[252,3],[68,0,0,0,0,0,0,8,64],[34,5],[252,3],[54,1,0],[32,4],[33,6],[32,3],[32,2],[68,0,0,0,0,0,0,8,64],[162],[160],[33,7],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[252,2],[32,7],[252,2],[45,0,4],[58,0,4],[32,4],[15]],
943
- params: [124,127],
944
- typedParams: true,
945
- returns: [124],
946
- returnType: 18,
947
- locals: [124,124,124,124,124,124],
948
- localNames: ["tv","tv#type","weekday","lut","out","__length_setter_tmp","outPtr","lutPtr"],
949
- data: [{"offset":0,"bytes":[21,0,0,0,83,117,110,77,111,110,84,117,101,87,101,100,84,104,117,70,114,105,83,97,116]}],
950
- };
951
- this.__ecma262_MonthName = {
952
- wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_MonthFromTime')],[33,2],...number(allocPage(scope, 'bytestring: __ecma262_MonthName/lut', 'i8') * pageSize, 124),[33,3],...number(allocPage(scope, 'bytestring: __ecma262_MonthName/out', 'i8') * pageSize, 124),[34,4],[252,3],[68,0,0,0,0,0,0,8,64],[34,5],[252,3],[54,1,0],[32,4],[33,6],[32,3],[32,2],[68,0,0,0,0,0,0,8,64],[162],[160],[33,7],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[32,6],[252,2],[32,7],[252,2],[45,0,4],[58,0,4],[32,4],[15]],
953
- params: [124,127],
954
- typedParams: true,
955
- returns: [124],
956
- returnType: 18,
957
- locals: [124,124,124,124,124,124],
958
- localNames: ["tv","tv#type","month","lut","out","__length_setter_tmp","outPtr","lutPtr"],
959
- data: [{"offset":0,"bytes":[36,0,0,0,74,97,110,70,101,98,77,97,114,65,112,114,77,97,121,74,117,110,74,117,108,65,117,103,83,101,112,79,99,116,78,111,118,68,101,99]}],
960
- };
961
997
  this.__ecma262_DateString = {
962
998
  wasm: (scope, { allocPage, builtin }) => [[32,0],[65,0],[16, builtin('__ecma262_WeekDayName')],[33,2],[32,0],[65,0],[16, builtin('__ecma262_MonthName')],[33,3],[32,0],[65,0],[16, builtin('__ecma262_DateFromTime')],[33,4],[32,0],[65,0],[16, builtin('__ecma262_YearFromTime')],[33,5],...number(allocPage(scope, 'bytestring: __ecma262_DateString/out', 'i8') * pageSize, 124),[34,6],[252,3],[68,0,0,0,0,0,0,0,0],[34,7],[252,3],[54,1,0],[32,6],[65,18],[32,2],[65,18],[16, builtin('__Porffor_bytestring_appendStr')],[26],[32,6],[65,18],[68,0,0,0,0,0,0,64,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,18],[32,3],[65,18],[16, builtin('__Porffor_bytestring_appendStr')],[26],[32,6],[65,18],[68,0,0,0,0,0,0,64,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,18],[32,4],[65,0],[68,0,0,0,0,0,0,0,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,6],[65,18],[68,0,0,0,0,0,0,64,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[32,5],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[65,18],[68,0,0,0,0,0,128,70,64],[65,0],[16, builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,6],[65,18],[32,5],[65,0],[68,0,0,0,0,0,0,16,64],[65,0],[16, builtin('__Porffor_bytestring_appendPadNum')],[26],[32,6],[15]],
963
999
  params: [124,127],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.2.0-6352ecf",
4
+ "version": "0.2.0-664913c",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {