porffor 0.57.3 → 0.57.5
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.js +28 -0
- package/compiler/builtins_precompiled.js +597 -468
- package/compiler/codegen.js +11 -17
- package/compiler/types.js +0 -1
- package/compiler/wrap.js +7 -12
- package/package.json +1 -1
- package/runtime/index.js +1 -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
|
|
@@ -1284,7 +1280,7 @@ const asmFuncToAsm = (scope, func, extra) => func(scope, {
|
|
1284
1280
|
scope.initedGlobals ??= new Set();
|
1285
1281
|
if (!scope.initedGlobals.has(name)) {
|
1286
1282
|
scope.initedGlobals.add(name);
|
1287
|
-
if (scope.globalInits[name]) out.unshift(
|
1283
|
+
if (scope.globalInits?.[name]) out.unshift(
|
1288
1284
|
[ Opcodes.global_get, globals[globalName + '#glbl_inited'].idx ],
|
1289
1285
|
[ Opcodes.i32_eqz ],
|
1290
1286
|
[ Opcodes.if, Blocktype.void ],
|
@@ -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
@@ -179,14 +179,8 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
179
179
|
}
|
180
180
|
|
181
181
|
case TYPES.symbol: {
|
182
|
-
const
|
183
|
-
|
184
|
-
|
185
|
-
const descStore = page * pageSize;
|
186
|
-
const offset = descStore + 4 + ((value - 1) * 9);
|
187
|
-
|
188
|
-
const v = read(Float64Array, memory, offset, 1)[0];
|
189
|
-
const t = read(Uint8Array, memory, offset + 8, 1)[0];
|
182
|
+
const v = read(Float64Array, memory, value, 1)[0];
|
183
|
+
const t = read(Uint8Array, memory, value + 8, 1)[0];
|
190
184
|
|
191
185
|
const desc = porfToJSValue({ memory, funcs, pages }, v, t);
|
192
186
|
return Symbol(desc);
|
@@ -313,11 +307,12 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
313
307
|
case TYPES.evalerror:
|
314
308
|
case TYPES.urierror:
|
315
309
|
case TYPES.test262error: {
|
316
|
-
const
|
317
|
-
const
|
310
|
+
const message = porfToJSValue({ memory, funcs, pages }, read(Uint32Array, memory, value, 1)[0], read(Uint8Array, memory, value + 4, 1)[0]);
|
311
|
+
const name = TYPE_NAMES[type];
|
312
|
+
const err = new (globalThis[name] ?? Error)(message);
|
318
313
|
|
319
|
-
err.name =
|
320
|
-
err.stack = `${
|
314
|
+
err.name = name;
|
315
|
+
err.stack = `${name}: ${message}`;
|
321
316
|
return err;
|
322
317
|
}
|
323
318
|
|
package/package.json
CHANGED