porffor 0.57.0 → 0.57.1
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/array.ts +1 -1
- package/compiler/builtins/base64.ts +2 -2
- package/compiler/builtins/console.ts +20 -20
- package/compiler/builtins/date.ts +1 -1
- package/compiler/builtins/number.ts +1 -1
- package/compiler/builtins/object.ts +4 -4
- package/compiler/builtins/promise.ts +3 -3
- package/compiler/builtins_precompiled.js +252 -981
- package/compiler/codegen.js +39 -12
- package/compiler/precompile.js +2 -4
- package/package.json +1 -1
- package/runner/index.js +8 -6
- package/optional-chaining-tests.js +0 -335
- package/r.cjs +0 -71
@@ -65,7 +65,7 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
|
|
65
65
|
}
|
66
66
|
|
67
67
|
if (Porffor.type(arg) == Porffor.TYPES.object) {
|
68
|
-
let len = ecma262.ToIntegerOrInfinity((arg as object)['length']);
|
68
|
+
let len: i32 = ecma262.ToIntegerOrInfinity((arg as object)['length']);
|
69
69
|
if (len > 4294967295) throw new RangeError('Invalid array length');
|
70
70
|
if (len < 0) len = 0;
|
71
71
|
|
@@ -15,7 +15,7 @@ export const btoa = (input: bytestring): bytestring => {
|
|
15
15
|
|
16
16
|
// todo/perf: add some per 6 char variant using bitwise magic?
|
17
17
|
|
18
|
-
const endPtr = i + len;
|
18
|
+
const endPtr: i32 = i + len;
|
19
19
|
while (i < endPtr) {
|
20
20
|
const chr1: i32 = Porffor.wasm.i32.load8_u(i++, 0, 4);
|
21
21
|
const chr2: i32 = i < endPtr ? Porffor.wasm.i32.load8_u(i++, 0, 4) : -1;
|
@@ -54,7 +54,7 @@ export const atob = (input: bytestring): bytestring => {
|
|
54
54
|
let i: i32 = Porffor.wasm`local.get ${input}`,
|
55
55
|
j: i32 = Porffor.wasm`local.get ${output}`;
|
56
56
|
|
57
|
-
const endPtr = i + input.length;
|
57
|
+
const endPtr: i32 = i + input.length;
|
58
58
|
while (i < endPtr) {
|
59
59
|
const enc1: i32 = Porffor.wasm.i32.load8_u(lutPtr + Porffor.wasm.i32.load8_u(i++, 0, 4), 0, 4);
|
60
60
|
const enc2: i32 = i < endPtr ? Porffor.wasm.i32.load8_u(lutPtr + Porffor.wasm.i32.load8_u(i++, 0, 4), 0, 4) : -1;
|
@@ -86,27 +86,27 @@ export const __Porffor_miniLog = (arg: any) => {
|
|
86
86
|
Porffor.printStatic('\n');
|
87
87
|
};
|
88
88
|
|
89
|
-
export const
|
90
|
-
const
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
export const __Porffor_print = (arg: any, colors: boolean = true, depth: number = 0) => {
|
90
|
+
const __Porffor_printArray = (arg: any[]|Uint8Array|Int8Array|Uint8ClampedArray|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array, colors: boolean, length: boolean = false) => {
|
91
|
+
const arrLen: i32 = arg.length;
|
92
|
+
if (length) {
|
93
|
+
Porffor.printStatic('(');
|
94
|
+
print(arrLen);
|
95
|
+
Porffor.printStatic(') ');
|
96
|
+
}
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
if (arrLen == 0) {
|
99
|
+
Porffor.printStatic('[]');
|
100
|
+
} else {
|
101
|
+
Porffor.printStatic('[ ');
|
102
|
+
for (let i: i32 = 0; i < arrLen; i++) {
|
103
|
+
__Porffor_print(arg[i], colors);
|
104
|
+
if (i != arrLen - 1) Porffor.printStatic(', ');
|
105
|
+
}
|
106
|
+
Porffor.printStatic(' ]');
|
104
107
|
}
|
105
|
-
|
106
|
-
}
|
107
|
-
};
|
108
|
+
};
|
108
109
|
|
109
|
-
export const __Porffor_print = (arg: any, colors: boolean = true, depth: number = 0) => {
|
110
110
|
// todo: Symbol.toStringTag could reduce duplication here
|
111
111
|
switch (Porffor.type(arg)) {
|
112
112
|
case Porffor.TYPES.number:
|
@@ -335,7 +335,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
|
|
335
335
|
}
|
336
336
|
};
|
337
337
|
|
338
|
-
let tabLevel = 0;
|
338
|
+
let tabLevel: i32 = 0;
|
339
339
|
export const __Porffor_consoleIndent = () => {
|
340
340
|
for (let i: i32 = 0; i < tabLevel; i++) {
|
341
341
|
Porffor.printStatic('\t');
|
@@ -459,7 +459,7 @@ export const __Porffor_dirObject = (obj: any, colors: boolean, depth: i32, showH
|
|
459
459
|
|
460
460
|
const keys = __Object_keys(obj);
|
461
461
|
const keysLen = keys.length - 1;
|
462
|
-
for (let i = 0; i <= keysLen; i++) {
|
462
|
+
for (let i: i32 = 0; i <= keysLen; i++) {
|
463
463
|
const key = keys[i];
|
464
464
|
__Porffor_consolePrint(key);
|
465
465
|
Porffor.printStatic(': ');
|
@@ -147,7 +147,7 @@ export const __ecma262_DateFromTime = (t: number): number => {
|
|
147
147
|
const dayWithinYear: number = __ecma262_DayWithinYear(t);
|
148
148
|
|
149
149
|
// 3. Let month be MonthFromTime(t).
|
150
|
-
const month = __ecma262_MonthFromTime(t);
|
150
|
+
const month: number = __ecma262_MonthFromTime(t);
|
151
151
|
|
152
152
|
// 4. If month is +0𝔽, return dayWithinYear + 1𝔽.
|
153
153
|
if (month == 0) return dayWithinYear + 1;
|
@@ -168,7 +168,7 @@ export const __Porffor_object_in = (obj: any, prop: any): boolean => {
|
|
168
168
|
return true;
|
169
169
|
}
|
170
170
|
|
171
|
-
let lastProto = obj;
|
171
|
+
let lastProto: any = obj;
|
172
172
|
while (true) {
|
173
173
|
obj = Porffor.object.getPrototypeWithHidden(obj, Porffor.type(obj));
|
174
174
|
if (Porffor.fastOr(obj == null, Porffor.wasm`local.get ${obj}` == Porffor.wasm`local.get ${lastProto}`)) break;
|
@@ -189,7 +189,7 @@ export const __Porffor_object_instanceof = (obj: any, constr: any, checkProto: a
|
|
189
189
|
return false;
|
190
190
|
}
|
191
191
|
|
192
|
-
let lastProto = obj;
|
192
|
+
let lastProto: any = obj;
|
193
193
|
while (true) {
|
194
194
|
obj = Porffor.object.getPrototypeWithHidden(obj, Porffor.type(obj));
|
195
195
|
if (Porffor.fastOr(obj == null, Porffor.wasm`local.get ${obj}` == Porffor.wasm`local.get ${lastProto}`)) break;
|
@@ -347,7 +347,7 @@ export const __Object_getOwnPropertyDescriptor = (obj: any, prop: any): object|u
|
|
347
347
|
if (entryPtr == -1) {
|
348
348
|
if (Porffor.type(obj) == Porffor.TYPES.function) {
|
349
349
|
// hack: function .name and .length
|
350
|
-
const v = obj[p];
|
350
|
+
const v: any = obj[p];
|
351
351
|
if (v != null) {
|
352
352
|
const out: object = {};
|
353
353
|
out.writable = false;
|
@@ -619,7 +619,7 @@ export const __Object_create = (proto: any, props: any): object => {
|
|
619
619
|
export const __Object_groupBy = (items: any, callbackFn: any): object => {
|
620
620
|
const out: object = {};
|
621
621
|
|
622
|
-
let i = 0;
|
622
|
+
let i: i32 = 0;
|
623
623
|
for (const x of items) {
|
624
624
|
const k: any = callbackFn(x, i++);
|
625
625
|
if (!__Object_hasOwn(out, k)) {
|
@@ -383,18 +383,18 @@ export const __Promise_allSettled = (promises: any): Promise => {
|
|
383
383
|
_allLen++;
|
384
384
|
if (__ecma262_IsPromise(x)) {
|
385
385
|
x.then(r => {
|
386
|
-
const o = {};
|
386
|
+
const o: object = {};
|
387
387
|
o.status = 'fulfilled';
|
388
388
|
o.value = r;
|
389
389
|
if (Porffor.array.fastPush(_allOut, o) == _allLen) _allRes(_allOut);
|
390
390
|
}, r => {
|
391
|
-
const o = {};
|
391
|
+
const o: object = {};
|
392
392
|
o.status = 'rejected';
|
393
393
|
o.reason = r;
|
394
394
|
if (Porffor.array.fastPush(_allOut, o) == _allLen) _allRes(_allOut);
|
395
395
|
});
|
396
396
|
} else {
|
397
|
-
const o = {};
|
397
|
+
const o: object = {};
|
398
398
|
o.status = 'fulfilled';
|
399
399
|
o.value = x;
|
400
400
|
Porffor.array.fastPush(_allOut, o);
|