porffor 0.36.4 → 0.36.6
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 +56 -18
- package/compiler/builtins/_internal_object.ts +15 -14
- package/compiler/builtins/object.ts +65 -32
- package/compiler/builtins/reflect.ts +18 -10
- package/compiler/builtins_objects.js +2 -2
- package/compiler/builtins_precompiled.js +78 -72
- package/compiler/codegen.js +40 -99
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -2676,7 +2676,7 @@ const typeSwitch = (scope, type, bc, returns = valtypeBinary, allowFallThrough =
|
|
2676
2676
|
}
|
2677
2677
|
|
2678
2678
|
if (Prefs.typeswitchBrtable) {
|
2679
|
-
if (allowFallThrough) throw new Error(`Fallthrough is not currently supported with --typeswitch-brtable`)
|
2679
|
+
if (allowFallThrough) throw new Error(`Fallthrough is not currently supported with --typeswitch-brtable`);
|
2680
2680
|
return brTable(type, bc, returns);
|
2681
2681
|
}
|
2682
2682
|
|
@@ -3288,68 +3288,6 @@ const generateAssign = (scope, decl, _global, _name, valueUnused = false) => {
|
|
3288
3288
|
[ Opcodes.local_get, newValueTmp ]
|
3289
3289
|
],
|
3290
3290
|
|
3291
|
-
[TYPES.object]: [
|
3292
|
-
...objectWasm,
|
3293
|
-
Opcodes.i32_to_u,
|
3294
|
-
...(op === '=' ? [] : [ [ Opcodes.local_tee, localTmp(scope, '#objset_object', Valtype.i32) ] ]),
|
3295
|
-
...getNodeType(scope, object),
|
3296
|
-
|
3297
|
-
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.left.computed, op === '='),
|
3298
|
-
...(op === '=' ? [] : [ [ Opcodes.local_set, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3299
|
-
...(op === '=' ? [] : [
|
3300
|
-
Opcodes.i32_to_u,
|
3301
|
-
[ Opcodes.local_tee, localTmp(scope, '#objset_property', Valtype.i32) ]
|
3302
|
-
]),
|
3303
|
-
...(op === '=' ? [] : [ [ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3304
|
-
|
3305
|
-
...(op === '=' ? generate(scope, decl.right) : performOp(scope, op, [
|
3306
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_object', Valtype.i32) ],
|
3307
|
-
...getNodeType(scope, object),
|
3308
|
-
|
3309
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_property', Valtype.i32) ],
|
3310
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ],
|
3311
|
-
|
3312
|
-
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
3313
|
-
...setLastType(scope)
|
3314
|
-
], generate(scope, decl.right), getLastType(scope), getNodeType(scope, decl.right), false, name, true)),
|
3315
|
-
...getNodeType(scope, decl),
|
3316
|
-
|
3317
|
-
[ Opcodes.call, includeBuiltin(scope, scope.strict ? '__Porffor_object_setStrict' : '__Porffor_object_set').index ],
|
3318
|
-
[ Opcodes.drop ],
|
3319
|
-
// ...setLastType(scope, getNodeType(scope, decl)),
|
3320
|
-
],
|
3321
|
-
|
3322
|
-
[TYPES.function]: [
|
3323
|
-
...objectWasm,
|
3324
|
-
Opcodes.i32_to_u,
|
3325
|
-
...(op === '=' ? [] : [ [ Opcodes.local_tee, localTmp(scope, '#objset_object', Valtype.i32) ] ]),
|
3326
|
-
...getNodeType(scope, object),
|
3327
|
-
|
3328
|
-
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.left.computed, op === '='),
|
3329
|
-
...(op === '=' ? [] : [ [ Opcodes.local_set, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3330
|
-
...(op === '=' ? [] : [
|
3331
|
-
Opcodes.i32_to_u,
|
3332
|
-
[ Opcodes.local_tee, localTmp(scope, '#objset_property', Valtype.i32) ]
|
3333
|
-
]),
|
3334
|
-
...(op === '=' ? [] : [ [ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3335
|
-
|
3336
|
-
...(op === '=' ? generate(scope, decl.right) : performOp(scope, op, [
|
3337
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_object', Valtype.i32) ],
|
3338
|
-
...getNodeType(scope, object),
|
3339
|
-
|
3340
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_property', Valtype.i32) ],
|
3341
|
-
[ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ],
|
3342
|
-
|
3343
|
-
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
3344
|
-
...setLastType(scope)
|
3345
|
-
], generate(scope, decl.right), getLastType(scope), getNodeType(scope, decl.right), false, name, true)),
|
3346
|
-
...getNodeType(scope, decl),
|
3347
|
-
|
3348
|
-
[ Opcodes.call, includeBuiltin(scope, scope.strict ? '__Porffor_object_setStrict' : '__Porffor_object_set').index ],
|
3349
|
-
[ Opcodes.drop ],
|
3350
|
-
// ...setLastType(scope, getNodeType(scope, decl)),
|
3351
|
-
],
|
3352
|
-
|
3353
3291
|
...wrapBC({
|
3354
3292
|
[TYPES.uint8array]: [
|
3355
3293
|
[ Opcodes.i32_add ],
|
@@ -3511,12 +3449,33 @@ const generateAssign = (scope, decl, _global, _name, valueUnused = false) => {
|
|
3511
3449
|
// default: internalThrow(scope, 'TypeError', `Cannot assign member with this type`)
|
3512
3450
|
default: [
|
3513
3451
|
...objectWasm,
|
3514
|
-
|
3452
|
+
Opcodes.i32_to_u,
|
3453
|
+
...(op === '=' ? [] : [ [ Opcodes.local_tee, localTmp(scope, '#objset_object', Valtype.i32) ] ]),
|
3454
|
+
...getNodeType(scope, object),
|
3515
3455
|
|
3516
|
-
...propertyWasm,
|
3517
|
-
[ Opcodes.
|
3456
|
+
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.left.computed, op === '='),
|
3457
|
+
...(op === '=' ? [] : [ [ Opcodes.local_set, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3458
|
+
...(op === '=' ? [] : [
|
3459
|
+
Opcodes.i32_to_u,
|
3460
|
+
[ Opcodes.local_tee, localTmp(scope, '#objset_property', Valtype.i32) ]
|
3461
|
+
]),
|
3462
|
+
...(op === '=' ? [] : [ [ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ] ]),
|
3463
|
+
|
3464
|
+
...(op === '=' ? generate(scope, decl.right) : performOp(scope, op, [
|
3465
|
+
[ Opcodes.local_get, localTmp(scope, '#objset_object', Valtype.i32) ],
|
3466
|
+
...getNodeType(scope, object),
|
3467
|
+
|
3468
|
+
[ Opcodes.local_get, localTmp(scope, '#objset_property', Valtype.i32) ],
|
3469
|
+
[ Opcodes.local_get, localTmp(scope, '#objset_property_type', Valtype.i32) ],
|
3518
3470
|
|
3519
|
-
|
3471
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
3472
|
+
...setLastType(scope)
|
3473
|
+
], generate(scope, decl.right), getLastType(scope), getNodeType(scope, decl.right), false, name, true)),
|
3474
|
+
...getNodeType(scope, decl),
|
3475
|
+
|
3476
|
+
[ Opcodes.call, includeBuiltin(scope, scope.strict ? '__Porffor_object_setStrict' : '__Porffor_object_set').index ],
|
3477
|
+
[ Opcodes.drop ],
|
3478
|
+
// ...setLastType(scope, getNodeType(scope, decl)),
|
3520
3479
|
]
|
3521
3480
|
}, valtypeBinary)
|
3522
3481
|
];
|
@@ -5406,28 +5365,6 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5406
5365
|
...setLastType(scope, TYPES.bytestring)
|
5407
5366
|
],
|
5408
5367
|
|
5409
|
-
[TYPES.object]: [
|
5410
|
-
...objectWasm,
|
5411
|
-
Opcodes.i32_to_u,
|
5412
|
-
...getNodeType(scope, object),
|
5413
|
-
|
5414
|
-
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.computed, true),
|
5415
|
-
|
5416
|
-
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
5417
|
-
...setLastType(scope)
|
5418
|
-
],
|
5419
|
-
|
5420
|
-
[TYPES.function]: [
|
5421
|
-
...objectWasm,
|
5422
|
-
Opcodes.i32_to_u,
|
5423
|
-
...getNodeType(scope, object),
|
5424
|
-
|
5425
|
-
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.computed, true),
|
5426
|
-
|
5427
|
-
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
5428
|
-
...setLastType(scope)
|
5429
|
-
],
|
5430
|
-
|
5431
5368
|
...wrapBC({
|
5432
5369
|
[TYPES.uint8array]: [
|
5433
5370
|
[ Opcodes.i32_add ],
|
@@ -5510,8 +5447,14 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5510
5447
|
|
5511
5448
|
// default: internalThrow(scope, 'TypeError', 'Unsupported member expression object', true)
|
5512
5449
|
default: [
|
5513
|
-
...
|
5514
|
-
|
5450
|
+
...objectWasm,
|
5451
|
+
Opcodes.i32_to_u,
|
5452
|
+
...getNodeType(scope, object),
|
5453
|
+
|
5454
|
+
...toPropertyKey(scope, propertyWasm, getNodeType(scope, property), decl.computed, true),
|
5455
|
+
|
5456
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_object_get').index ],
|
5457
|
+
...setLastType(scope)
|
5515
5458
|
],
|
5516
5459
|
|
5517
5460
|
...extraBC
|
@@ -5603,7 +5546,7 @@ const generateClass = (scope, decl) => {
|
|
5603
5546
|
optional: false
|
5604
5547
|
};
|
5605
5548
|
|
5606
|
-
const
|
5549
|
+
const [ func, out ] = generateFunc(scope, {
|
5607
5550
|
...(body.find(x => x.kind === 'constructor')?.value ?? {
|
5608
5551
|
type: 'FunctionExpression',
|
5609
5552
|
params: [],
|
@@ -5612,12 +5555,9 @@ const generateClass = (scope, decl) => {
|
|
5612
5555
|
body: []
|
5613
5556
|
}
|
5614
5557
|
}),
|
5615
|
-
id: root
|
5616
|
-
};
|
5617
|
-
|
5618
|
-
const [ func, out ] = generateFunc(scope, {
|
5619
|
-
...constr,
|
5558
|
+
id: root,
|
5620
5559
|
_onlyConstr: true,
|
5560
|
+
strict: true,
|
5621
5561
|
type: expr ? 'FunctionExpression' : 'FunctionDeclaration'
|
5622
5562
|
});
|
5623
5563
|
|
@@ -5663,7 +5603,7 @@ const generateClass = (scope, decl) => {
|
|
5663
5603
|
outScope = func;
|
5664
5604
|
}
|
5665
5605
|
|
5666
|
-
if (isFuncType(value.type)
|
5606
|
+
if (isFuncType(value.type)) {
|
5667
5607
|
let id = value.id;
|
5668
5608
|
|
5669
5609
|
// todo: support computed names properly
|
@@ -5675,6 +5615,7 @@ const generateClass = (scope, decl) => {
|
|
5675
5615
|
value = {
|
5676
5616
|
...value,
|
5677
5617
|
id,
|
5618
|
+
strict: true,
|
5678
5619
|
_onlyThisMethod: true
|
5679
5620
|
};
|
5680
5621
|
}
|
@@ -5837,7 +5778,7 @@ const generateFunc = (scope, decl, outUnused = false) => {
|
|
5837
5778
|
// not async or generator
|
5838
5779
|
!decl.async && !decl.generator,
|
5839
5780
|
_onlyConstr: decl._onlyConstr, _onlyThisMethod: decl._onlyThisMethod,
|
5840
|
-
strict: scope.strict,
|
5781
|
+
strict: scope.strict || decl.strict,
|
5841
5782
|
|
5842
5783
|
generate() {
|
5843
5784
|
if (func.wasm) return func.wasm;
|
package/package.json
CHANGED