porffor 0.37.20 → 0.37.22
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 +42 -1
- package/compiler/builtins/object.ts +3 -57
- package/compiler/builtins/promise.ts +0 -1
- package/compiler/builtins_precompiled.js +57 -57
- package/compiler/codegen.js +294 -289
- package/compiler/prefs.js +1 -1
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -4,7 +4,7 @@ export const __Porffor_object_underlying = (obj: any): any => {
|
|
4
4
|
const t: i32 = Porffor.rawType(obj);
|
5
5
|
if (t == Porffor.TYPES.object) return obj;
|
6
6
|
|
7
|
-
if (Porffor.fastAnd(t > 0x05, t != Porffor.TYPES.
|
7
|
+
if (Porffor.fastAnd(t > 0x05, t != Porffor.TYPES.undefined)) {
|
8
8
|
let idx: i32 = underlyingKeys.indexOf(obj);
|
9
9
|
if (idx == -1) {
|
10
10
|
const underlying: object = {};
|
@@ -22,6 +22,47 @@ export const __Porffor_object_underlying = (obj: any): any => {
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
+
if (t == Porffor.TYPES.array) {
|
26
|
+
const arr: any[] = obj;
|
27
|
+
const len: i32 = arr.length;
|
28
|
+
|
29
|
+
const key3: bytestring = 'length';
|
30
|
+
__Porffor_object_expr_initWithFlags(underlying, key3, len, 0b1000);
|
31
|
+
|
32
|
+
// todo: this should somehow be kept in sync?
|
33
|
+
for (let i: i32 = 0; i < len; i++) {
|
34
|
+
__Porffor_object_expr_initWithFlags(underlying, __Number_prototype_toString(i), arr[i], 0b1110);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
if (t == Porffor.TYPES.string) {
|
39
|
+
const str: string = obj;
|
40
|
+
const len: i32 = str.length;
|
41
|
+
|
42
|
+
const key3: bytestring = 'length';
|
43
|
+
__Porffor_object_expr_initWithFlags(underlying, key1, len, 0b0000);
|
44
|
+
|
45
|
+
for (let i: i32 = 0; i < len; i++) {
|
46
|
+
__Porffor_object_expr_initWithFlags(underlying, __Number_prototype_toString(i), str[i], 0b0100);
|
47
|
+
}
|
48
|
+
|
49
|
+
Porffor.object.preventExtensions(underlying);
|
50
|
+
}
|
51
|
+
|
52
|
+
if (t == Porffor.TYPES.bytestring) {
|
53
|
+
const str: bytestring = obj;
|
54
|
+
const len: i32 = str.length;
|
55
|
+
|
56
|
+
const key3: bytestring = 'length';
|
57
|
+
__Porffor_object_expr_initWithFlags(underlying, key1, len, 0b0000);
|
58
|
+
|
59
|
+
for (let i: i32 = 0; i < len; i++) {
|
60
|
+
__Porffor_object_expr_initWithFlags(underlying, __Number_prototype_toString(i), str[i], 0b0100);
|
61
|
+
}
|
62
|
+
|
63
|
+
Porffor.object.preventExtensions(underlying);
|
64
|
+
}
|
65
|
+
|
25
66
|
Porffor.array.fastPush(underlyingVals, underlying);
|
26
67
|
idx = Porffor.array.fastPush(underlyingKeys, obj) - 1;
|
27
68
|
}
|
@@ -18,6 +18,7 @@ export const __Object_keys = (obj: any): any[] => {
|
|
18
18
|
if (obj == null) throw new TypeError('Argument is nullish, expected object');
|
19
19
|
const out: any[] = Porffor.allocate();
|
20
20
|
|
21
|
+
obj = __Porffor_object_underlying(obj);
|
21
22
|
const t: i32 = Porffor.rawType(obj);
|
22
23
|
if (t == Porffor.TYPES.object) {
|
23
24
|
let ptr: i32 = Porffor.wasm`local.get ${obj}` + 5;
|
@@ -64,25 +65,6 @@ local.set ${key}`;
|
|
64
65
|
}
|
65
66
|
|
66
67
|
out.length = i;
|
67
|
-
} else {
|
68
|
-
if (Porffor.fastOr(
|
69
|
-
t == Porffor.TYPES.array,
|
70
|
-
t == Porffor.TYPES.bytestring,
|
71
|
-
t == Porffor.TYPES.string
|
72
|
-
)) {
|
73
|
-
const len: i32 = obj.length;
|
74
|
-
out.length = len;
|
75
|
-
|
76
|
-
for (let i: i32 = 0; i < len; i++) {
|
77
|
-
out[i] = __Number_prototype_toString(i);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
obj = __Porffor_object_underlying(obj);
|
82
|
-
if (Porffor.rawType(obj) == Porffor.TYPES.object) {
|
83
|
-
const objKeys: any[] = __Object_keys(obj);
|
84
|
-
for (const x of objKeys) Porffor.array.fastPush(out, x);
|
85
|
-
}
|
86
68
|
}
|
87
69
|
|
88
70
|
return out;
|
@@ -92,6 +74,7 @@ export const __Object_values = (obj: any): any[] => {
|
|
92
74
|
if (obj == null) throw new TypeError('Argument is nullish, expected object');
|
93
75
|
const out: any[] = Porffor.allocate();
|
94
76
|
|
77
|
+
obj = __Porffor_object_underlying(obj);
|
95
78
|
const t: i32 = Porffor.rawType(obj);
|
96
79
|
if (t == Porffor.TYPES.object) {
|
97
80
|
let ptr: i32 = Porffor.wasm`local.get ${obj}` + 5;
|
@@ -118,25 +101,6 @@ local.set ${val+1}`;
|
|
118
101
|
}
|
119
102
|
|
120
103
|
out.length = i;
|
121
|
-
} else {
|
122
|
-
if (Porffor.fastOr(
|
123
|
-
t == Porffor.TYPES.array,
|
124
|
-
t == Porffor.TYPES.bytestring,
|
125
|
-
t == Porffor.TYPES.string
|
126
|
-
)) {
|
127
|
-
const len: i32 = obj.length;
|
128
|
-
out.length = len;
|
129
|
-
|
130
|
-
for (let i: i32 = 0; i < len; i++) {
|
131
|
-
out[i] = obj[i];
|
132
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
obj = __Porffor_object_underlying(obj);
|
136
|
-
if (Porffor.rawType(obj) == Porffor.TYPES.object) {
|
137
|
-
const objVals: any[] = __Object_values(obj);
|
138
|
-
for (const x of objVals) Porffor.array.fastPush(out, x);
|
139
|
-
}
|
140
104
|
}
|
141
105
|
|
142
106
|
return out;
|
@@ -454,6 +418,7 @@ export const __Object_getOwnPropertyNames = (obj: any): any[] => {
|
|
454
418
|
if (obj == null) throw new TypeError('Argument is nullish, expected object');
|
455
419
|
const out: any[] = Porffor.allocate();
|
456
420
|
|
421
|
+
obj = __Porffor_object_underlying(obj);
|
457
422
|
const t: i32 = Porffor.rawType(obj);
|
458
423
|
if (t == Porffor.TYPES.object) {
|
459
424
|
let ptr: i32 = Porffor.wasm`local.get ${obj}` + 5;
|
@@ -499,25 +464,6 @@ local.set ${key}`;
|
|
499
464
|
}
|
500
465
|
|
501
466
|
out.length = i;
|
502
|
-
} else {
|
503
|
-
if (Porffor.fastOr(
|
504
|
-
t == Porffor.TYPES.array,
|
505
|
-
t == Porffor.TYPES.bytestring,
|
506
|
-
t == Porffor.TYPES.string
|
507
|
-
)) {
|
508
|
-
const len: i32 = obj.length;
|
509
|
-
out.length = len;
|
510
|
-
|
511
|
-
for (let i: i32 = 0; i < len; i++) {
|
512
|
-
out[i] = __Number_prototype_toString(i);
|
513
|
-
}
|
514
|
-
}
|
515
|
-
|
516
|
-
obj = __Porffor_object_underlying(obj);
|
517
|
-
if (Porffor.rawType(obj) == Porffor.TYPES.object) {
|
518
|
-
const objKeys: any[] = __Object_getOwnPropertyNames(obj);
|
519
|
-
for (const x of objKeys) Porffor.array.fastPush(out, x);
|
520
|
-
}
|
521
467
|
}
|
522
468
|
|
523
469
|
return out;
|