porffor 0.56.8 → 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/_internal_object.ts +4 -4
- package/compiler/builtins/array.ts +1 -1
- package/compiler/builtins/base64.ts +2 -2
- package/compiler/builtins/console.ts +9 -12
- package/compiler/builtins/date.ts +1 -1
- package/compiler/builtins/function.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 +663 -1392
- 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
@@ -603,7 +603,7 @@ local.set ${obj+1}`;
|
|
603
603
|
} else obj = __Porffor_object_getHiddenPrototype(trueType);
|
604
604
|
|
605
605
|
// todo/opt: put this behind comptime flag if only __proto__ is used
|
606
|
-
if (hash == -406948493) if (key
|
606
|
+
if (hash == -406948493) if (Porffor.strcmp(key, '__proto__')) {
|
607
607
|
// get prototype
|
608
608
|
Porffor.wasm`
|
609
609
|
local.get ${obj}
|
@@ -679,7 +679,7 @@ export const __Porffor_object_set = (obj: any, key: any, value: any): any => {
|
|
679
679
|
let entryPtr: i32 = __Porffor_object_lookup(obj, key, hash);
|
680
680
|
let flags: i32;
|
681
681
|
if (entryPtr == -1) {
|
682
|
-
if (hash == -406948493) if (key
|
682
|
+
if (hash == -406948493) if (Porffor.strcmp(key, '__proto__')) {
|
683
683
|
// set prototype
|
684
684
|
__Porffor_object_setPrototype(obj, value);
|
685
685
|
return value;
|
@@ -785,7 +785,7 @@ export const __Porffor_object_setStrict = (obj: any, key: any, value: any): any
|
|
785
785
|
let entryPtr: i32 = __Porffor_object_lookup(obj, key, hash);
|
786
786
|
let flags: i32;
|
787
787
|
if (entryPtr == -1) {
|
788
|
-
if (hash == -406948493) if (key
|
788
|
+
if (hash == -406948493) if (Porffor.strcmp(key, '__proto__')) {
|
789
789
|
// set prototype
|
790
790
|
__Porffor_object_setPrototype(obj, value);
|
791
791
|
return value;
|
@@ -1063,7 +1063,7 @@ export const __Porffor_object_expr_init = (obj: any, key: any, value: any): void
|
|
1063
1063
|
const hash: i32 = __Porffor_object_hash(key);
|
1064
1064
|
let entryPtr: i32 = __Porffor_object_lookup(obj, key, hash);
|
1065
1065
|
if (entryPtr == -1) {
|
1066
|
-
if (hash == -406948493) if (key
|
1066
|
+
if (hash == -406948493) if (Porffor.strcmp(key, '__proto__')) {
|
1067
1067
|
// set prototype
|
1068
1068
|
__Porffor_object_setPrototype(obj, value);
|
1069
1069
|
return value;
|
@@ -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;
|
@@ -87,30 +87,27 @@ export const __Porffor_miniLog = (arg: any) => {
|
|
87
87
|
};
|
88
88
|
|
89
89
|
export const __Porffor_print = (arg: any, colors: boolean = true, depth: number = 0) => {
|
90
|
-
|
91
|
-
|
92
|
-
// note: this doesn't have access to the upper scope!! do not use any variables from up there
|
93
|
-
const __Porffor_printArray = (arg: any, colors: boolean, length: boolean = false) => {
|
94
|
-
const arrLen: i32 = arg.length - 1;
|
95
|
-
|
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;
|
96
92
|
if (length) {
|
97
93
|
Porffor.printStatic('(');
|
98
|
-
print(arrLen
|
94
|
+
print(arrLen);
|
99
95
|
Porffor.printStatic(') ');
|
100
96
|
}
|
101
97
|
|
102
|
-
if (arrLen ==
|
98
|
+
if (arrLen == 0) {
|
103
99
|
Porffor.printStatic('[]');
|
104
100
|
} else {
|
105
101
|
Porffor.printStatic('[ ');
|
106
|
-
for (let i: i32 = 0; i
|
102
|
+
for (let i: i32 = 0; i < arrLen; i++) {
|
107
103
|
__Porffor_print(arg[i], colors);
|
108
|
-
if (i != arrLen) Porffor.printStatic(', ');
|
104
|
+
if (i != arrLen - 1) Porffor.printStatic(', ');
|
109
105
|
}
|
110
106
|
Porffor.printStatic(' ]');
|
111
107
|
}
|
112
108
|
};
|
113
109
|
|
110
|
+
// todo: Symbol.toStringTag could reduce duplication here
|
114
111
|
switch (Porffor.type(arg)) {
|
115
112
|
case Porffor.TYPES.number:
|
116
113
|
if (colors) Porffor.printStatic('\x1b[33m'); // yellow
|
@@ -338,7 +335,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
|
|
338
335
|
}
|
339
336
|
};
|
340
337
|
|
341
|
-
let tabLevel = 0;
|
338
|
+
let tabLevel: i32 = 0;
|
342
339
|
export const __Porffor_consoleIndent = () => {
|
343
340
|
for (let i: i32 = 0; i < tabLevel; i++) {
|
344
341
|
Porffor.printStatic('\t');
|
@@ -462,7 +459,7 @@ export const __Porffor_dirObject = (obj: any, colors: boolean, depth: i32, showH
|
|
462
459
|
|
463
460
|
const keys = __Object_keys(obj);
|
464
461
|
const keysLen = keys.length - 1;
|
465
|
-
for (let i = 0; i <= keysLen; i++) {
|
462
|
+
for (let i: i32 = 0; i <= keysLen; i++) {
|
466
463
|
const key = keys[i];
|
467
464
|
__Porffor_consolePrint(key);
|
468
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;
|
@@ -4,7 +4,7 @@ export const __Function_prototype_toString = (_this: Function) => {
|
|
4
4
|
const out: bytestring = Porffor.allocate();
|
5
5
|
|
6
6
|
Porffor.bytestring.appendStr(out, 'function ');
|
7
|
-
Porffor.bytestring.appendStr(out, _this
|
7
|
+
Porffor.bytestring.appendStr(out, __Porffor_funcLut_name(_this));
|
8
8
|
Porffor.bytestring.appendStr(out, '() { [native code] }');
|
9
9
|
return out;
|
10
10
|
};
|
@@ -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);
|