summaryrefslogtreecommitdiff
path: root/docs/demo/wat2wasm
diff options
context:
space:
mode:
authorMarcus Better <marcusb@users.noreply.github.com>2022-12-27 10:57:42 -0500
committerGitHub <noreply@github.com>2022-12-27 07:57:42 -0800
commitaefa094ea44619a410218ab754c6b58ac3a49683 (patch)
tree0fd79486487d803139e387e1a660a0189a9e3a91 /docs/demo/wat2wasm
parentd9338f70a26cc9ee4e64da71ce3b50d4c44e0c03 (diff)
downloadwabt-aefa094ea44619a410218ab754c6b58ac3a49683.tar.gz
wabt-aefa094ea44619a410218ab754c6b58ac3a49683.tar.bz2
wabt-aefa094ea44619a410218ab754c6b58ac3a49683.zip
Enable features in libwabt.js by default (#2109)
This applies the same defaults for features in the JavaScript-compiled version as the native tools. Without this change, enabling only the "reference_types" feature did not work, as it got turned off due to the dependency on "bulk_memory", which is counter-intuitive (see Features::UpdateDependencies()). Additionally, exposes all the features and their default setting in JavaScript.
Diffstat (limited to 'docs/demo/wat2wasm')
-rw-r--r--docs/demo/wat2wasm/demo.js19
-rw-r--r--docs/demo/wat2wasm/index.html16
2 files changed, 15 insertions, 20 deletions
diff --git a/docs/demo/wat2wasm/demo.js b/docs/demo/wat2wasm/demo.js
index 66f44736..a5b7eb09 100644
--- a/docs/demo/wat2wasm/demo.js
+++ b/docs/demo/wat2wasm/demo.js
@@ -24,19 +24,6 @@ var features = {};
WabtModule().then(function(wabt) {
-var FEATURES = [
- 'exceptions',
- 'mutable_globals',
- 'sat_float_to_int',
- 'sign_extension',
- 'simd',
- 'threads',
- 'multi_value',
- 'tail_call',
- 'bulk_memory',
- 'reference_types',
-];
-
var kCompileMinMS = 100;
var outputShowBase64 = false;
var outputLog;
@@ -52,9 +39,9 @@ var base64El = document.getElementById('base64');
var binaryBuffer = null;
var binaryBlobUrl = null;
-for (var feature of FEATURES) {
- var featureEl = document.getElementById(feature);
- features[feature] = featureEl.checked;
+for (const [f, v] of Object.entries(wabt.FEATURES)) {
+ var featureEl = document.getElementById(f);
+ featureEl.checked = v;
featureEl.addEventListener('change', event => {
var feature = event.target.id;
features[feature] = event.target.checked;
diff --git a/docs/demo/wat2wasm/index.html b/docs/demo/wat2wasm/index.html
index f2e92561..14329c95 100644
--- a/docs/demo/wat2wasm/index.html
+++ b/docs/demo/wat2wasm/index.html
@@ -39,17 +39,25 @@
<div>Enabled features:</div>
<div>
<input type="checkbox" id="exceptions"><label for="exceptions">exceptions</label>
- <input type="checkbox" id="mutable_globals" checked><label for="mutable_globals">mutable globals</label>
+ <input type="checkbox" id="mutable_globals"><label for="mutable_globals">mutable globals</label>
<input type="checkbox" id="sat_float_to_int"><label for="sat_float_to_int">saturating float to int</label>
<input type="checkbox" id="sign_extension"><label for="sign_extension">sign extension</label>
- </div>
- <div>
<input type="checkbox" id="simd"><label for="simd">simd</label>
<input type="checkbox" id="threads"><label for="threads">threads</label>
- <input type="checkbox" id="multi_value" checked><label for="multi_value">multi value</label>
+ <input type="checkbox" id="function_references"><label for="function_references">function references</label>
+ <input type="checkbox" id="multi_value"><label for="multi_value">multi value</label>
<input type="checkbox" id="tail_call"><label for="tail_call">tail call</label>
+ </div>
+ <div>
<input type="checkbox" id="bulk_memory"><label for="bulk_memory">bulk memory</label>
<input type="checkbox" id="reference_types"><label for="reference_types">reference types</label>
+ <input type="checkbox" id="annotations"><label for="annotations">annotations</label>
+ <input type="checkbox" id="code_metadata"><label for="code_metadata">code metadata</label>
+ <input type="checkbox" id="gc"><label for="gc">gc</label>
+ <input type="checkbox" id="memory64"><label for="memory64">memory64</label>
+ <input type="checkbox" id="multi_memory"><label for="gc">multi memory</label>
+ <input type="checkbox" id="extended_const"><label for="extended_const">extended const</label>
+ <input type="checkbox" id="relaxed_simd"><label for="relaxed_simd">relaxed simd</label>
</div>
</header>
<main>