summaryrefslogtreecommitdiff
path: root/demo/wat2wasm/demo.js
diff options
context:
space:
mode:
Diffstat (limited to 'demo/wat2wasm/demo.js')
-rw-r--r--demo/wat2wasm/demo.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/demo/wat2wasm/demo.js b/demo/wat2wasm/demo.js
index 7974c5a8..a595726a 100644
--- a/demo/wat2wasm/demo.js
+++ b/demo/wat2wasm/demo.js
@@ -20,8 +20,21 @@ Split(["#top-row", "#bottom-row"], {
direction: 'vertical'
});
+var features = {};
+
WabtModule().then(function(wabt) {
+var FEATURES = [
+ 'exceptions',
+ 'mutable_globals',
+ 'sat_float_to_int',
+ 'sign_extension',
+ 'simd',
+ 'threads',
+ 'multi_value',
+ 'tail_call',
+];
+
var kCompileMinMS = 100;
var outputEl = document.getElementById('output');
@@ -32,6 +45,16 @@ var downloadLink = document.getElementById('downloadLink');
var binaryBuffer = null;
var binaryBlobUrl = null;
+for (var feature of FEATURES) {
+ var featureEl = document.getElementById(feature);
+ features[feature] = featureEl.checked;
+ featureEl.addEventListener('change', event => {
+ var feature = event.target.id;
+ features[feature] = event.target.checked;
+ onWatChange();
+ });
+}
+
var wasmInstance = null;
var wrappedConsole = Object.create(console);
@@ -79,9 +102,9 @@ function compile() {
outputEl.textContent = '';
var binaryOutput;
try {
- var module = wabt.parseWat('test.wast', watEditor.getValue());
+ var module = wabt.parseWat('test.wast', watEditor.getValue(), features);
module.resolveNames();
- module.validate();
+ module.validate(features);
var binaryOutput = module.toBinary({log: true, write_debug_names:true});
outputEl.textContent = binaryOutput.log;
binaryBuffer = binaryOutput.buffer;