porffor 0.57.2 → 0.57.4
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 +0 -11
- package/compiler/builtins/error.js +32 -13
- package/compiler/builtins_precompiled.js +597 -468
- package/compiler/codegen.js +10 -16
- package/compiler/types.js +0 -1
- package/compiler/wrap.js +5 -4
- package/package.json +1 -1
- package/runtime/index.js +2 -1
package/compiler/codegen.js
CHANGED
@@ -10,19 +10,15 @@ import { log } from './log.js';
|
|
10
10
|
import { allocPage, allocStr } from './allocator.js';
|
11
11
|
import './prefs.js';
|
12
12
|
|
13
|
-
class TodoError extends Error {
|
14
|
-
constructor(message) {
|
15
|
-
super(message);
|
16
|
-
this.name = 'TodoError';
|
17
|
-
}
|
18
|
-
}
|
19
13
|
const todo = (scope, msg, expectsValue = undefined) => {
|
14
|
+
msg = `todo: ${msg}`;
|
15
|
+
|
20
16
|
switch (Prefs.todoTime ?? 'runtime') {
|
21
17
|
case 'compile':
|
22
|
-
throw new
|
18
|
+
throw new Error(msg);
|
23
19
|
|
24
20
|
case 'runtime':
|
25
|
-
return internalThrow(scope, '
|
21
|
+
return internalThrow(scope, 'Error', msg, expectsValue);
|
26
22
|
}
|
27
23
|
};
|
28
24
|
|
@@ -1801,10 +1797,9 @@ const generateLiteral = (scope, decl, global, name) => {
|
|
1801
1797
|
}
|
1802
1798
|
]
|
1803
1799
|
});
|
1804
|
-
|
1805
|
-
default:
|
1806
|
-
return todo(scope, `cannot generate literal of type ${typeof decl.value}`, true);
|
1807
1800
|
}
|
1801
|
+
|
1802
|
+
return todo(scope, `cannot generate literal of type ${typeof decl.value}`, true);
|
1808
1803
|
};
|
1809
1804
|
|
1810
1805
|
const generateExp = (scope, decl) => {
|
@@ -3594,7 +3589,7 @@ const coctcOffset = prop => {
|
|
3594
3589
|
if (typeof prop === 'object') {
|
3595
3590
|
if (
|
3596
3591
|
prop.computed || prop.optional ||
|
3597
|
-
['prototype', 'size', 'description', 'byteLength', 'byteOffset', 'buffer', 'detached', 'resizable', 'growable', 'maxByteLength', 'length', '__proto__'].includes(prop.property.name)
|
3592
|
+
['prototype', 'size', 'description', 'byteLength', 'byteOffset', 'buffer', 'detached', 'resizable', 'growable', 'maxByteLength', 'name', 'message', 'constructor', 'length', '__proto__'].includes(prop.property.name)
|
3598
3593
|
) return 0;
|
3599
3594
|
|
3600
3595
|
prop = prop.property.name;
|
@@ -4306,10 +4301,9 @@ const generateUnary = (scope, decl) => {
|
|
4306
4301
|
|
4307
4302
|
return out;
|
4308
4303
|
}
|
4309
|
-
|
4310
|
-
default:
|
4311
|
-
return todo(scope, `unary operator ${decl.operator} not implemented yet`, true);
|
4312
4304
|
}
|
4305
|
+
|
4306
|
+
return todo(scope, `unary operator ${decl.operator} not implemented yet`, true);
|
4313
4307
|
};
|
4314
4308
|
|
4315
4309
|
const generateUpdate = (scope, decl, _global, _name, valueUnused = false) => {
|
@@ -5815,7 +5809,7 @@ const generateMember = (scope, decl, _global, _name) => {
|
|
5815
5809
|
const known = knownType(scope, type);
|
5816
5810
|
|
5817
5811
|
// todo: generate this array procedurally during builtinFuncs creation
|
5818
|
-
if (['size', 'description', 'byteLength', 'byteOffset', 'buffer', 'detached', 'resizable', 'growable', 'maxByteLength'].includes(decl.property.name)) {
|
5812
|
+
if (['size', 'description', 'byteLength', 'byteOffset', 'buffer', 'detached', 'resizable', 'growable', 'maxByteLength', 'name', 'message', 'constructor'].includes(decl.property.name)) {
|
5819
5813
|
// todo: support optional
|
5820
5814
|
const bc = {};
|
5821
5815
|
const cands = Object.keys(builtinFuncs).filter(x => x.startsWith('__') && x.endsWith('_prototype_' + decl.property.name + '$get'));
|
package/compiler/types.js
CHANGED
@@ -72,7 +72,6 @@ registerInternalType('StringObject');
|
|
72
72
|
registerInternalType('__Porffor_Generator');
|
73
73
|
registerInternalType('__Porffor_AsyncGenerator');
|
74
74
|
|
75
|
-
// from here, remapped object types only
|
76
75
|
for (const x of [ '', 'Aggregate', 'Type', 'Reference', 'Syntax', 'Range', 'Eval', 'URI', 'Test262' ])
|
77
76
|
registerInternalType(`${x}Error`);
|
78
77
|
|
package/compiler/wrap.js
CHANGED
@@ -313,11 +313,12 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
313
313
|
case TYPES.evalerror:
|
314
314
|
case TYPES.urierror:
|
315
315
|
case TYPES.test262error: {
|
316
|
-
const
|
317
|
-
const
|
316
|
+
const message = porfToJSValue({ memory, funcs, pages }, read(Uint32Array, memory, value, 1)[0], read(Uint8Array, memory, value + 4, 1)[0]);
|
317
|
+
const name = TYPE_NAMES[type];
|
318
|
+
const err = new (globalThis[name] ?? Error)(message);
|
318
319
|
|
319
|
-
err.name =
|
320
|
-
err.stack = `${
|
320
|
+
err.name = name;
|
321
|
+
err.stack = `${name}: ${message}`;
|
321
322
|
return err;
|
322
323
|
}
|
323
324
|
|
package/package.json
CHANGED
package/runtime/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import fs from 'node:fs';
|
3
|
-
globalThis.version = '0.57.
|
3
|
+
globalThis.version = '0.57.4';
|
4
4
|
|
5
5
|
// deno compat
|
6
6
|
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
|
@@ -208,6 +208,7 @@ try {
|
|
208
208
|
let out = e;
|
209
209
|
if (!process.argv.includes('-d') && Object.getPrototypeOf(e).message != null) out = `${e.name}${e.message != null ? `: ${e.message}` : ''}`;
|
210
210
|
console.error(out);
|
211
|
+
process.exit(1);
|
211
212
|
}
|
212
213
|
|
213
214
|
if (process.argv.includes('-t')) console.log(`${process.argv.includes('-b') ? '' : '\n'}total time: ${(performance.now() - start).toFixed(2)}ms\nexecution time: ${(performance.now() - runStart).toFixed(2)}ms`);
|