Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3382,20 +3382,13 @@ Module['readBinaryWithFeatures'] = function(data, features) {
return wrapModule(ptr);
};

// Parses text format to a module
Module['parseText'] = function(text) {
// Parses text format to a module with the given feature set enabled.
Module['parseText'] = function(text, features) {
const buffer = _malloc(text.length + 1);
stringToAscii(text, buffer);
const ptr = handleFatalError(() => Module['_BinaryenModuleParse'](buffer));
_free(buffer);
return wrapModule(ptr);
};

// Parses text format to a module with the given feature set enabled
Module['parseTextWithFeatures'] = function(text, features) {
const buffer = _malloc(text.length + 1);
stringToAscii(text, buffer);
const ptr = handleFatalError(() => Module['_BinaryenModuleParseWithFeatures'](buffer, features));
const ptr = features === undefined
? handleFatalError(() => Module['_BinaryenModuleParse'](buffer))
: handleFatalError(() => Module['_BinaryenModuleParseWithFeatures'](buffer, features));
_free(buffer);
return wrapModule(ptr);
};
Expand Down
4 changes: 2 additions & 2 deletions test/binaryen.js/kitchen-sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,14 +1135,14 @@ function test_parsing_with_features() {
(global $g anyref (ref.null any))
)`;

module = binaryen.parseTextWithFeatures(text, binaryen.Features.All);
module = binaryen.parseText(text, binaryen.Features.All);
assert(module.validate());
console.log("module loaded from text form with features:");
console.log(module.emitText());
module.dispose();

// parse with MVP features, which should fail
module = binaryen.parseTextWithFeatures(text, binaryen.Features.MVP);
module = binaryen.parseText(text, binaryen.Features.MVP);
console.log("validation with MVP features: " + module.validate());
module.dispose();
}
Expand Down
Loading