Skip to content

Commit a8eb2f5

Browse files
committed
refuse to export builtin functions
1 parent 8e439fe commit a8eb2f5

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

Diff for: lib/loader/tests/build/default.wasm

454 Bytes
Binary file not shown.

Diff for: lib/loader/tests/build/legacy.wasm

454 Bytes
Binary file not shown.

Diff for: lib/loader/tests/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function test(file) {
1919

2020
// should export memory
2121
assert(exports.memory instanceof WebAssembly.Memory);
22-
assert(typeof exports.memory.copy === "function");
22+
assert(typeof exports.memory.compare === "function");
2323

2424
// should be able to get an exported string
2525
assert.strictEqual(exports.__getString(exports.COLOR), "red");

Diff for: src/compiler.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,15 @@ export class Compiler extends DiagnosticEmitter {
713713
}
714714
case ElementKind.FUNCTION: {
715715
let functionInstance = <Function>element;
716-
let signature = functionInstance.signature;
717-
if (signature.requiredParameters < signature.parameterTypes.length) {
718-
// utilize trampoline to fill in omitted arguments
719-
functionInstance = this.ensureTrampoline(functionInstance);
720-
this.ensureBuiltinArgumentsLength();
716+
if (!functionInstance.hasDecorator(DecoratorFlags.BUILTIN)) {
717+
let signature = functionInstance.signature;
718+
if (signature.requiredParameters < signature.parameterTypes.length) {
719+
// utilize trampoline to fill in omitted arguments
720+
functionInstance = this.ensureTrampoline(functionInstance);
721+
this.ensureBuiltinArgumentsLength();
722+
}
723+
if (functionInstance.is(CommonFlags.COMPILED)) this.module.addFunctionExport(functionInstance.internalName, prefix + name);
721724
}
722-
if (functionInstance.is(CommonFlags.COMPILED)) this.module.addFunctionExport(functionInstance.internalName, prefix + name);
723725
break;
724726
}
725727
case ElementKind.PROPERTY: {

Diff for: src/diagnostics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ export abstract class DiagnosticEmitter {
290290
if (range) message = message.withRange(range);
291291
if (relatedRange) message.relatedRange = relatedRange;
292292
this.diagnostics.push(message);
293-
// console.log(formatDiagnosticMessage(message, true, true) + "\n"); // temporary
294-
// console.log(<string>new Error("stack").stack);
293+
console.log(formatDiagnosticMessage(message, true, true) + "\n"); // temporary
294+
console.log(<string>new Error("stack").stack);
295295
}
296296

297297
/** Emits an overly pedantic diagnostic message. */

0 commit comments

Comments
 (0)