porffor 0.27.2 → 0.28.0
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/codegen.js +21 -2
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -2429,6 +2429,14 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2429
2429
|
[ Opcodes.i32_load16_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut') * pageSize), 'read func lut' ]
|
2430
2430
|
], tableBc, valtypeBinary)
|
2431
2431
|
],
|
2432
|
+
|
2433
|
+
...(decl.optional ? {
|
2434
|
+
[TYPES.undefined]: [
|
2435
|
+
...number(UNDEFINED),
|
2436
|
+
...setLastType(scope, TYPES.undefined)
|
2437
|
+
]
|
2438
|
+
} : {}),
|
2439
|
+
|
2432
2440
|
default: internalThrow(scope, 'TypeError', `${unhackName(name)} is not a function`, true)
|
2433
2441
|
})
|
2434
2442
|
];
|
@@ -5212,8 +5220,6 @@ const objectHack = node => {
|
|
5212
5220
|
};
|
5213
5221
|
|
5214
5222
|
const generateFunc = (scope, decl) => {
|
5215
|
-
if (decl.generator) return todo(scope, 'generator functions are not supported');
|
5216
|
-
|
5217
5223
|
const name = decl.id ? decl.id.name : `anonymous${uniqId()}`;
|
5218
5224
|
const params = decl.params ?? [];
|
5219
5225
|
|
@@ -5235,6 +5241,19 @@ const generateFunc = (scope, decl) => {
|
|
5235
5241
|
funcIndex[name] = func.index;
|
5236
5242
|
funcs.push(func);
|
5237
5243
|
|
5244
|
+
let errorWasm = null;
|
5245
|
+
if (decl.generator) errorWasm = todo(scope, 'generator functions are not supported');
|
5246
|
+
|
5247
|
+
if (errorWasm) {
|
5248
|
+
func.wasm = errorWasm.concat([
|
5249
|
+
...number(UNDEFINED),
|
5250
|
+
...number(TYPES.undefined, Valtype.i32)
|
5251
|
+
]);
|
5252
|
+
func.params = [];
|
5253
|
+
func.constr = false;
|
5254
|
+
return func;
|
5255
|
+
}
|
5256
|
+
|
5238
5257
|
if (typedInput && decl.returnType) {
|
5239
5258
|
const { type } = extractTypeAnnotation(decl.returnType);
|
5240
5259
|
if (type != null && !Prefs.indirectCalls) {
|
package/package.json
CHANGED