porffor 0.24.6 → 0.24.8
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/number.ts +57 -51
- package/compiler/builtins/stringtonumber.ts +121 -0
- package/compiler/builtins/z_ecma262.ts +0 -7
- package/compiler/builtins_precompiled.js +39 -9
- package/compiler/index.js +2 -2
- package/compiler/precompile.js +12 -3
- package/compiler/wrap.js +1 -1
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -533,7 +533,7 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
533
533
|
// todo/perf: optimize this instead of doing a naive algo (https://kholdstare.github.io/technical/2020/05/26/faster-integer-parsing.html)
|
534
534
|
// todo/perf: use i32s here once that becomes not annoying
|
535
535
|
|
536
|
-
input = ecma262.ToString(input);
|
536
|
+
input = ecma262.ToString(input).trim();
|
537
537
|
|
538
538
|
let defaultRadix: boolean = false;
|
539
539
|
radix = ecma262.ToIntegerOrInfinity(radix);
|
@@ -543,22 +543,22 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
543
543
|
}
|
544
544
|
if (radix < 2 || radix > 36) return NaN;
|
545
545
|
|
546
|
-
let nMax:
|
546
|
+
let nMax: i32 = 58;
|
547
547
|
if (radix < 10) nMax = 48 + radix;
|
548
548
|
|
549
549
|
let n: f64 = NaN;
|
550
550
|
|
551
|
-
const inputPtr:
|
552
|
-
const len:
|
553
|
-
let i:
|
551
|
+
const inputPtr: i32 = Porffor.wasm`local.get ${input}`;
|
552
|
+
const len: i32 = Porffor.wasm.i32.load(inputPtr, 0, 0);
|
553
|
+
let i: i32 = inputPtr;
|
554
554
|
|
555
555
|
let negative: boolean = false;
|
556
556
|
|
557
557
|
if (Porffor.rawType(input) == Porffor.TYPES.bytestring) {
|
558
|
-
const endPtr:
|
558
|
+
const endPtr: i32 = i + len;
|
559
559
|
|
560
560
|
// check start of string
|
561
|
-
const startChr:
|
561
|
+
const startChr: i32 = Porffor.wasm.i32.load8_u(i, 0, 4);
|
562
562
|
|
563
563
|
// +, ignore
|
564
564
|
if (startChr == 43) i++;
|
@@ -571,7 +571,7 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
571
571
|
|
572
572
|
// 0, potential start of hex
|
573
573
|
if ((defaultRadix || radix == 16) && startChr == 48) {
|
574
|
-
const second:
|
574
|
+
const second: i32 = Porffor.wasm.i32.load8_u(i + 1, 0, 4);
|
575
575
|
// 0x or 0X
|
576
576
|
if (second == 120 || second == 88) {
|
577
577
|
// set radix to 16 and skip leading 2 chars
|
@@ -581,24 +581,18 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
581
581
|
}
|
582
582
|
|
583
583
|
while (i < endPtr) {
|
584
|
-
const chr:
|
584
|
+
const chr: i32 = Porffor.wasm.i32.load8_u(i++, 0, 4);
|
585
585
|
|
586
586
|
if (chr >= 48 && chr < nMax) {
|
587
587
|
if (Number.isNaN(n)) n = 0;
|
588
|
-
|
589
|
-
n *= radix;
|
590
|
-
n += chr - 48;
|
588
|
+
n = (n * radix) + chr - 48;
|
591
589
|
} else if (radix > 10) {
|
592
590
|
if (chr >= 97 && chr < (87 + radix)) {
|
593
591
|
if (Number.isNaN(n)) n = 0;
|
594
|
-
|
595
|
-
n *= radix;
|
596
|
-
n += chr - 87;
|
592
|
+
n = (n * radix) + chr - 87;
|
597
593
|
} else if (chr >= 65 && chr < (55 + radix)) {
|
598
594
|
if (Number.isNaN(n)) n = 0;
|
599
|
-
|
600
|
-
n *= radix;
|
601
|
-
n += chr - 55;
|
595
|
+
n = (n * radix) + chr - 55;
|
602
596
|
} else {
|
603
597
|
break;
|
604
598
|
}
|
@@ -611,10 +605,10 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
611
605
|
return n;
|
612
606
|
}
|
613
607
|
|
614
|
-
const endPtr:
|
608
|
+
const endPtr: i32 = i + len * 2;
|
615
609
|
|
616
610
|
// check start of string
|
617
|
-
const startChr:
|
611
|
+
const startChr: i32 = Porffor.wasm.i32.load16_u(i, 0, 4);
|
618
612
|
|
619
613
|
// +, ignore
|
620
614
|
if (startChr == 43) i += 2;
|
@@ -627,7 +621,7 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
627
621
|
|
628
622
|
// 0, potential start of hex
|
629
623
|
if ((defaultRadix || radix == 16) && startChr == 48) {
|
630
|
-
const second:
|
624
|
+
const second: i32 = Porffor.wasm.i32.load16_u(i + 2, 0, 4);
|
631
625
|
// 0x or 0X
|
632
626
|
if (second == 120 || second == 88) {
|
633
627
|
// set radix to 16 and skip leading 2 chars
|
@@ -637,25 +631,19 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
637
631
|
}
|
638
632
|
|
639
633
|
while (i < endPtr) {
|
640
|
-
const chr:
|
634
|
+
const chr: i32 = Porffor.wasm.i32.load16_u(i, 0, 4);
|
641
635
|
i += 2;
|
642
636
|
|
643
637
|
if (chr >= 48 && chr < nMax) {
|
644
638
|
if (Number.isNaN(n)) n = 0;
|
645
|
-
|
646
|
-
n *= radix;
|
647
|
-
n += chr - 48;
|
639
|
+
n = (n * radix) + chr - 48;
|
648
640
|
} else if (radix > 10) {
|
649
641
|
if (chr >= 97 && chr < (87 + radix)) {
|
650
642
|
if (Number.isNaN(n)) n = 0;
|
651
|
-
|
652
|
-
n *= radix;
|
653
|
-
n += chr - 87;
|
643
|
+
n = (n * radix) + chr - 87;
|
654
644
|
} else if (chr >= 65 && chr < (55 + radix)) {
|
655
645
|
if (Number.isNaN(n)) n = 0;
|
656
|
-
|
657
|
-
n *= radix;
|
658
|
-
n += chr - 55;
|
646
|
+
n = (n * radix) + chr - 55;
|
659
647
|
} else {
|
660
648
|
break;
|
661
649
|
}
|
@@ -670,30 +658,48 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
670
658
|
|
671
659
|
export const __Number_parseInt = (input: any, radix: any): f64 => parseInt(input, radix);
|
672
660
|
|
673
|
-
|
674
|
-
//
|
661
|
+
export const parseFloat = (input: any): f64 => {
|
662
|
+
// todo: handle exponents
|
663
|
+
input = ecma262.ToString(input).trim();
|
675
664
|
|
676
|
-
|
677
|
-
|
665
|
+
let n: f64 = NaN;
|
666
|
+
let dec: i32 = 0;
|
667
|
+
let negative: boolean = false;
|
678
668
|
|
679
|
-
|
680
|
-
|
669
|
+
let i = 0;
|
670
|
+
const start: i32 = input.charCodeAt(0);
|
681
671
|
|
682
|
-
//
|
683
|
-
|
684
|
-
|
685
|
-
|
672
|
+
// +, ignore
|
673
|
+
if (start == 43) {
|
674
|
+
i++;
|
675
|
+
}
|
686
676
|
|
687
|
-
//
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
677
|
+
// -, negative
|
678
|
+
if (start == 45) {
|
679
|
+
i++;
|
680
|
+
negative = true;
|
681
|
+
}
|
682
|
+
|
683
|
+
const len: i32 = input.length;
|
684
|
+
while (i < len) {
|
685
|
+
const chr: i32 = input.charCodeAt(i++);
|
692
686
|
|
693
|
-
|
694
|
-
|
687
|
+
if (chr >= 48 && chr <= 57) { // 0-9
|
688
|
+
if (Number.isNaN(n)) n = 0;
|
689
|
+
if (dec) {
|
690
|
+
dec *= 10;
|
691
|
+
n += (chr - 48) / dec;
|
692
|
+
} else n = (n * 10) + chr - 48;
|
693
|
+
} else if (chr == 46) { // .
|
694
|
+
if (dec) break;
|
695
|
+
dec = 1;
|
696
|
+
} else {
|
697
|
+
break;
|
698
|
+
}
|
699
|
+
}
|
695
700
|
|
696
|
-
|
701
|
+
if (negative) return -n;
|
702
|
+
return n;
|
703
|
+
};
|
697
704
|
|
698
|
-
|
699
|
-
// };
|
705
|
+
export const __Number_parseFloat = (input: any): f64 => parseFloat(input);
|
@@ -0,0 +1,121 @@
|
|
1
|
+
export const __Porffor_stn_int = (str: unknown, radix: i32, i: i32): f64 => {
|
2
|
+
let nMax: i32 = 58;
|
3
|
+
if (radix < 10) nMax = 48 + radix;
|
4
|
+
|
5
|
+
let n: f64 = 0;
|
6
|
+
|
7
|
+
const len: i32 = str.length;
|
8
|
+
if (len - i == 0) return NaN;
|
9
|
+
|
10
|
+
while (i < len) {
|
11
|
+
const chr: i32 = str.charCodeAt(i++);
|
12
|
+
|
13
|
+
if (chr >= 48 && chr < nMax) {
|
14
|
+
n = (n * radix) + chr - 48;
|
15
|
+
} else if (radix > 10) {
|
16
|
+
if (chr >= 97 && chr < (87 + radix)) {
|
17
|
+
n = (n * radix) + chr - 87;
|
18
|
+
} else if (chr >= 65 && chr < (55 + radix)) {
|
19
|
+
n = (n * radix) + chr - 55;
|
20
|
+
} else {
|
21
|
+
return NaN;
|
22
|
+
}
|
23
|
+
} else {
|
24
|
+
return NaN;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return n;
|
29
|
+
};
|
30
|
+
|
31
|
+
export const __Porffor_stn_float = (str: unknown, i: i32): f64 => {
|
32
|
+
let n: f64 = 0;
|
33
|
+
let dec: i32 = 0;
|
34
|
+
|
35
|
+
const len: i32 = str.length;
|
36
|
+
if (len - i == 0) return NaN;
|
37
|
+
|
38
|
+
while (i < len) {
|
39
|
+
const chr: i32 = str.charCodeAt(i++);
|
40
|
+
|
41
|
+
if (chr >= 48 && chr <= 57) { // 0-9
|
42
|
+
if (dec) {
|
43
|
+
dec *= 10;
|
44
|
+
n += (chr - 48) / dec;
|
45
|
+
} else n = (n * 10) + chr - 48;
|
46
|
+
} else if (chr == 46) { // .
|
47
|
+
if (dec) return NaN;
|
48
|
+
dec = 1;
|
49
|
+
} else {
|
50
|
+
return NaN;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
return n;
|
55
|
+
};
|
56
|
+
|
57
|
+
// 7.1.4.1.1 StringToNumber (str)
|
58
|
+
// https://tc39.es/ecma262/#sec-stringtonumber
|
59
|
+
export const __ecma262_StringToNumber = (str: unknown): number => {
|
60
|
+
// trim whitespace
|
61
|
+
str = str.trim();
|
62
|
+
|
63
|
+
// check 0x, 0o, 0b prefixes
|
64
|
+
const first: i32 = str.charCodeAt(0);
|
65
|
+
const second: i32 = str.charCodeAt(1);
|
66
|
+
|
67
|
+
if (first == 48) {
|
68
|
+
// starts with 0, check for prefixes
|
69
|
+
|
70
|
+
if (second == 120 || second == 88) { // 0x (hex)
|
71
|
+
return __Porffor_stn_int(str, 16, 2);
|
72
|
+
}
|
73
|
+
|
74
|
+
if (second == 111 || second == 79) { // 0o (octal)
|
75
|
+
return __Porffor_stn_int(str, 8, 2);
|
76
|
+
}
|
77
|
+
|
78
|
+
if (second == 98 || second == 66) { // 0b (binary)
|
79
|
+
return __Porffor_stn_int(str, 2, 2);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
let i: i32 = 0;
|
84
|
+
let negative: boolean = false;
|
85
|
+
|
86
|
+
// +, skip char
|
87
|
+
if (first == 43) {
|
88
|
+
i = 1;
|
89
|
+
}
|
90
|
+
|
91
|
+
// -, set negative and skip char
|
92
|
+
if (first == 45) {
|
93
|
+
negative = true;
|
94
|
+
i = 1;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (str.charCodeAt(i) == 73) {
|
98
|
+
// next char is 'I', likely 'Infinity' so check each char lol
|
99
|
+
if (
|
100
|
+
str.charCodeAt(i + 1) == 110 && // n
|
101
|
+
str.charCodeAt(i + 2) == 102 && // f
|
102
|
+
str.charCodeAt(i + 3) == 105 && // i
|
103
|
+
str.charCodeAt(i + 4) == 110 && // n
|
104
|
+
str.charCodeAt(i + 5) == 105 && // i
|
105
|
+
str.charCodeAt(i + 6) == 116 && // t
|
106
|
+
str.charCodeAt(i + 7) == 121 // y
|
107
|
+
) {
|
108
|
+
// no way, it matched
|
109
|
+
let n: f64 = Infinity;
|
110
|
+
return negative ? -n : n;
|
111
|
+
}
|
112
|
+
|
113
|
+
return NaN;
|
114
|
+
}
|
115
|
+
|
116
|
+
// todo: handle exponents
|
117
|
+
const n: f64 = __Porffor_stn_float(str, i);
|
118
|
+
|
119
|
+
if (negative) return -n;
|
120
|
+
return n;
|
121
|
+
};
|
@@ -1,13 +1,6 @@
|
|
1
1
|
// general widely used ecma262/spec functions
|
2
2
|
import type {} from './porffor.d.ts';
|
3
3
|
|
4
|
-
// 7.1.4.1.1 StringToNumber (str)
|
5
|
-
// https://tc39.es/ecma262/#sec-stringtonumber
|
6
|
-
export const __ecma262_StringToNumber = (str: unknown): number => {
|
7
|
-
// nah.
|
8
|
-
return NaN;
|
9
|
-
};
|
10
|
-
|
11
4
|
// 7.1.4 ToNumber (argument)
|
12
5
|
// https://tc39.es/ecma262/#sec-tonumber
|
13
6
|
export const __ecma262_ToNumber = (argument: unknown): number => {
|
@@ -1648,7 +1648,7 @@ export const BuiltinFuncs = function() {
|
|
1648
1648
|
locals: [124,127,127], localNames: ["y","y#type","x","x#type","ratio","ratio#type","#last_type"],
|
1649
1649
|
};
|
1650
1650
|
this.Number = {
|
1651
|
-
wasm: (scope, {builtin}) => [[32,-1],[184],[65,2],[33,2],[26],[32,0],[32,1],[16, ...builtin('
|
1651
|
+
wasm: (scope, {builtin}) => [[32,-1],[184],[65,2],[33,2],[26],[32,0],[32,1],[16, ...builtin('__ecma262_ToNumeric')],[34,2],[15]],
|
1652
1652
|
params: [124,127], typedParams: 1,
|
1653
1653
|
returns: [124,127], typedReturns: 1,
|
1654
1654
|
locals: [127], localNames: ["argument","argument#type","#last_type"],
|
@@ -1688,10 +1688,10 @@ export const BuiltinFuncs = function() {
|
|
1688
1688
|
locals: [], localNames: ["_this","_this#type"],
|
1689
1689
|
};
|
1690
1690
|
this.parseInt = {
|
1691
|
-
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__ecma262_ToString')],[33,1],[33,0],[68,0,0,0,0,0,0,0,0],[33,
|
1691
|
+
wasm: (scope, {builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__ecma262_ToString')],[33,4],[33,5],[32,4],[34,6],[33,7],[2,124],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,5],[252,2],[32,6],[16, ...builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,5],[252,2],[32,6],[16, ...builtin('__ByteString_prototype_trim')],[33,4],[183],[12,1],[11],...internalThrow(scope, 'TypeError', `'trim' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,0],[32,4],[33,1],[26],[68,0,0,0,0,0,0,0,0],[33,8],[32,2],[32,3],[16, ...builtin('__ecma262_ToIntegerOrInfinity')],[33,3],[34,2],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,8],[68,0,0,0,0,0,0,36,64],[34,2],[65,1],[33,3],[26],[11],[32,2],[68,0,0,0,0,0,0,0,64],[99],[34,9],[69],[4,127],[32,2],[68,0,0,0,0,0,0,66,64],[100],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[68,0,0,0,0,0,0,77,64],[33,10],[32,2],[68,0,0,0,0,0,0,36,64],[99],[4,64],[68,0,0,0,0,0,0,72,64],[32,2],[160],[33,10],[11],[68,0,0,0,0,0,0,248,127],[33,11],[32,0],[34,12],[252,2],[40,0,0],[183],[33,13],[32,12],[33,14],[68,0,0,0,0,0,0,0,0],[33,15],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,96,104,64],[97],[4,64],[32,14],[32,13],[160],[33,16],[32,14],[252,2],[45,0,4],[183],[34,17],[68,0,0,0,0,0,128,69,64],[97],[4,64],[32,14],[68,0,0,0,0,0,0,240,63],[160],[33,14],[11],[32,17],[68,0,0,0,0,0,128,70,64],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,15],[32,14],[68,0,0,0,0,0,0,240,63],[160],[33,14],[11],[32,8],[34,18],[68,0,0,0,0,0,0,0,0],[97],[4,124],[32,2],[68,0,0,0,0,0,0,48,64],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,19],[252,3],[11,"TYPESWITCH_end"],[4,124],[32,17],[68,0,0,0,0,0,0,72,64],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,19],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,14],[68,0,0,0,0,0,0,240,63],[160],[252,2],[45,0,4],[183],[34,20],[68,0,0,0,0,0,0,94,64],[97],[34,9],[69],[4,127],[32,20],[68,0,0,0,0,0,0,86,64],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,0,0,0,0,0,0,0,64],[160],[33,14],[68,0,0,0,0,0,0,48,64],[34,2],[65,1],[33,3],[26],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[32,14],[68,0,0,0,0,0,0,240,63],[160],[33,14],[252,2],[45,0,4],[183],[34,21],[68,0,0,0,0,0,0,72,64],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,0,72,64],[161],[33,11],[5],[32,2],[68,0,0,0,0,0,0,36,64],[100],[4,64],[32,21],[68,0,0,0,0,0,64,88,64],[102],[34,9],[4,127],[32,21],[68,0,0,0,0,0,192,85,64],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,192,85,64],[161],[33,11],[5],[32,21],[68,0,0,0,0,0,64,80,64],[102],[34,9],[4,127],[32,21],[68,0,0,0,0,0,128,75,64],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,128,75,64],[161],[33,11],[5],[12,4],[11],[11],[5],[12,2],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[11],[32,11],[65,1],[15],[11],[32,14],[32,13],[68,0,0,0,0,0,0,0,64],[162],[160],[33,16],[32,14],[252,2],[47,0,4],[183],[34,17],[68,0,0,0,0,0,128,69,64],[97],[4,64],[32,14],[68,0,0,0,0,0,0,0,64],[160],[33,14],[11],[32,17],[68,0,0,0,0,0,128,70,64],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,15],[32,14],[68,0,0,0,0,0,0,0,64],[160],[33,14],[11],[32,8],[34,18],[68,0,0,0,0,0,0,0,0],[97],[4,124],[32,2],[68,0,0,0,0,0,0,48,64],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,19],[252,3],[11,"TYPESWITCH_end"],[4,124],[32,17],[68,0,0,0,0,0,0,72,64],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,19],[252,3],[40,1,0],[12,1],[11],[32,19],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,14],[68,0,0,0,0,0,0,0,64],[160],[252,2],[47,0,4],[183],[34,20],[68,0,0,0,0,0,0,94,64],[97],[34,9],[69],[4,127],[32,20],[68,0,0,0,0,0,0,86,64],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,0,0,0,0,0,0,16,64],[160],[33,14],[68,0,0,0,0,0,0,48,64],[34,2],[65,1],[33,3],[26],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[252,2],[47,0,4],[183],[33,21],[32,14],[68,0,0,0,0,0,0,0,64],[160],[33,14],[32,21],[68,0,0,0,0,0,0,72,64],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,0,72,64],[161],[33,11],[5],[32,2],[68,0,0,0,0,0,0,36,64],[100],[4,64],[32,21],[68,0,0,0,0,0,64,88,64],[102],[34,9],[4,127],[32,21],[68,0,0,0,0,0,192,85,64],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,192,85,64],[161],[33,11],[5],[32,21],[68,0,0,0,0,0,64,80,64],[102],[34,9],[4,127],[32,21],[68,0,0,0,0,0,128,75,64],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,0,0,0,0,0,128,75,64],[161],[33,11],[5],[12,4],[11],[11],[5],[12,2],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[11],[32,11],[65,1],[15]],
|
1692
1692
|
params: [124,127,124,127], typedParams: 1,
|
1693
1693
|
returns: [124,127], typedReturns: 1,
|
1694
|
-
locals: [127,124,127,124,124,124,124,124,124,124,124,124,124,
|
1694
|
+
locals: [127,124,127,127,124,127,124,124,124,124,124,124,124,124,124,124,124,124], localNames: ["input","input#type","radix","radix#type","#last_type","#proto_target","#proto_target#type","#typeswitch_tmp","defaultRadix","logictmpi","nMax","n","inputPtr","len","i","negative","endPtr","startChr","logictmp","#logicinner_tmp","second","chr"],
|
1695
1695
|
};
|
1696
1696
|
this.__Number_parseInt = {
|
1697
1697
|
wasm: (scope, {builtin}) => [[32,0],[32,1],[32,2],[32,3],[16, ...builtin('parseInt')],[34,4],[15]],
|
@@ -1699,6 +1699,18 @@ export const BuiltinFuncs = function() {
|
|
1699
1699
|
returns: [124,127], typedReturns: 1,
|
1700
1700
|
locals: [127], localNames: ["input","input#type","radix","radix#type","#last_type"],
|
1701
1701
|
};
|
1702
|
+
this.parseFloat = {
|
1703
|
+
wasm: (scope, {builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__ecma262_ToString')],[33,2],[33,3],[32,2],[34,4],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,3],[252,2],[32,4],[16, ...builtin('__String_prototype_trim')],[33,2],[183],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,3],[252,2],[32,4],[16, ...builtin('__ByteString_prototype_trim')],[33,2],[183],[12,1],[11],...internalThrow(scope, 'TypeError', `'trim' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,0],[32,2],[33,1],[26],[68,0,0,0,0,0,0,248,127],[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],[65,1],[33,10],[32,0],[252,3],[34,13],[40,1,0],[33,12],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[65,0],[34,14],[32,12],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,14],[65,2],[108],[32,13],[106],[47,0,4],[184],[65,1],[33,2],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[65,0],[34,14],[32,12],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,14],[32,13],[106],[45,0,4],[184],[65,1],[33,2],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,11],[68,0,0,0,0,0,128,69,64],[97],[4,64],[32,9],[68,0,0,0,0,0,0,240,63],[160],[33,9],[11],[32,11],[68,0,0,0,0,0,128,70,64],[97],[4,64],[32,9],[68,0,0,0,0,0,0,240,63],[160],[33,9],[68,0,0,0,0,0,0,240,63],[33,8],[11],[32,0],[252,3],[40,1,0],[184],[33,15],[3,64],[32,9],[32,15],[99],[4,64],[32,0],[252,3],[34,13],[40,1,0],[33,12],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,9],[32,9],[68,0,0,0,0,0,0,240,63],[160],[33,9],[252,2],[34,14],[32,12],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,14],[65,2],[108],[32,13],[106],[47,0,4],[184],[65,1],[33,2],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,9],[32,9],[68,0,0,0,0,0,0,240,63],[160],[33,9],[252,2],[34,14],[32,12],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,14],[32,13],[106],[45,0,4],[184],[65,1],[33,2],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,16],[68,0,0,0,0,0,0,72,64],[102],[34,17],[4,127],[32,16],[68,0,0,0,0,0,128,76,64],[101],[65,2],[33,2],[5],[32,17],[65,2],[33,2],[11],[4,64],[32,6],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[33,6],[11],[32,7],[252,3],[4,64],[32,7],[68,0,0,0,0,0,0,36,64],[162],[33,7],[32,6],[32,16],[68,0,0,0,0,0,0,72,64],[161],[32,7],[163],[160],[33,6],[5],[32,6],[68,0,0,0,0,0,0,36,64],[162],[32,16],[160],[68,0,0,0,0,0,0,72,64],[161],[33,6],[11],[5],[32,16],[68,0,0,0,0,0,0,71,64],[97],[4,64],[32,7],[252,3],[4,64],[12,3],[11],[68,0,0,0,0,0,0,240,63],[33,7],[5],[12,2],[11],[11],[12,1],[11],[11],[32,8],[252,3],[4,64],[32,6],[154],[65,1],[15],[11],[32,6],[65,1],[15]],
|
1704
|
+
params: [124,127], typedParams: 1,
|
1705
|
+
returns: [124,127], typedReturns: 1,
|
1706
|
+
locals: [127,124,127,127,124,124,124,124,127,124,127,127,127,124,124,127], localNames: ["input","input#type","#last_type","#proto_target","#proto_target#type","#typeswitch_tmp","n","dec","negative","i","i#type","start","__proto_length_cache","__proto_pointer_cache","__charCodeAt_tmp","len","chr","logictmpi"],
|
1707
|
+
};
|
1708
|
+
this.__Number_parseFloat = {
|
1709
|
+
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('parseFloat')],[34,2],[15]],
|
1710
|
+
params: [124,127], typedParams: 1,
|
1711
|
+
returns: [124,127], typedReturns: 1,
|
1712
|
+
locals: [127], localNames: ["input","input#type","#last_type"],
|
1713
|
+
};
|
1702
1714
|
this.Object = {
|
1703
1715
|
wasm: (scope, {builtin}) => [[32,-1],[184],[26],[32,0],[33,3],[32,1],[33,4],[2,127],[32,4],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,3],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,4],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],[16, ...builtin('__Porffor_allocate')],[183],[34,5],[65,7],[15],[11],[32,0],[32,1],[15]],
|
1704
1716
|
params: [124,127], typedParams: 1,
|
@@ -2376,6 +2388,24 @@ export const BuiltinFuncs = function() {
|
|
2376
2388
|
locals: [124,124,124,124,124,124,124,124,127,127,127,127,124], localNames: ["codes","codes#type","out","len","__length_setter_tmp","bytestringable","i","v","#member_obj","#member_prop","#loadArray_offset","#last_type","#member_allocd","#swap","out2"],
|
2377
2389
|
hasRestArgument: 1,
|
2378
2390
|
};
|
2391
|
+
this.__Porffor_stn_int = {
|
2392
|
+
wasm: (scope, {internalThrow}) => [[68,0,0,0,0,0,0,77,64],[33,6],[32,2],[68,0,0,0,0,0,0,36,64],[99],[4,64],[68,0,0,0,0,0,0,72,64],[32,2],[160],[33,6],[11],[68,0,0,0,0,0,0,0,0],[33,7],[32,0],[252,3],[40,1,0],[184],[34,8],[32,4],[161],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[3,64],[32,4],[32,8],[99],[4,64],[32,0],[252,3],[34,11],[40,1,0],[33,10],[32,1],[33,14],[2,124],[32,14],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,4],[32,4],[68,0,0,0,0,0,0,240,63],[160],[33,4],[252,2],[34,12],[32,10],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,12],[65,2],[108],[32,11],[106],[47,0,4],[184],[65,1],[33,13],[11],[12,1],[11],[32,14],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,4],[32,4],[68,0,0,0,0,0,0,240,63],[160],[33,4],[252,2],[34,12],[32,10],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,12],[32,11],[106],[45,0,4],[184],[65,1],[33,13],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,9],[68,0,0,0,0,0,0,72,64],[102],[34,15],[4,127],[32,9],[32,6],[99],[65,2],[33,13],[5],[32,15],[65,2],[33,13],[11],[4,64],[32,7],[32,2],[162],[32,9],[160],[68,0,0,0,0,0,0,72,64],[161],[33,7],[5],[32,2],[68,0,0,0,0,0,0,36,64],[100],[4,64],[32,9],[68,0,0,0,0,0,64,88,64],[102],[34,15],[4,127],[32,9],[68,0,0,0,0,0,192,85,64],[32,2],[160],[99],[65,2],[33,13],[5],[32,15],[65,2],[33,13],[11],[4,64],[32,7],[32,2],[162],[32,9],[160],[68,0,0,0,0,0,192,85,64],[161],[33,7],[5],[32,9],[68,0,0,0,0,0,64,80,64],[102],[34,15],[4,127],[32,9],[68,0,0,0,0,0,128,75,64],[32,2],[160],[99],[65,2],[33,13],[5],[32,15],[65,2],[33,13],[11],[4,64],[32,7],[32,2],[162],[32,9],[160],[68,0,0,0,0,0,128,75,64],[161],[33,7],[5],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[11],[5],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[11],[12,1],[11],[11],[32,7],[65,1],[15]],
|
2393
|
+
params: [124,127,124,127,124,127], typedParams: 1,
|
2394
|
+
returns: [124,127], typedReturns: 1,
|
2395
|
+
locals: [124,124,124,124,127,127,127,127,127,127], localNames: ["str","str#type","radix","radix#type","i","i#type","nMax","n","len","chr","__proto_length_cache","__proto_pointer_cache","__charCodeAt_tmp","#last_type","#typeswitch_tmp","logictmpi"],
|
2396
|
+
};
|
2397
|
+
this.__Porffor_stn_float = {
|
2398
|
+
wasm: (scope, {internalThrow}) => [[68,0,0,0,0,0,0,0,0],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[32,0],[252,3],[40,1,0],[184],[34,6],[32,2],[161],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[3,64],[32,2],[32,6],[99],[4,64],[32,0],[252,3],[34,9],[40,1,0],[33,8],[32,1],[33,12],[2,124],[32,12],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,2],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[252,2],[34,10],[32,8],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,10],[65,2],[108],[32,9],[106],[47,0,4],[184],[65,1],[33,11],[11],[12,1],[11],[32,12],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,2],[32,2],[68,0,0,0,0,0,0,240,63],[160],[33,2],[252,2],[34,10],[32,8],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,10],[32,9],[106],[45,0,4],[184],[65,1],[33,11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,7],[68,0,0,0,0,0,0,72,64],[102],[34,13],[4,127],[32,7],[68,0,0,0,0,0,128,76,64],[101],[65,2],[33,11],[5],[32,13],[65,2],[33,11],[11],[4,64],[32,5],[252,3],[4,64],[32,5],[68,0,0,0,0,0,0,36,64],[162],[33,5],[32,4],[32,7],[68,0,0,0,0,0,0,72,64],[161],[32,5],[163],[160],[33,4],[5],[32,4],[68,0,0,0,0,0,0,36,64],[162],[32,7],[160],[68,0,0,0,0,0,0,72,64],[161],[33,4],[11],[5],[32,7],[68,0,0,0,0,0,0,71,64],[97],[4,64],[32,5],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[68,0,0,0,0,0,0,240,63],[33,5],[5],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[11],[12,1],[11],[11],[32,4],[65,1],[15]],
|
2399
|
+
params: [124,127,124,127], typedParams: 1,
|
2400
|
+
returns: [124,127], typedReturns: 1,
|
2401
|
+
locals: [124,124,124,124,127,127,127,127,127,127], localNames: ["str","str#type","i","i#type","n","dec","len","chr","__proto_length_cache","__proto_pointer_cache","__charCodeAt_tmp","#last_type","#typeswitch_tmp","logictmpi"],
|
2402
|
+
};
|
2403
|
+
this.__ecma262_StringToNumber = {
|
2404
|
+
wasm: (scope, {builtin,internalThrow}) => [[32,0],[33,2],[32,1],[34,3],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,2],[252,2],[32,3],[16, ...builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,2],[252,2],[32,3],[16, ...builtin('__ByteString_prototype_trim')],[33,4],[183],[12,1],[11],...internalThrow(scope, 'TypeError', `'trim' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[34,0],[32,4],[33,1],[26],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[65,0],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[65,0],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[33,6],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[65,1],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[65,1],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[33,10],[32,6],[68,0,0,0,0,0,0,72,64],[97],[4,64],[32,10],[68,0,0,0,0,0,0,94,64],[97],[34,11],[69],[4,127],[32,10],[68,0,0,0,0,0,0,86,64],[97],[65,2],[33,4],[5],[32,11],[65,2],[33,4],[11],[4,64],[32,0],[32,1],[68,0,0,0,0,0,0,48,64],[65,1],[68,0,0,0,0,0,0,0,64],[65,1],[16, ...builtin('__Porffor_stn_int')],[34,4],[15],[11],[32,10],[68,0,0,0,0,0,192,91,64],[97],[34,11],[69],[4,127],[32,10],[68,0,0,0,0,0,192,83,64],[97],[65,2],[33,4],[5],[32,11],[65,2],[33,4],[11],[4,64],[32,0],[32,1],[68,0,0,0,0,0,0,32,64],[65,1],[68,0,0,0,0,0,0,0,64],[65,1],[16, ...builtin('__Porffor_stn_int')],[34,4],[15],[11],[32,10],[68,0,0,0,0,0,128,88,64],[97],[34,11],[69],[4,127],[32,10],[68,0,0,0,0,0,128,80,64],[97],[65,2],[33,4],[5],[32,11],[65,2],[33,4],[11],[4,64],[32,0],[32,1],[68,0,0,0,0,0,0,0,64],[65,1],[68,0,0,0,0,0,0,0,64],[65,1],[16, ...builtin('__Porffor_stn_int')],[34,4],[15],[11],[11],[68,0,0,0,0,0,0,0,0],[33,12],[68,0,0,0,0,0,0,0,0],[33,13],[32,6],[68,0,0,0,0,0,128,69,64],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,12],[11],[32,6],[68,0,0,0,0,0,128,70,64],[97],[4,64],[68,0,0,0,0,0,0,240,63],[33,13],[68,0,0,0,0,0,0,240,63],[33,12],[11],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,64,82,64],[97],[4,64],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,240,63],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,240,63],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,128,91,64],[97],[34,11],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,0,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,0,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,128,89,64],[97],[65,2],[33,4],[5],[32,11],[65,2],[33,4],[11],[34,11],[33,14],[32,4],[33,5],[2,127],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,14],[40,1,0],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,14],[40,1,0],[12,1],[11],[32,14],[11,"TYPESWITCH_end"],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,8,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,8,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,64,90,64],[97],[65,2],[33,4],[5],[32,11],[32,4],[33,4],[11],[34,11],[33,14],[32,4],[33,5],[2,127],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,14],[40,1,0],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,14],[40,1,0],[12,1],[11],[32,14],[11,"TYPESWITCH_end"],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,16,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,16,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,128,91,64],[97],[65,2],[33,4],[5],[32,11],[32,4],[33,4],[11],[34,11],[33,14],[32,4],[33,5],[2,127],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,14],[40,1,0],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,14],[40,1,0],[12,1],[11],[32,14],[11,"TYPESWITCH_end"],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,20,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,20,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,64,90,64],[97],[65,2],[33,4],[5],[32,11],[32,4],[33,4],[11],[34,11],[33,14],[32,4],[33,5],[2,127],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,14],[40,1,0],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,14],[40,1,0],[12,1],[11],[32,14],[11,"TYPESWITCH_end"],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,24,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,24,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,0,93,64],[97],[65,2],[33,4],[5],[32,11],[32,4],[33,4],[11],[34,11],[33,14],[32,4],[33,5],[2,127],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,14],[40,1,0],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,14],[40,1,0],[12,1],[11],[32,14],[11,"TYPESWITCH_end"],[4,127],[32,0],[252,3],[34,8],[40,1,0],[33,7],[32,1],[33,5],[2,124],[32,5],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[2,124],[32,12],[68,0,0,0,0,0,0,28,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[65,2],[108],[32,8],[106],[47,0,4],[184],[65,1],[33,4],[11],[12,1],[11],[32,5],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[2,124],[32,12],[68,0,0,0,0,0,0,28,64],[160],[252,2],[34,9],[32,7],[78],[4,64],[68,0,0,0,0,0,0,248,127],[12,1],[11],[32,9],[32,8],[106],[45,0,4],[184],[65,1],[33,4],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `'charCodeAt' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[68,0,0,0,0,0,64,94,64],[97],[65,2],[33,4],[5],[32,11],[32,4],[33,4],[11],[4,64],[68,0,0,0,0,0,0,240,127],[33,15],[32,13],[252,3],[4,124],[32,15],[154],[65,1],[33,4],[5],[32,15],[65,1],[33,4],[11],[32,4],[15],[11],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[32,0],[32,1],[32,12],[65,1],[16, ...builtin('__Porffor_stn_float')],[26],[33,15],[32,13],[252,3],[4,64],[32,15],[154],[65,1],[15],[11],[32,15],[65,1],[15]],
|
2405
|
+
params: [124,127], typedParams: 1,
|
2406
|
+
returns: [124,127], typedReturns: 1,
|
2407
|
+
locals: [124,127,127,127,124,127,127,127,124,127,124,124,127,124], localNames: ["str","str#type","#proto_target","#proto_target#type","#last_type","#typeswitch_tmp","first","__proto_length_cache","__proto_pointer_cache","__charCodeAt_tmp","second","logictmpi","i","negative","#logicinner_tmp_int","n"],
|
2408
|
+
};
|
2379
2409
|
this.Symbol = {
|
2380
2410
|
wasm: (scope, {glbl,builtin}) => [[68,0,0,0,0,0,0,0,0],[33,2],[65,128,1],[33,3],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,96,64],[98],[4,64],[32,0],[32,1],[16, ...builtin('__ecma262_ToString')],[33,3],[33,2],[11],...glbl(35, 'descStore', 124),[65,208,0],[32,2],[32,3],[16, ...builtin('__Porffor_fastPush')],[26],[34,5],[65,5],[15]],
|
2381
2411
|
params: [124,127], typedParams: 1,
|
@@ -4437,18 +4467,18 @@ export const BuiltinFuncs = function() {
|
|
4437
4467
|
returns: [124,127], typedReturns: 1,
|
4438
4468
|
locals: [127], localNames: ["_this","_this#type","#last_type"],
|
4439
4469
|
};
|
4440
|
-
this.__ecma262_StringToNumber = {
|
4441
|
-
wasm: (scope, {}) => [[68,0,0,0,0,0,0,248,127],[65,1],[15]],
|
4442
|
-
params: [124,127], typedParams: 1,
|
4443
|
-
returns: [124,127], typedReturns: 1,
|
4444
|
-
locals: [], localNames: ["str","str#type"],
|
4445
|
-
};
|
4446
4470
|
this.__ecma262_ToNumber = {
|
4447
4471
|
wasm: (scope, {builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[34,2],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,0],[32,1],[15],[11],[32,2],[68,0,0,0,0,0,0,20,64],[97],[32,2],[68,0,0,0,0,0,0,16,64],[97],[114],[4,64],...internalThrow(scope, 'TypeError', `Cannot convert Symbol or BigInt to a number`),[11],[32,2],[68,0,0,0,0,0,0,96,64],[97],[32,2],[68,0,0,0,0,0,0,0,0],[97],[114],[4,64],[68,0,0,0,0,0,0,248,127],[65,1],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[97],[32,1],[65,128,1],[114],[65,7],[65,128,1],[114],[70],[113],[32,0],[68,0,0,0,0,0,0,0,0],[97],[32,1],[65,128,1],[114],[65,2],[65,128,1],[114],[70],[113],[114],[4,64],[68,0,0,0,0,0,0,0,0],[65,1],[15],[11],[32,0],[68,0,0,0,0,0,0,240,63],[97],[32,1],[65,128,1],[114],[65,2],[65,128,1],[114],[70],[113],[4,64],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[32,2],[68,0,0,0,0,0,192,80,64],[97],[32,2],[68,0,0,0,0,0,96,104,64],[97],[114],[4,64],[32,0],[32,1],[16, ...builtin('__ecma262_StringToNumber')],[34,3],[15],[11],[68,0,0,0,0,0,0,248,127],[65,1],[15]],
|
4448
4472
|
params: [124,127], typedParams: 1,
|
4449
4473
|
returns: [124,127], typedReturns: 1,
|
4450
4474
|
locals: [124,127], localNames: ["argument","argument#type","t","#last_type"],
|
4451
4475
|
};
|
4476
|
+
this.__ecma262_ToNumeric = {
|
4477
|
+
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__ecma262_ToNumber')],[34,2],[15]],
|
4478
|
+
params: [124,127], typedParams: 1,
|
4479
|
+
returns: [124,127], typedReturns: 1,
|
4480
|
+
locals: [127], localNames: ["value","value#type","#last_type"],
|
4481
|
+
};
|
4452
4482
|
this.__ecma262_ToIntegerOrInfinity = {
|
4453
4483
|
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__ecma262_ToNumber')],[26],[34,2],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[65,1],[15],[11],[32,2],[16, ...builtin('__Number_isFinite')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,2],[65,1],[15],[11],[32,2],[16, ...builtin('__Math_trunc')],[34,2],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,0,0],[65,1],[15],[11],[32,2],[65,1],[15]],
|
4454
4484
|
params: [124,127], typedParams: 1,
|
package/compiler/index.js
CHANGED
@@ -108,10 +108,10 @@ export default (code, flags) => {
|
|
108
108
|
|
109
109
|
if (Prefs.profileCompiler) console.log(`3. optimized in ${(performance.now() - t2).toFixed(2)}ms`);
|
110
110
|
|
111
|
-
const
|
111
|
+
const t3 = performance.now();
|
112
|
+
const out = { funcs, globals, tags, exceptions, pages, data, times: [ t0, t1, t2, t3 ] };
|
112
113
|
if (globalThis.precompile) return out;
|
113
114
|
|
114
|
-
const t3 = performance.now();
|
115
115
|
const wasm = out.wasm = assemble(funcs, globals, tags, pages, data, flags);
|
116
116
|
if (Prefs.profileCompiler) console.log(`4. assembled in ${(performance.now() - t3).toFixed(2)}ms`);
|
117
117
|
|
package/compiler/precompile.js
CHANGED
@@ -15,6 +15,7 @@ globalThis.precompile = true;
|
|
15
15
|
|
16
16
|
const argv = process.argv.slice();
|
17
17
|
|
18
|
+
const timing = {};
|
18
19
|
const compile = async (file, _funcs) => {
|
19
20
|
let source = fs.readFileSync(file, 'utf8');
|
20
21
|
let first = source.slice(0, source.indexOf('\n'));
|
@@ -32,7 +33,14 @@ const compile = async (file, _funcs) => {
|
|
32
33
|
|
33
34
|
const porfCompile = (await import(`./index.js?_=${Date.now()}`)).default;
|
34
35
|
|
35
|
-
let { funcs, globals, data, exceptions } = porfCompile(source, ['module', 'typed']);
|
36
|
+
let { funcs, globals, data, exceptions, times } = porfCompile(source, ['module', 'typed']);
|
37
|
+
|
38
|
+
timing.parse ??= 0;
|
39
|
+
timing.parse += times[1] - times[0];
|
40
|
+
timing.codegen ??= 0;
|
41
|
+
timing.codegen += times[2] - times[1];
|
42
|
+
timing.opt ??= 0;
|
43
|
+
timing.opt += times[3] - times[2];
|
36
44
|
|
37
45
|
const allocated = new Set();
|
38
46
|
|
@@ -179,10 +187,11 @@ const precompile = async () => {
|
|
179
187
|
throw e;
|
180
188
|
}
|
181
189
|
|
182
|
-
process.stdout.write(`\r${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(
|
190
|
+
process.stdout.write(`\r${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92m${file}\u001b[0m`);
|
183
191
|
}
|
184
192
|
|
185
|
-
|
193
|
+
const total = performance.now() - t;
|
194
|
+
console.log(`\r${' '.repeat(100)}\r\u001b[90m${`[${total.toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92mcompiled ${fileCount} files (${funcs.length} funcs)\u001b[0m \u001b[90m(${['parse', 'codegen', 'opt'].map(x => `${x}: ${((timing[x] / total) * 100).toFixed(2)}%`).join(', ')})\u001b[0m`);
|
186
195
|
|
187
196
|
return `// autogenerated by compiler/precompile.js
|
188
197
|
import { number } from './embedding.js';
|
package/compiler/wrap.js
CHANGED
@@ -26,7 +26,7 @@ export const readByteStr = (memory, ptr) => {
|
|
26
26
|
export const writeByteStr = (memory, ptr, str) => {
|
27
27
|
const length = str.length;
|
28
28
|
|
29
|
-
if (dv
|
29
|
+
if (dv?.memory !== memory) dv = new DataView(memory.buffer);
|
30
30
|
dv.setUint32(ptr, length, true);
|
31
31
|
|
32
32
|
const arr = read(Uint8Array, memory, ptr + 4, length);
|
package/package.json
CHANGED