porffor 0.28.11 → 0.28.13
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/CONTRIBUTING.md +1 -1
- package/compiler/builtins/array.ts +8 -7
- package/compiler/builtins/boolean.ts +7 -0
- package/compiler/builtins/console.ts +132 -133
- package/compiler/builtins/dataview.ts +4 -4
- package/compiler/builtins/object.ts +3 -3
- package/compiler/builtins/porffor.d.ts +1 -1
- package/compiler/builtins_precompiled.js +34 -27
- package/compiler/codegen.js +32 -20
- package/compiler/opt.js +3 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/CONTRIBUTING.md
CHANGED
@@ -202,7 +202,7 @@ Store the character code into the `out` pointer variable, and increment it.
|
|
202
202
|
- Attempt to avoid object/string/array-heavy code and use more variables instead if possible, easier on memory and CPU/perf.
|
203
203
|
- Do not set a return type for prototype methods, it can cause errors/unexpected results.
|
204
204
|
- You cannot use other functions in the file not exported, or variables not inside the current function.
|
205
|
-
- `if (...)` uses a fast truthy implementation which is not spec-compliant as most conditions should be strictly checked. To use spec-compliant behavior, use `if (
|
205
|
+
- `if (...)` uses a fast truthy implementation which is not spec-compliant as most conditions should be strictly checked. To use spec-compliant behavior, use `if (!!...)`.
|
206
206
|
- For object (string/array/etc) literals, you must use a variable eg `const out: bytestring = 'foobar'; console.log(out);` instead of `console.log('foobar')` due to precompile's allocator constraints.
|
207
207
|
- You should generally use non-strict equality ops (`==`/`!=`).
|
208
208
|
|
@@ -435,7 +435,7 @@ export const __Array_prototype_filter = (_this: any[], callbackFn: any) => {
|
|
435
435
|
let j: i32 = 0;
|
436
436
|
while (i < len) {
|
437
437
|
const el: any = _this[i];
|
438
|
-
if (
|
438
|
+
if (!!callbackFn(el, i++, _this)) out[j++] = el;
|
439
439
|
}
|
440
440
|
|
441
441
|
out.length = j;
|
@@ -478,7 +478,7 @@ export const __Array_prototype_find = (_this: any[], callbackFn: any) => {
|
|
478
478
|
let i: i32 = 0;
|
479
479
|
while (i < len) {
|
480
480
|
const el: any = _this[i];
|
481
|
-
if (
|
481
|
+
if (!!callbackFn(el, i++, _this)) return el;
|
482
482
|
}
|
483
483
|
};
|
484
484
|
|
@@ -487,7 +487,7 @@ export const __Array_prototype_findLast = (_this: any[], callbackFn: any) => {
|
|
487
487
|
let i: i32 = _this.length;
|
488
488
|
while (i > 0) {
|
489
489
|
const el: any = _this[--i];
|
490
|
-
if (
|
490
|
+
if (!!callbackFn(el, i, _this)) return el;
|
491
491
|
}
|
492
492
|
};
|
493
493
|
|
@@ -496,7 +496,7 @@ export const __Array_prototype_findIndex = (_this: any[], callbackFn: any) => {
|
|
496
496
|
const len: i32 = _this.length;
|
497
497
|
let i: i32 = 0;
|
498
498
|
while (i < len) {
|
499
|
-
if (
|
499
|
+
if (!!callbackFn(_this[i], i++, _this)) return i;
|
500
500
|
}
|
501
501
|
};
|
502
502
|
|
@@ -504,7 +504,7 @@ export const __Array_prototype_findIndex = (_this: any[], callbackFn: any) => {
|
|
504
504
|
export const __Array_prototype_findLastIndex = (_this: any[], callbackFn: any) => {
|
505
505
|
let i: i32 = _this.length;
|
506
506
|
while (i > 0) {
|
507
|
-
if (
|
507
|
+
if (!!callbackFn(_this[--i], i, _this)) return i;
|
508
508
|
}
|
509
509
|
};
|
510
510
|
|
@@ -513,7 +513,8 @@ export const __Array_prototype_every = (_this: any[], callbackFn: any) => {
|
|
513
513
|
const len: i32 = _this.length;
|
514
514
|
let i: i32 = 0;
|
515
515
|
while (i < len) {
|
516
|
-
if (
|
516
|
+
if (!!callbackFn(_this[i], i++, _this)) {}
|
517
|
+
else return false;
|
517
518
|
}
|
518
519
|
|
519
520
|
return true;
|
@@ -524,7 +525,7 @@ export const __Array_prototype_some = (_this: any[], callbackFn: any) => {
|
|
524
525
|
const len: i32 = _this.length;
|
525
526
|
let i: i32 = 0;
|
526
527
|
while (i < len) {
|
527
|
-
if (
|
528
|
+
if (!!callbackFn(_this[i], i++, _this)) return true;
|
528
529
|
}
|
529
530
|
|
530
531
|
return false;
|
@@ -1,5 +1,12 @@
|
|
1
1
|
import type {} from './porffor.d.ts';
|
2
2
|
|
3
|
+
export const Boolean = function (value: any): boolean {
|
4
|
+
// hack: allow to be called via new but we do not have prim objects yet
|
5
|
+
new.target;
|
6
|
+
|
7
|
+
return !!value;
|
8
|
+
};
|
9
|
+
|
3
10
|
// 20.3.3.2 Boolean.prototype.toString ()
|
4
11
|
// https://tc39.es/ecma262/#sec-boolean.prototype.tostring
|
5
12
|
export const __Boolean_prototype_toString = (_this: boolean) => {
|
@@ -18,12 +18,12 @@ export const __Porffor_printString = (arg: bytestring|string) => {
|
|
18
18
|
|
19
19
|
export const __Porffor_printHexDigit = (arg: number) => {
|
20
20
|
switch (arg) {
|
21
|
-
case 0xf: printStatic('f'); return;
|
22
|
-
case 0xe: printStatic('e'); return;
|
23
|
-
case 0xd: printStatic('d'); return;
|
24
|
-
case 0xc: printStatic('c'); return;
|
25
|
-
case 0xb: printStatic('b'); return;
|
26
|
-
case 0xa: printStatic('a'); return;
|
21
|
+
case 0xf: Porffor.printStatic('f'); return;
|
22
|
+
case 0xe: Porffor.printStatic('e'); return;
|
23
|
+
case 0xd: Porffor.printStatic('d'); return;
|
24
|
+
case 0xc: Porffor.printStatic('c'); return;
|
25
|
+
case 0xb: Porffor.printStatic('b'); return;
|
26
|
+
case 0xa: Porffor.printStatic('a'); return;
|
27
27
|
|
28
28
|
default: print(arg);
|
29
29
|
}
|
@@ -31,7 +31,7 @@ export const __Porffor_printHexDigit = (arg: number) => {
|
|
31
31
|
|
32
32
|
export const __Porffor_numberLog = (arg: number) => {
|
33
33
|
print(arg);
|
34
|
-
printStatic('\n');
|
34
|
+
Porffor.printStatic('\n');
|
35
35
|
};
|
36
36
|
|
37
37
|
export const __Porffor_miniLog = (arg: any) => {
|
@@ -42,48 +42,48 @@ export const __Porffor_miniLog = (arg: any) => {
|
|
42
42
|
|
43
43
|
case Porffor.TYPES.boolean:
|
44
44
|
if (arg) {
|
45
|
-
printStatic('true');
|
45
|
+
Porffor.printStatic('true');
|
46
46
|
} else {
|
47
|
-
printStatic('false');
|
47
|
+
Porffor.printStatic('false');
|
48
48
|
}
|
49
49
|
break;
|
50
50
|
|
51
51
|
case Porffor.TYPES.bytestring:
|
52
52
|
case Porffor.TYPES.string:
|
53
|
-
printStatic("'");
|
53
|
+
Porffor.printStatic("'");
|
54
54
|
__Porffor_printString(arg);
|
55
|
-
printStatic("'");
|
55
|
+
Porffor.printStatic("'");
|
56
56
|
break;
|
57
57
|
|
58
58
|
case Porffor.TYPES.array:
|
59
59
|
const arrLen: i32 = arg.length - 1;
|
60
60
|
if (arrLen == -1) {
|
61
|
-
printStatic('[]');
|
61
|
+
Porffor.printStatic('[]');
|
62
62
|
} else {
|
63
|
-
printStatic('[ ');
|
63
|
+
Porffor.printStatic('[ ');
|
64
64
|
for (let i: i32 = 0; i <= arrLen; i++) {
|
65
65
|
__Porffor_miniLog(arg[i]);
|
66
|
-
if (i != arrLen) printStatic(', ');
|
66
|
+
if (i != arrLen) Porffor.printStatic(', ');
|
67
67
|
}
|
68
|
-
printStatic(' ]');
|
68
|
+
Porffor.printStatic(' ]');
|
69
69
|
}
|
70
70
|
break;
|
71
71
|
|
72
72
|
case Porffor.TYPES.empty:
|
73
73
|
case Porffor.TYPES.undefined:
|
74
|
-
printStatic('undefined');
|
74
|
+
Porffor.printStatic('undefined');
|
75
75
|
break;
|
76
76
|
|
77
77
|
case Porffor.TYPES.object:
|
78
78
|
if (arg) {
|
79
|
-
printStatic('[Object]');
|
79
|
+
Porffor.printStatic('[Object]');
|
80
80
|
} else {
|
81
|
-
printStatic('null');
|
81
|
+
Porffor.printStatic('null');
|
82
82
|
}
|
83
83
|
break;
|
84
84
|
}
|
85
85
|
|
86
|
-
printStatic('\n');
|
86
|
+
Porffor.printStatic('\n');
|
87
87
|
};
|
88
88
|
|
89
89
|
export const __Porffor_print = (arg: any, colors: boolean = true) => {
|
@@ -94,102 +94,101 @@ export const __Porffor_print = (arg: any, colors: boolean = true) => {
|
|
94
94
|
const arrLen: i32 = arg.length - 1;
|
95
95
|
|
96
96
|
if (length) {
|
97
|
-
printStatic('(');
|
97
|
+
Porffor.printStatic('(');
|
98
98
|
print(arrLen + 1);
|
99
|
-
printStatic(') ');
|
99
|
+
Porffor.printStatic(') ');
|
100
100
|
}
|
101
101
|
|
102
102
|
if (arrLen == -1) {
|
103
|
-
printStatic('[]');
|
103
|
+
Porffor.printStatic('[]');
|
104
104
|
} else {
|
105
|
-
printStatic('[ ');
|
105
|
+
Porffor.printStatic('[ ');
|
106
106
|
for (let i: i32 = 0; i <= arrLen; i++) {
|
107
107
|
__Porffor_print(arg[i], colors);
|
108
|
-
if (i != arrLen) printStatic(', ');
|
108
|
+
if (i != arrLen) Porffor.printStatic(', ');
|
109
109
|
}
|
110
|
-
printStatic(' ]');
|
110
|
+
Porffor.printStatic(' ]');
|
111
111
|
}
|
112
112
|
};
|
113
113
|
|
114
114
|
switch (Porffor.rawType(arg)) {
|
115
115
|
case Porffor.TYPES.number:
|
116
|
-
if (colors) printStatic('\x1b[33m'); // yellow
|
116
|
+
if (colors) Porffor.printStatic('\x1b[33m'); // yellow
|
117
117
|
print(arg);
|
118
|
-
if (colors) printStatic('\x1b[0m');
|
118
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
119
119
|
return;
|
120
120
|
|
121
121
|
case Porffor.TYPES.boolean:
|
122
|
-
if (colors) printStatic('\x1b[33m'); // yellow
|
122
|
+
if (colors) Porffor.printStatic('\x1b[33m'); // yellow
|
123
123
|
if (arg) {
|
124
|
-
printStatic('true');
|
124
|
+
Porffor.printStatic('true');
|
125
125
|
} else {
|
126
|
-
printStatic('false');
|
126
|
+
Porffor.printStatic('false');
|
127
127
|
}
|
128
|
-
if (colors) printStatic('\x1b[0m');
|
128
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
129
129
|
return;
|
130
130
|
|
131
131
|
case Porffor.TYPES.bytestring:
|
132
132
|
case Porffor.TYPES.string:
|
133
|
-
if (colors) printStatic('\x1b[32m'); // green
|
134
|
-
printStatic("'");
|
133
|
+
if (colors) Porffor.printStatic('\x1b[32m'); // green
|
134
|
+
Porffor.printStatic("'");
|
135
135
|
|
136
136
|
__Porffor_printString(arg);
|
137
137
|
|
138
|
-
printStatic("'");
|
139
|
-
if (colors) printStatic('\x1b[0m');
|
138
|
+
Porffor.printStatic("'");
|
139
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
140
140
|
return;
|
141
141
|
|
142
142
|
case Porffor.TYPES.empty:
|
143
143
|
case Porffor.TYPES.undefined:
|
144
|
-
if (colors) printStatic('\x1b[2m'); // dim
|
145
|
-
printStatic('undefined');
|
146
|
-
if (colors) printStatic('\x1b[0m');
|
144
|
+
if (colors) Porffor.printStatic('\x1b[2m'); // dim
|
145
|
+
Porffor.printStatic('undefined');
|
146
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
147
147
|
return;
|
148
148
|
|
149
149
|
case Porffor.TYPES.object:
|
150
150
|
if (arg) {
|
151
|
-
printStatic('{\n');
|
151
|
+
Porffor.printStatic('{\n');
|
152
152
|
|
153
|
-
const keys = Object.keys(arg);
|
154
|
-
const len = keys.length - 1;
|
153
|
+
const keys: any[] = Object.keys(arg);
|
154
|
+
const len: i32 = keys.length - 1;
|
155
155
|
for (let i: i32 = 0; i <= len; i++) {
|
156
|
-
const x = keys[i];
|
156
|
+
const x: any = keys[i];
|
157
157
|
|
158
|
-
printStatic(' ');
|
158
|
+
Porffor.printStatic(' ');
|
159
159
|
__Porffor_printString(x);
|
160
160
|
|
161
|
-
printStatic(': ');
|
162
|
-
__Porffor_print(arg
|
161
|
+
Porffor.printStatic(': ');
|
162
|
+
__Porffor_print(Porffor.object.get(arg, ecma262.ToPropertyKey(x)));
|
163
163
|
|
164
|
-
if (i != len) printStatic(',\n');
|
164
|
+
if (i != len) Porffor.printStatic(',\n');
|
165
165
|
}
|
166
166
|
|
167
|
-
printStatic('\n}');
|
167
|
+
Porffor.printStatic('\n}');
|
168
168
|
} else {
|
169
|
-
if (colors) printStatic('\x1b[1m'); // bold
|
170
|
-
printStatic('null');
|
169
|
+
if (colors) Porffor.printStatic('\x1b[1m'); // bold
|
170
|
+
Porffor.printStatic('null');
|
171
171
|
}
|
172
172
|
|
173
|
-
if (colors) printStatic('\x1b[0m');
|
173
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
174
174
|
return;
|
175
175
|
|
176
176
|
case Porffor.TYPES.function:
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
printStatic(']');
|
177
|
+
Porffor.printStatic('[Function ');
|
178
|
+
__Porffor_printString(__Porffor_funcLut_name(arg));
|
179
|
+
Porffor.printStatic(']');
|
181
180
|
return;
|
182
181
|
|
183
182
|
case Porffor.TYPES.date:
|
184
|
-
if (colors) printStatic('\x1b[35m'); // purple
|
183
|
+
if (colors) Porffor.printStatic('\x1b[35m'); // purple
|
185
184
|
__Porffor_printString(__Date_prototype_toISOString(arg));
|
186
|
-
if (colors) printStatic('\x1b[0m');
|
185
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
187
186
|
return;
|
188
187
|
|
189
188
|
case Porffor.TYPES.symbol:
|
190
|
-
if (colors) printStatic('\x1b[32m'); // green
|
189
|
+
if (colors) Porffor.printStatic('\x1b[32m'); // green
|
191
190
|
__Porffor_printString(__Symbol_prototype_toString(arg));
|
192
|
-
if (colors) printStatic('\x1b[0m');
|
191
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
193
192
|
return;
|
194
193
|
|
195
194
|
case Porffor.TYPES.array:
|
@@ -197,60 +196,60 @@ export const __Porffor_print = (arg: any, colors: boolean = true) => {
|
|
197
196
|
return;
|
198
197
|
|
199
198
|
case Porffor.TYPES.uint8array:
|
200
|
-
printStatic('Uint8Array');
|
199
|
+
Porffor.printStatic('Uint8Array');
|
201
200
|
__Porffor_printArray(arg, colors, true);
|
202
201
|
return;
|
203
202
|
|
204
203
|
case Porffor.TYPES.int8array:
|
205
|
-
printStatic('Int8Array');
|
204
|
+
Porffor.printStatic('Int8Array');
|
206
205
|
__Porffor_printArray(arg, colors, true);
|
207
206
|
return;
|
208
207
|
|
209
208
|
case Porffor.TYPES.uint8clampedarray:
|
210
|
-
printStatic('Uint8ClampedArray');
|
209
|
+
Porffor.printStatic('Uint8ClampedArray');
|
211
210
|
__Porffor_printArray(arg, colors, true);
|
212
211
|
return;
|
213
212
|
|
214
213
|
case Porffor.TYPES.uint16array:
|
215
|
-
printStatic('Uint16Array');
|
214
|
+
Porffor.printStatic('Uint16Array');
|
216
215
|
__Porffor_printArray(arg, colors, true);
|
217
216
|
return;
|
218
217
|
|
219
218
|
case Porffor.TYPES.int16array:
|
220
|
-
printStatic('Int16Array');
|
219
|
+
Porffor.printStatic('Int16Array');
|
221
220
|
__Porffor_printArray(arg, colors, true);
|
222
221
|
return;
|
223
222
|
|
224
223
|
case Porffor.TYPES.uint32array:
|
225
|
-
printStatic('Uint32Array');
|
224
|
+
Porffor.printStatic('Uint32Array');
|
226
225
|
__Porffor_printArray(arg, colors, true);
|
227
226
|
return;
|
228
227
|
|
229
228
|
case Porffor.TYPES.int32array:
|
230
|
-
printStatic('Int32Array');
|
229
|
+
Porffor.printStatic('Int32Array');
|
231
230
|
__Porffor_printArray(arg, colors, true);
|
232
231
|
return;
|
233
232
|
|
234
233
|
case Porffor.TYPES.float32array:
|
235
|
-
printStatic('Float32Array');
|
234
|
+
Porffor.printStatic('Float32Array');
|
236
235
|
__Porffor_printArray(arg, colors, true);
|
237
236
|
return;
|
238
237
|
|
239
238
|
case Porffor.TYPES.float64array:
|
240
|
-
printStatic('Float64Array');
|
239
|
+
Porffor.printStatic('Float64Array');
|
241
240
|
__Porffor_printArray(arg, colors, true);
|
242
241
|
return;
|
243
242
|
|
244
243
|
case Porffor.TYPES.sharedarraybuffer:
|
245
244
|
case Porffor.TYPES.arraybuffer:
|
246
|
-
if (Porffor.rawType(arg) == Porffor.TYPES.sharedarraybuffer) printStatic('SharedArrayBuffer');
|
247
|
-
else printStatic('ArrayBuffer');
|
248
|
-
printStatic(' {\n');
|
245
|
+
if (Porffor.rawType(arg) == Porffor.TYPES.sharedarraybuffer) Porffor.printStatic('SharedArrayBuffer');
|
246
|
+
else Porffor.printStatic('ArrayBuffer');
|
247
|
+
Porffor.printStatic(' {\n');
|
249
248
|
|
250
|
-
if (colors) printStatic('\x1b[34m'); // blue
|
251
|
-
printStatic(' [Uint8Contents]');
|
252
|
-
if (colors) printStatic('\x1b[0m');
|
253
|
-
printStatic('): <');
|
249
|
+
if (colors) Porffor.printStatic('\x1b[34m'); // blue
|
250
|
+
Porffor.printStatic(' [Uint8Contents]');
|
251
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
252
|
+
Porffor.printStatic('): <');
|
254
253
|
|
255
254
|
const buffer = new Uint8Array(arg);
|
256
255
|
const bufferLen = buffer.length - 1;
|
@@ -258,70 +257,70 @@ export const __Porffor_print = (arg: any, colors: boolean = true) => {
|
|
258
257
|
const ele = buffer[i];
|
259
258
|
__Porffor_printHexDigit((ele & 0xF0) / 16);
|
260
259
|
__Porffor_printHexDigit(ele & 0xF);
|
261
|
-
if (i != bufferLen) printStatic(' ');
|
260
|
+
if (i != bufferLen) Porffor.printStatic(' ');
|
262
261
|
}
|
263
262
|
|
264
|
-
printStatic('>,\n byteLength: ');
|
265
|
-
if (colors) printStatic('\x1b[33m'); // yellow
|
263
|
+
Porffor.printStatic('>,\n byteLength: ');
|
264
|
+
if (colors) Porffor.printStatic('\x1b[33m'); // yellow
|
266
265
|
print(arg.byteLength);
|
267
|
-
if (colors) printStatic('\x1b[0m');
|
268
|
-
printStatic('\n}');
|
266
|
+
if (colors) Porffor.printStatic('\x1b[0m');
|
267
|
+
Porffor.printStatic('\n}');
|
269
268
|
return;
|
270
269
|
|
271
270
|
case Porffor.TYPES.dataview:
|
272
|
-
printStatic('DataView {\n');
|
273
|
-
printStatic(' byteLength: ');
|
274
|
-
__Porffor_print(arg
|
275
|
-
printStatic(',\n byteOffset: ');
|
276
|
-
__Porffor_print(arg
|
277
|
-
printStatic(',\n buffer: ');
|
278
|
-
__Porffor_print(arg
|
279
|
-
printStatic('\n}');
|
271
|
+
Porffor.printStatic('DataView {\n');
|
272
|
+
Porffor.printStatic(' byteLength: ');
|
273
|
+
__Porffor_print(__DataView_prototype_byteLength$get(arg), colors);
|
274
|
+
Porffor.printStatic(',\n byteOffset: ');
|
275
|
+
__Porffor_print(__DataView_prototype_byteOffset$get(arg), colors);
|
276
|
+
Porffor.printStatic(',\n buffer: ');
|
277
|
+
__Porffor_print(__DataView_prototype_buffer$get(arg), colors);
|
278
|
+
Porffor.printStatic('\n}');
|
280
279
|
return;
|
281
280
|
|
282
281
|
case Porffor.TYPES.weakmap:
|
283
282
|
case Porffor.TYPES.map:
|
284
|
-
if (Porffor.rawType(arg) == Porffor.TYPES.weakmap) printStatic('WeakMap');
|
285
|
-
else printStatic('Map');
|
286
|
-
printStatic('(');
|
283
|
+
if (Porffor.rawType(arg) == Porffor.TYPES.weakmap) Porffor.printStatic('WeakMap');
|
284
|
+
else Porffor.printStatic('Map');
|
285
|
+
Porffor.printStatic('(');
|
287
286
|
|
288
|
-
const map = __Map_prototype_keys(arg);
|
287
|
+
const map: any[] = __Map_prototype_keys(arg);
|
289
288
|
const mapLen: i32 = map.length - 1;
|
290
289
|
print(mapLen + 1);
|
291
|
-
printStatic(') { ');
|
290
|
+
Porffor.printStatic(') { ');
|
292
291
|
|
293
292
|
for (let i: i32 = 0; i < mapLen; i++) {
|
294
|
-
const key = map[i];
|
293
|
+
const key: any = map[i];
|
295
294
|
__Porffor_print(key);
|
296
|
-
printStatic(' => ');
|
295
|
+
Porffor.printStatic(' => ');
|
297
296
|
__Porffor_print(__Map_prototype_get(arg, key), colors);
|
298
|
-
if (i != mapLen) printStatic(', ');
|
297
|
+
if (i != mapLen) Porffor.printStatic(', ');
|
299
298
|
}
|
300
299
|
|
301
|
-
printStatic(' }');
|
300
|
+
Porffor.printStatic(' }');
|
302
301
|
return;
|
303
302
|
|
304
303
|
case Porffor.TYPES.weakset:
|
305
304
|
case Porffor.TYPES.set:
|
306
|
-
if (Porffor.rawType(arg) == Porffor.TYPES.weakset) printStatic('WeakSet');
|
307
|
-
else printStatic('Set');
|
308
|
-
printStatic('(');
|
305
|
+
if (Porffor.rawType(arg) == Porffor.TYPES.weakset) Porffor.printStatic('WeakSet');
|
306
|
+
else Porffor.printStatic('Set');
|
307
|
+
Porffor.printStatic('(');
|
309
308
|
|
310
|
-
const set = __Set_prototype_values(arg);
|
309
|
+
const set: any[] = __Set_prototype_values(arg);
|
311
310
|
const setLen: i32 = set.length - 1;
|
312
311
|
print(setLen + 1);
|
313
|
-
printStatic(') { ');
|
312
|
+
Porffor.printStatic(') { ');
|
314
313
|
|
315
314
|
for (let i: i32 = 0; i <= setLen; i++) {
|
316
315
|
__Porffor_print(set[i], colors);
|
317
|
-
if (i != setLen) printStatic(', ');
|
316
|
+
if (i != setLen) Porffor.printStatic(', ');
|
318
317
|
}
|
319
318
|
|
320
|
-
printStatic(' }');
|
319
|
+
Porffor.printStatic(' }');
|
321
320
|
return;
|
322
321
|
|
323
322
|
case Porffor.TYPES.weakref:
|
324
|
-
printStatic('WeakRef {}');
|
323
|
+
Porffor.printStatic('WeakRef {}');
|
325
324
|
return;
|
326
325
|
|
327
326
|
// case Porffor.TYPES.regexp:
|
@@ -336,12 +335,12 @@ export const __Porffor_print = (arg: any, colors: boolean = true) => {
|
|
336
335
|
let tabLevel = 0;
|
337
336
|
export const __Porffor_consoleIndent = () => {
|
338
337
|
for (let i = 0; i < tabLevel; i++) {
|
339
|
-
printStatic('\t');
|
338
|
+
Porffor.printStatic('\t');
|
340
339
|
}
|
341
340
|
};
|
342
341
|
|
343
342
|
export const __console_clear = () => {
|
344
|
-
printStatic('\x1b[1;1H\x1b[J');
|
343
|
+
Porffor.printStatic('\x1b[1;1H\x1b[J');
|
345
344
|
tabLevel = 0;
|
346
345
|
};
|
347
346
|
|
@@ -375,10 +374,10 @@ export const __console_log = (...args: any[]) => {
|
|
375
374
|
__Porffor_consoleIndent();
|
376
375
|
__Porffor_consolePrint(args[i]);
|
377
376
|
|
378
|
-
if (i != argLen) printStatic(' ');
|
377
|
+
if (i != argLen) Porffor.printStatic(' ');
|
379
378
|
}
|
380
379
|
|
381
|
-
printStatic('\n');
|
380
|
+
Porffor.printStatic('\n');
|
382
381
|
};
|
383
382
|
|
384
383
|
export const __console_debug = (...args: any[]) => {
|
@@ -387,10 +386,10 @@ export const __console_debug = (...args: any[]) => {
|
|
387
386
|
__Porffor_consoleIndent();
|
388
387
|
__Porffor_consolePrint(args[i]);
|
389
388
|
|
390
|
-
if (i != argLen) printStatic(' ');
|
389
|
+
if (i != argLen) Porffor.printStatic(' ');
|
391
390
|
}
|
392
391
|
|
393
|
-
printStatic('\n');
|
392
|
+
Porffor.printStatic('\n');
|
394
393
|
};
|
395
394
|
|
396
395
|
export const __console_info = (...args: any[]) => {
|
@@ -399,10 +398,10 @@ export const __console_info = (...args: any[]) => {
|
|
399
398
|
__Porffor_consoleIndent();
|
400
399
|
__Porffor_consolePrint(args[i]);
|
401
400
|
|
402
|
-
if (i != argLen) printStatic(' ');
|
401
|
+
if (i != argLen) Porffor.printStatic(' ');
|
403
402
|
}
|
404
403
|
|
405
|
-
printStatic('\n');
|
404
|
+
Porffor.printStatic('\n');
|
406
405
|
};
|
407
406
|
|
408
407
|
export const __console_warn = (...args: any[]) => {
|
@@ -411,10 +410,10 @@ export const __console_warn = (...args: any[]) => {
|
|
411
410
|
__Porffor_consoleIndent();
|
412
411
|
__Porffor_consolePrint(args[i]);
|
413
412
|
|
414
|
-
if (i != argLen) printStatic(' ');
|
413
|
+
if (i != argLen) Porffor.printStatic(' ');
|
415
414
|
}
|
416
415
|
|
417
|
-
printStatic('\n');
|
416
|
+
Porffor.printStatic('\n');
|
418
417
|
};
|
419
418
|
|
420
419
|
export const __console_error = (...args: any[]) => {
|
@@ -423,28 +422,28 @@ export const __console_error = (...args: any[]) => {
|
|
423
422
|
__Porffor_consoleIndent();
|
424
423
|
__Porffor_consolePrint(args[i]);
|
425
424
|
|
426
|
-
if (i != argLen) printStatic(' ');
|
425
|
+
if (i != argLen) Porffor.printStatic(' ');
|
427
426
|
}
|
428
427
|
|
429
|
-
printStatic('\n');
|
428
|
+
Porffor.printStatic('\n');
|
430
429
|
};
|
431
430
|
|
432
431
|
export const __console_assert = (assertion: any, ...args: any[]) => {
|
433
432
|
if (assertion) return;
|
434
433
|
|
435
434
|
__Porffor_consoleIndent();
|
436
|
-
printStatic('Assertion failed');
|
435
|
+
Porffor.printStatic('Assertion failed');
|
437
436
|
if (args.length != 0) {
|
438
|
-
printStatic(': ');
|
437
|
+
Porffor.printStatic(': ');
|
439
438
|
}
|
440
439
|
|
441
440
|
const argLen: i32 = args.length - 1;
|
442
441
|
for (let i = 0; i <= argLen; i++) {
|
443
442
|
__Porffor_consolePrint(args[i]);
|
444
|
-
if (i != argLen) printStatic(' ');
|
443
|
+
if (i != argLen) Porffor.printStatic(' ');
|
445
444
|
}
|
446
445
|
|
447
|
-
printStatic('\n');
|
446
|
+
Porffor.printStatic('\n');
|
448
447
|
};
|
449
448
|
|
450
449
|
export const __Porffor_dirObject = (obj: any, colors: boolean, depth: i32, showHidden: boolean) => {
|
@@ -453,22 +452,22 @@ export const __Porffor_dirObject = (obj: any, colors: boolean, depth: i32, showH
|
|
453
452
|
return;
|
454
453
|
}
|
455
454
|
|
456
|
-
printStatic('{ ');
|
455
|
+
Porffor.printStatic('{ ');
|
457
456
|
|
458
457
|
const keys = __Object_keys(obj);
|
459
458
|
const keysLen = keys.length - 1;
|
460
459
|
for (let i = 0; i <= keysLen; i++) {
|
461
460
|
const key = keys[i];
|
462
461
|
__Porffor_consolePrint(key);
|
463
|
-
printStatic(': ');
|
462
|
+
Porffor.printStatic(': ');
|
464
463
|
|
465
464
|
const value = __Porffor_object_get(obj, key);
|
466
465
|
__Porffor_dirObject(value, colors, depth - 1, showHidden);
|
467
466
|
|
468
|
-
if (i != keysLen) printStatic(', ');
|
467
|
+
if (i != keysLen) Porffor.printStatic(', ');
|
469
468
|
}
|
470
469
|
|
471
|
-
printStatic(' }');
|
470
|
+
Porffor.printStatic(' }');
|
472
471
|
};
|
473
472
|
|
474
473
|
export const __console_dir = (obj: any, options: any) => {
|
@@ -486,7 +485,7 @@ export const __console_dir = (obj: any, options: any) => {
|
|
486
485
|
|
487
486
|
__Porffor_consoleIndent();
|
488
487
|
__Porffor_dirObject(obj, colors, depth, showHidden);
|
489
|
-
printStatic('\n');
|
488
|
+
Porffor.printStatic('\n');
|
490
489
|
};
|
491
490
|
|
492
491
|
export const __console_dirxml = (obj: any) => __console_dir(obj);
|
@@ -499,9 +498,9 @@ export const __console_count = (label: any) => {
|
|
499
498
|
|
500
499
|
__Porffor_consoleIndent();
|
501
500
|
__Porffor_consolePrint(label);
|
502
|
-
printStatic(': ');
|
501
|
+
Porffor.printStatic(': ');
|
503
502
|
print(val);
|
504
|
-
printStatic('\n');
|
503
|
+
Porffor.printStatic('\n');
|
505
504
|
};
|
506
505
|
|
507
506
|
export const __console_countReset = (label: any) => {
|
@@ -516,9 +515,9 @@ export const __console_time = (label: any) => {
|
|
516
515
|
|
517
516
|
// warn if label already exists
|
518
517
|
if (timeMap.has(label)) {
|
519
|
-
printStatic("Warning: Timer '");
|
518
|
+
Porffor.printStatic("Warning: Timer '");
|
520
519
|
__Porffor_consolePrint(label);
|
521
|
-
printStatic("' already exists for console.time()\n");
|
520
|
+
Porffor.printStatic("' already exists for console.time()\n");
|
522
521
|
}
|
523
522
|
|
524
523
|
timeMap.set(label, performance.now());
|
@@ -530,17 +529,17 @@ export const __console_timeLog = (label: any) => {
|
|
530
529
|
|
531
530
|
const val = timeMap.get(label);
|
532
531
|
if (!val) {
|
533
|
-
printStatic("Timer '");
|
532
|
+
Porffor.printStatic("Timer '");
|
534
533
|
__Porffor_consolePrint(label);
|
535
|
-
printStatic("' does not exist\n");
|
534
|
+
Porffor.printStatic("' does not exist\n");
|
536
535
|
return;
|
537
536
|
}
|
538
537
|
|
539
538
|
__Porffor_consolePrint(label);
|
540
|
-
printStatic(': ');
|
539
|
+
Porffor.printStatic(': ');
|
541
540
|
|
542
541
|
print(performance.now() - val);
|
543
|
-
printStatic(' ms\n');
|
542
|
+
Porffor.printStatic(' ms\n');
|
544
543
|
};
|
545
544
|
|
546
545
|
export const __console_timeEnd = (label: any) => {
|