porffor 0.60.21 → 0.60.23
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/bun.lock +5 -2
- package/compiler/builtins_precompiled.js +353 -353
- package/compiler/codegen.js +92 -123
- package/compiler/cyclone.js +1 -0
- package/compiler/parse.js +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -611,8 +611,8 @@ const lookup = (scope, name, failEarly = false) => {
|
|
611
611
|
return wasm.slice();
|
612
612
|
}
|
613
613
|
|
614
|
-
if (
|
615
|
-
includeBuiltin(scope, name);
|
614
|
+
if (name in builtinFuncs) {
|
615
|
+
if (!(name in funcIndex)) includeBuiltin(scope, name);
|
616
616
|
} else if (name in internalConstrs) {
|
617
617
|
// todo: return an actual something
|
618
618
|
return [ number(1) ];
|
@@ -882,7 +882,7 @@ const generateReturn = (scope, decl) => {
|
|
882
882
|
};
|
883
883
|
|
884
884
|
const localTmp = (scope, name, type = valtypeBinary) => {
|
885
|
-
if (scope.locals
|
885
|
+
if (name in scope.locals) return scope.locals[name].idx;
|
886
886
|
|
887
887
|
let idx = scope.localInd++;
|
888
888
|
scope.locals[name] = { idx, type };
|
@@ -1198,6 +1198,22 @@ const nullish = (scope, wasm, type, nonbinary = true, intIn = false) => {
|
|
1198
1198
|
];
|
1199
1199
|
};
|
1200
1200
|
|
1201
|
+
const eitherStringType = (leftType, rightType) => [
|
1202
|
+
...leftType,
|
1203
|
+
number(TYPE_FLAGS.parity, Valtype.i32),
|
1204
|
+
[ Opcodes.i32_or ],
|
1205
|
+
number(TYPES.bytestring, Valtype.i32),
|
1206
|
+
[ Opcodes.i32_eq ],
|
1207
|
+
|
1208
|
+
...rightType,
|
1209
|
+
number(TYPE_FLAGS.parity, Valtype.i32),
|
1210
|
+
[ Opcodes.i32_or ],
|
1211
|
+
number(TYPES.bytestring, Valtype.i32),
|
1212
|
+
[ Opcodes.i32_eq ],
|
1213
|
+
|
1214
|
+
[ Opcodes.i32_or ]
|
1215
|
+
];
|
1216
|
+
|
1201
1217
|
const performOp = (scope, op, left, right, leftType, rightType) => {
|
1202
1218
|
if (op === '||' || op === '&&' || op === '??') {
|
1203
1219
|
return performLogicOp(scope, op, left, right, leftType, rightType);
|
@@ -1294,19 +1310,7 @@ const performOp = (scope, op, left, right, leftType, rightType) => {
|
|
1294
1310
|
|
1295
1311
|
ops.unshift(
|
1296
1312
|
// if left or right are string or bytestring
|
1297
|
-
...leftType,
|
1298
|
-
number(TYPE_FLAGS.parity, Valtype.i32),
|
1299
|
-
[ Opcodes.i32_or ],
|
1300
|
-
number(TYPES.bytestring, Valtype.i32),
|
1301
|
-
[ Opcodes.i32_eq ],
|
1302
|
-
|
1303
|
-
...rightType,
|
1304
|
-
number(TYPE_FLAGS.parity, Valtype.i32),
|
1305
|
-
[ Opcodes.i32_or ],
|
1306
|
-
number(TYPES.bytestring, Valtype.i32),
|
1307
|
-
[ Opcodes.i32_eq ],
|
1308
|
-
|
1309
|
-
[ Opcodes.i32_or ],
|
1313
|
+
...eitherStringType(leftType, rightType),
|
1310
1314
|
[ Opcodes.if, Blocktype.void ],
|
1311
1315
|
...concatStrings(scope, [ [ Opcodes.local_get, tmpLeft ] ], [ [ Opcodes.local_get, tmpRight ] ], leftType, rightType),
|
1312
1316
|
[ Opcodes.br, 1 ],
|
@@ -1326,19 +1330,7 @@ const performOp = (scope, op, left, right, leftType, rightType) => {
|
|
1326
1330
|
|
1327
1331
|
ops.unshift(
|
1328
1332
|
// if left or right are string or bytestring
|
1329
|
-
...leftType,
|
1330
|
-
number(TYPE_FLAGS.parity, Valtype.i32),
|
1331
|
-
[ Opcodes.i32_or ],
|
1332
|
-
number(TYPES.bytestring, Valtype.i32),
|
1333
|
-
[ Opcodes.i32_eq ],
|
1334
|
-
|
1335
|
-
...rightType,
|
1336
|
-
number(TYPE_FLAGS.parity, Valtype.i32),
|
1337
|
-
[ Opcodes.i32_or ],
|
1338
|
-
number(TYPES.bytestring, Valtype.i32),
|
1339
|
-
[ Opcodes.i32_eq ],
|
1340
|
-
|
1341
|
-
[ Opcodes.i32_or ],
|
1333
|
+
...eitherStringType(leftType, rightType),
|
1342
1334
|
[ Opcodes.if, Blocktype.void ],
|
1343
1335
|
...compareStrings(scope, [ [ Opcodes.local_get, tmpLeft ] ], [ [ Opcodes.local_get, tmpRight ] ], leftType, rightType),
|
1344
1336
|
...(op === '!==' || op === '!=' ? [ [ Opcodes.i32_eqz ] ] : []),
|
@@ -1599,11 +1591,11 @@ const generateLogicExp = (scope, decl) =>
|
|
1599
1591
|
const getInferred = (scope, name, global = false) => {
|
1600
1592
|
const isConst = getVarMetadata(scope, name, global)?.kind === 'const';
|
1601
1593
|
if (global) {
|
1602
|
-
if (
|
1594
|
+
if (name in globalInfer && (isConst || inferLoopPrev.length === 0)) return globalInfer[name];
|
1603
1595
|
} else if (scope.inferTree) {
|
1604
1596
|
for (let i = scope.inferTree.length - 1; i >= 0; i--) {
|
1605
1597
|
const x = scope.inferTree[i];
|
1606
|
-
if (x
|
1598
|
+
if (name in x) return x[name];
|
1607
1599
|
}
|
1608
1600
|
}
|
1609
1601
|
|
@@ -1612,21 +1604,20 @@ const getInferred = (scope, name, global = false) => {
|
|
1612
1604
|
|
1613
1605
|
const setInferred = (scope, name, type, global = false) => {
|
1614
1606
|
const isConst = getVarMetadata(scope, name, global)?.kind === 'const';
|
1615
|
-
scope.inferTree ??= [];
|
1607
|
+
scope.inferTree ??= [ Object.create(null) ];
|
1616
1608
|
|
1617
1609
|
if (global) {
|
1618
1610
|
// set inferred type in global if not already and not in a loop, else make it null
|
1619
|
-
globalInfer
|
1611
|
+
globalInfer[name] = name in globalInfer || (!isConst && inferLoopPrev.length > 0) ? null : type;
|
1620
1612
|
} else {
|
1621
1613
|
// set inferred type in top
|
1622
1614
|
const top = scope.inferTree.at(-1);
|
1623
|
-
top
|
1624
|
-
top._infer.set(name, type);
|
1615
|
+
top[name] = type;
|
1625
1616
|
|
1626
1617
|
// invalidate inferred type above if mismatched
|
1627
1618
|
for (let i = scope.inferTree.length - 2; i >= 0; i--) {
|
1628
1619
|
const x = scope.inferTree[i];
|
1629
|
-
if (x
|
1620
|
+
if (name in x && x[name] !== type) x[name] = null;
|
1630
1621
|
}
|
1631
1622
|
}
|
1632
1623
|
};
|
@@ -2051,31 +2042,6 @@ const generateChain = (scope, decl) => {
|
|
2051
2042
|
return out;
|
2052
2043
|
};
|
2053
2044
|
|
2054
|
-
const ArrayUtil = {
|
2055
|
-
getLengthI32: pointer => [
|
2056
|
-
...pointer,
|
2057
|
-
[ Opcodes.i32_load, Math.log2(ValtypeSize.i32) - 1, 0 ]
|
2058
|
-
],
|
2059
|
-
|
2060
|
-
getLength: pointer => [
|
2061
|
-
...pointer,
|
2062
|
-
[ Opcodes.i32_load, Math.log2(ValtypeSize.i32) - 1, 0 ],
|
2063
|
-
Opcodes.i32_from_u
|
2064
|
-
],
|
2065
|
-
|
2066
|
-
setLengthI32: (pointer, value) => [
|
2067
|
-
...pointer,
|
2068
|
-
...value,
|
2069
|
-
[ Opcodes.i32_store, Math.log2(ValtypeSize.i32) - 1, 0 ]
|
2070
|
-
],
|
2071
|
-
|
2072
|
-
setLength: (pointer, value) => [
|
2073
|
-
...pointer,
|
2074
|
-
...value,
|
2075
|
-
Opcodes.i32_to_u,
|
2076
|
-
[ Opcodes.i32_store, Math.log2(ValtypeSize.i32) - 1, 0 ]
|
2077
|
-
]
|
2078
|
-
};
|
2079
2045
|
|
2080
2046
|
const createNewTarget = (scope, decl, idx = 0, force = false) => {
|
2081
2047
|
if (decl._new || force) {
|
@@ -2824,16 +2790,6 @@ const DEFAULT_VALUE = () => ({
|
|
2824
2790
|
name: 'undefined'
|
2825
2791
|
});
|
2826
2792
|
|
2827
|
-
const codeToSanitizedStr = code => {
|
2828
|
-
let out = '';
|
2829
|
-
while (code > 0) {
|
2830
|
-
out += String.fromCharCode(97 + code % 26);
|
2831
|
-
code -= 26;
|
2832
|
-
}
|
2833
|
-
return out;
|
2834
|
-
};
|
2835
|
-
const sanitize = str => str.replace(/[^0-9a-zA-Z_]/g, _ => codeToSanitizedStr(_.charCodeAt(0)));
|
2836
|
-
|
2837
2793
|
const unhackName = name => {
|
2838
2794
|
if (!name) return name;
|
2839
2795
|
|
@@ -3015,6 +2971,34 @@ const typeSwitch = (scope, type, bc, returns = valtypeBinary, fallthrough = fals
|
|
3015
2971
|
return typeof def === 'function' ? def() : def;
|
3016
2972
|
}
|
3017
2973
|
|
2974
|
+
if (bc.length === 2 && (bc[0][0] === 'default' || bc[1][0] === 'default')) {
|
2975
|
+
let trueCase, falseCase;
|
2976
|
+
if (bc[0][0] === 'default') {
|
2977
|
+
trueCase = bc[1];
|
2978
|
+
falseCase = bc[0];
|
2979
|
+
} else {
|
2980
|
+
trueCase = bc[0];
|
2981
|
+
falseCase = bc[1];
|
2982
|
+
}
|
2983
|
+
|
2984
|
+
if (!Array.isArray(trueCase[0])) {
|
2985
|
+
depth.push('if');
|
2986
|
+
const out = [
|
2987
|
+
...type,
|
2988
|
+
number(trueCase[0], Valtype.i32),
|
2989
|
+
[ Opcodes.i32_eq ],
|
2990
|
+
[ Opcodes.if, returns ],
|
2991
|
+
...typeof trueCase[1] === 'function' ? trueCase[1]() : trueCase[1],
|
2992
|
+
[ Opcodes.else ],
|
2993
|
+
...typeof falseCase[1] === 'function' ? falseCase[1]() : falseCase[1],
|
2994
|
+
[ Opcodes.end ],
|
2995
|
+
];
|
2996
|
+
depth.pop();
|
2997
|
+
|
2998
|
+
return out;
|
2999
|
+
}
|
3000
|
+
}
|
3001
|
+
|
3018
3002
|
if (Prefs.typeswitchBrtable) {
|
3019
3003
|
if (fallthrough) throw new Error(`Fallthrough is not currently supported with --typeswitch-brtable`);
|
3020
3004
|
return brTable(type, bc, returns);
|
@@ -3131,7 +3115,7 @@ const typeIsNotOneOf = (type, types, valtype = Valtype.i32) => {
|
|
3131
3115
|
return out;
|
3132
3116
|
};
|
3133
3117
|
|
3134
|
-
const allocVar = (scope, name, global = false, type = true,
|
3118
|
+
const allocVar = (scope, name, global = false, type = true, i32 = false, redecl = false) => {
|
3135
3119
|
const target = global ? globals : scope.locals;
|
3136
3120
|
|
3137
3121
|
// already declared
|
@@ -3271,8 +3255,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3271
3255
|
try {
|
3272
3256
|
let usedNames = [];
|
3273
3257
|
for (const x of pattern.properties) {
|
3274
|
-
|
3275
|
-
usedNames.push(name);
|
3258
|
+
usedNames.push(x.key.name);
|
3276
3259
|
}
|
3277
3260
|
|
3278
3261
|
let path = init.arguments[0].value;
|
@@ -3299,7 +3282,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3299
3282
|
|
3300
3283
|
// mock ffi function
|
3301
3284
|
asmFunc(name, {
|
3302
|
-
wasm: [],
|
3285
|
+
wasm: () => [],
|
3303
3286
|
params: parameters.map(x => Valtype.i32),
|
3304
3287
|
returns: result ? [ Valtype.i32 ] : [],
|
3305
3288
|
returnType: TYPES.number
|
@@ -4495,27 +4478,26 @@ const generateUpdate = (scope, decl, _global, _name, valueUnused = false) => {
|
|
4495
4478
|
];
|
4496
4479
|
};
|
4497
4480
|
|
4498
|
-
const inferBranchStart =
|
4499
|
-
scope.inferTree ??= [];
|
4500
|
-
scope.inferTree.push(
|
4481
|
+
const inferBranchStart = scope => {
|
4482
|
+
scope.inferTree ??= [ Object.create(null) ];
|
4483
|
+
scope.inferTree.push(Object.create(null));
|
4501
4484
|
};
|
4502
4485
|
|
4503
4486
|
const inferBranchEnd = scope => {
|
4504
4487
|
scope.inferTree.pop();
|
4505
4488
|
};
|
4506
4489
|
|
4507
|
-
const inferBranchElse =
|
4490
|
+
const inferBranchElse = scope => {
|
4491
|
+
// todo/opt: at end of else, find inferences in common and keep them?
|
4508
4492
|
inferBranchEnd(scope);
|
4509
|
-
inferBranchStart(scope
|
4493
|
+
inferBranchStart(scope);
|
4510
4494
|
};
|
4511
4495
|
|
4512
4496
|
const inferLoopPrev = [];
|
4513
|
-
const inferLoopStart =
|
4514
|
-
scope.inferTree ??= [];
|
4515
|
-
|
4497
|
+
const inferLoopStart = scope => {
|
4516
4498
|
// todo/opt: do not just wipe the infer tree for loops
|
4517
|
-
inferLoopPrev.push(scope.inferTree);
|
4518
|
-
scope.inferTree = [
|
4499
|
+
inferLoopPrev.push(scope.inferTree ?? [ Object.create(null) ]);
|
4500
|
+
scope.inferTree = [ Object.create(null) ];
|
4519
4501
|
};
|
4520
4502
|
|
4521
4503
|
const inferLoopEnd = scope => {
|
@@ -4534,23 +4516,23 @@ const generateIf = (scope, decl) => {
|
|
4534
4516
|
const out = truthy(scope, generate(scope, decl.test), getNodeType(scope, decl.test));
|
4535
4517
|
out.push([ Opcodes.if, Blocktype.void ]);
|
4536
4518
|
depth.push('if');
|
4537
|
-
inferBranchStart(scope
|
4519
|
+
inferBranchStart(scope);
|
4538
4520
|
|
4539
4521
|
out.push(
|
4540
4522
|
...generate(scope, decl.consequent),
|
4541
4523
|
[ Opcodes.drop ]
|
4542
4524
|
);
|
4543
4525
|
|
4544
|
-
|
4526
|
+
|
4545
4527
|
if (decl.alternate) {
|
4546
|
-
|
4528
|
+
inferBranchElse(scope);
|
4547
4529
|
out.push(
|
4548
4530
|
[ Opcodes.else ],
|
4549
4531
|
...generate(scope, decl.alternate),
|
4550
4532
|
[ Opcodes.drop ]
|
4551
4533
|
);
|
4552
4534
|
inferBranchEnd(scope);
|
4553
|
-
}
|
4535
|
+
} else inferBranchEnd(scope);
|
4554
4536
|
|
4555
4537
|
out.push(
|
4556
4538
|
[ Opcodes.end ],
|
@@ -4566,7 +4548,7 @@ const generateConditional = (scope, decl) => {
|
|
4566
4548
|
|
4567
4549
|
out.push([ Opcodes.if, valtypeBinary ]);
|
4568
4550
|
depth.push('if');
|
4569
|
-
inferBranchStart(scope
|
4551
|
+
inferBranchStart(scope);
|
4570
4552
|
|
4571
4553
|
out.push(
|
4572
4554
|
...generate(scope, decl.consequent),
|
@@ -4574,7 +4556,7 @@ const generateConditional = (scope, decl) => {
|
|
4574
4556
|
);
|
4575
4557
|
|
4576
4558
|
out.push([ Opcodes.else ]);
|
4577
|
-
inferBranchElse(scope
|
4559
|
+
inferBranchElse(scope);
|
4578
4560
|
|
4579
4561
|
out.push(
|
4580
4562
|
...generate(scope, decl.alternate),
|
@@ -4596,7 +4578,7 @@ const generateFor = (scope, decl) => {
|
|
4596
4578
|
[ Opcodes.drop ]
|
4597
4579
|
);
|
4598
4580
|
|
4599
|
-
inferLoopStart(scope
|
4581
|
+
inferLoopStart(scope);
|
4600
4582
|
out.push([ Opcodes.loop, Blocktype.void ]);
|
4601
4583
|
depth.push('for');
|
4602
4584
|
|
@@ -4635,7 +4617,7 @@ const generateFor = (scope, decl) => {
|
|
4635
4617
|
|
4636
4618
|
const generateWhile = (scope, decl) => {
|
4637
4619
|
const out = [];
|
4638
|
-
inferLoopStart(scope
|
4620
|
+
inferLoopStart(scope);
|
4639
4621
|
|
4640
4622
|
out.push([ Opcodes.loop, Blocktype.void ]);
|
4641
4623
|
depth.push('while');
|
@@ -4663,7 +4645,7 @@ const generateWhile = (scope, decl) => {
|
|
4663
4645
|
|
4664
4646
|
const generateDoWhile = (scope, decl) => {
|
4665
4647
|
const out = [];
|
4666
|
-
inferLoopStart(scope
|
4648
|
+
inferLoopStart(scope);
|
4667
4649
|
|
4668
4650
|
out.push([ Opcodes.loop, Blocktype.void ]);
|
4669
4651
|
|
@@ -4736,7 +4718,7 @@ const generateForOf = (scope, decl) => {
|
|
4736
4718
|
[ Opcodes.local_set, length ]
|
4737
4719
|
);
|
4738
4720
|
|
4739
|
-
inferLoopStart(scope
|
4721
|
+
inferLoopStart(scope);
|
4740
4722
|
depth.push('forof');
|
4741
4723
|
depth.push('block');
|
4742
4724
|
|
@@ -5076,7 +5058,7 @@ const generateForIn = (scope, decl) => {
|
|
5076
5058
|
[ Opcodes.if, Blocktype.void ]
|
5077
5059
|
);
|
5078
5060
|
|
5079
|
-
inferLoopStart(scope
|
5061
|
+
inferLoopStart(scope);
|
5080
5062
|
depth.push('if');
|
5081
5063
|
depth.push('forin');
|
5082
5064
|
depth.push('block');
|
@@ -6457,7 +6439,7 @@ const generateClass = (scope, decl) => {
|
|
6457
6439
|
// define in construction instead
|
6458
6440
|
if (computed) {
|
6459
6441
|
// compute key now, reference in construction
|
6460
|
-
const computedTmp = allocVar(scope, `#class_computed_prop${uniqId()}`, true, true,
|
6442
|
+
const computedTmp = allocVar(scope, `#class_computed_prop${uniqId()}`, true, true, true);
|
6461
6443
|
|
6462
6444
|
out.push(
|
6463
6445
|
...toPropertyKey(scope, generate(scope, key), getNodeType(scope, key), computed, true),
|
@@ -6801,7 +6783,6 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
6801
6783
|
async: decl.async,
|
6802
6784
|
subclass: decl._subclass, _onlyConstr: decl._onlyConstr, _onlyThisMethod: decl._onlyThisMethod,
|
6803
6785
|
strict: scope.strict || decl.strict,
|
6804
|
-
inferTree: [ decl ],
|
6805
6786
|
|
6806
6787
|
generate() {
|
6807
6788
|
if (func.wasm) return func.wasm;
|
@@ -6847,7 +6828,7 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
6847
6828
|
const { name, def, destr, type } = args[i];
|
6848
6829
|
|
6849
6830
|
func.localInd = i * 2;
|
6850
|
-
allocVar(func, name, false, true, true);
|
6831
|
+
allocVar(func, name, false, true, false, true);
|
6851
6832
|
|
6852
6833
|
func.localInd = localInd;
|
6853
6834
|
if (type) {
|
@@ -7157,8 +7138,7 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
7157
7138
|
const generateBlock = (scope, decl) => {
|
7158
7139
|
let out = [];
|
7159
7140
|
|
7160
|
-
scope
|
7161
|
-
scope.inferTree.push(decl);
|
7141
|
+
inferBranchStart(scope);
|
7162
7142
|
|
7163
7143
|
let len = decl.body.length, j = 0;
|
7164
7144
|
for (let i = 0; i < len; i++) {
|
@@ -7169,7 +7149,7 @@ const generateBlock = (scope, decl) => {
|
|
7169
7149
|
out = out.concat(generate(scope, x));
|
7170
7150
|
}
|
7171
7151
|
|
7172
|
-
scope
|
7152
|
+
inferBranchEnd(scope);
|
7173
7153
|
|
7174
7154
|
if (out.length === 0) out.push(number(UNDEFINED));
|
7175
7155
|
return out;
|
@@ -7186,8 +7166,7 @@ const internalConstrs = {
|
|
7186
7166
|
}, global, name);
|
7187
7167
|
},
|
7188
7168
|
type: TYPES.array,
|
7189
|
-
notConstr: true
|
7190
|
-
length: 0
|
7169
|
+
notConstr: true
|
7191
7170
|
},
|
7192
7171
|
|
7193
7172
|
__Porffor_fastOr: {
|
@@ -7246,8 +7225,7 @@ const internalConstrs = {
|
|
7246
7225
|
return out;
|
7247
7226
|
},
|
7248
7227
|
type: TYPES.number,
|
7249
|
-
notConstr: true
|
7250
|
-
length: 2
|
7228
|
+
notConstr: true
|
7251
7229
|
},
|
7252
7230
|
|
7253
7231
|
__Math_min: {
|
@@ -7266,8 +7244,7 @@ const internalConstrs = {
|
|
7266
7244
|
return out;
|
7267
7245
|
},
|
7268
7246
|
type: TYPES.number,
|
7269
|
-
notConstr: true
|
7270
|
-
length: 2
|
7247
|
+
notConstr: true
|
7271
7248
|
},
|
7272
7249
|
|
7273
7250
|
__Porffor_printStatic: {
|
@@ -7278,8 +7255,7 @@ const internalConstrs = {
|
|
7278
7255
|
return out;
|
7279
7256
|
},
|
7280
7257
|
type: TYPES.undefined,
|
7281
|
-
notConstr: true
|
7282
|
-
length: 1
|
7258
|
+
notConstr: true
|
7283
7259
|
},
|
7284
7260
|
|
7285
7261
|
__Porffor_type: {
|
@@ -7288,15 +7264,13 @@ const internalConstrs = {
|
|
7288
7264
|
Opcodes.i32_from_u
|
7289
7265
|
],
|
7290
7266
|
type: TYPES.number,
|
7291
|
-
notConstr: true
|
7292
|
-
length: 1
|
7267
|
+
notConstr: true
|
7293
7268
|
},
|
7294
7269
|
|
7295
7270
|
__Porffor_compileType: {
|
7296
7271
|
generate: (scope, decl) => makeString(scope, TYPE_NAMES[knownType(scope, getNodeType(scope, decl.arguments[0]))] ?? 'unknown'),
|
7297
7272
|
type: TYPES.bytestring,
|
7298
|
-
notConstr: true
|
7299
|
-
length: 1
|
7273
|
+
notConstr: true
|
7300
7274
|
},
|
7301
7275
|
|
7302
7276
|
__Porffor_call: {
|
@@ -7319,8 +7293,7 @@ const internalConstrs = {
|
|
7319
7293
|
_new: decl.arguments[3].value !== null,
|
7320
7294
|
_forceCreateThis: true
|
7321
7295
|
}),
|
7322
|
-
notConstr: true
|
7323
|
-
length: 1
|
7296
|
+
notConstr: true
|
7324
7297
|
},
|
7325
7298
|
|
7326
7299
|
__console_log: {
|
@@ -7359,8 +7332,7 @@ const internalConstrs = {
|
|
7359
7332
|
return fast('__Porffor_consolePrint');
|
7360
7333
|
},
|
7361
7334
|
type: TYPES.undefined,
|
7362
|
-
notConstr: true
|
7363
|
-
length: 0
|
7335
|
+
notConstr: true
|
7364
7336
|
}
|
7365
7337
|
};
|
7366
7338
|
|
@@ -7383,7 +7355,7 @@ export default program => {
|
|
7383
7355
|
typeswitchDepth = 0;
|
7384
7356
|
usedTypes = new Set([ TYPES.undefined, TYPES.number, TYPES.boolean, TYPES.function ]);
|
7385
7357
|
coctc = new Map();
|
7386
|
-
globalInfer =
|
7358
|
+
globalInfer = Object.create(null);
|
7387
7359
|
|
7388
7360
|
// set generic opcodes for current valtype
|
7389
7361
|
Opcodes.const = valtypeBinary === Valtype.i32 ? Opcodes.i32_const : Opcodes.f64_const;
|
@@ -7409,7 +7381,7 @@ export default program => {
|
|
7409
7381
|
objectHackers = ['assert', 'compareArray', 'Test262Error', ...new Set(Object.keys(builtinFuncs).map(getObjectName).concat(Object.keys(builtinVars).map(getObjectName)).filter(x => x))];
|
7410
7382
|
}
|
7411
7383
|
|
7412
|
-
|
7384
|
+
generateFunc({}, {
|
7413
7385
|
type: 'Program',
|
7414
7386
|
id: { name: '#main' },
|
7415
7387
|
body: {
|
@@ -7418,9 +7390,6 @@ export default program => {
|
|
7418
7390
|
}
|
7419
7391
|
});
|
7420
7392
|
|
7421
|
-
// if wanted and blank main func and other exports, remove it
|
7422
|
-
if (Prefs.rmBlankMain && main.wasm.length === 0 && funcs.some(x => x.export)) funcs.splice(main.index - importedFuncs.length, 1);
|
7423
|
-
|
7424
7393
|
for (let i = 0; i < funcs.length; i++) {
|
7425
7394
|
const f = funcs[i];
|
7426
7395
|
|
package/compiler/cyclone.js
CHANGED
package/compiler/parse.js
CHANGED
@@ -17,7 +17,7 @@ globalThis.parser = '';
|
|
17
17
|
let parse;
|
18
18
|
const loadParser = async (fallbackParser = 'acorn', forceParser) => {
|
19
19
|
parser = forceParser ?? Prefs.parser ?? fallbackParser;
|
20
|
-
const mod = (await import((globalThis.document
|
20
|
+
const mod = (await import((globalThis.document ? 'https://esm.sh/' : '') + parser));
|
21
21
|
if (mod.parseSync) parse = mod.parseSync;
|
22
22
|
else parse = mod.parse;
|
23
23
|
};
|
package/jsr.json
CHANGED
package/package.json
CHANGED