Skip to content

Commit

Permalink
Add check for tail call support
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Nov 24, 2023
1 parent 83e6e2d commit 41aa930
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
21 changes: 21 additions & 0 deletions fiat-html/disable-wasm-option.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
document.addEventListener('DOMContentLoaded', async function() {
const wasmCheckbox = document.getElementById('wasm');
const extraWasmLabel = document.getElementById('extraWasmLabel');
wasmCheckbox.disabled = true; // Initially disable the checkbox

try {
if (await wasmFeatureDetect.tailCall()) {
wasmCheckbox.disabled = false; // Re-enable the checkbox if tail calls are supported
} else {
wasmCheckbox.checked = false;

if (navigator.userAgent.includes('Firefox')) {
extraWasmLabel.innerHTML = '(enable <code>javascript.options.wasm_tail_calls</code> in <code>about:config</code>)';
} else {
extraWasmLabel.innerHTML = '(wasm tail calls not supported)';
}
}
} catch (error) {
console.error('Error checking wasm tail call support:', error);
}
});
16 changes: 11 additions & 5 deletions fiat-html/fiat-crypto.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Fiat Cryptography Web Interface</title>
<style>
.error { color: red; white-space: pre-wrap; }
code { display: block; white-space: pre-wrap; border: 1px solid #ddd; padding: 10px; position: relative; }
/*code { display: block; white-space: pre-wrap; border: 1px solid #ddd; padding: 10px; position: relative; }*/
.code-container {
position: relative;
}
Expand All @@ -15,7 +15,8 @@
white-space: pre-wrap;
border: 1px solid #ddd;
padding: 10px;
margin-bottom: 20px; /* Space for the button, adjust as needed */
position: relative;
/*margin-bottom: 20px;*/ /* Space for the button, adjust as needed */
}

.copy-button {
Expand Down Expand Up @@ -50,8 +51,10 @@
<input type="radio" name="inputType" value="string" checked> Input String
</label>
<label>
<input type="checkbox" id="wasm" name="codeKind" value="wasm"> Use WASM
<input type="checkbox" id="wasm" name="codeKind" value="wasm"> Use WASM <span id="extraWasmLabel"></span>
</label>
</div>
<div class="form-row">
<button type="button" id="synthesizeButton">Synthesize</button>
<button type="button" id="cancelButton" disabled>Cancel</button>
<span id="status" class="status-span hidden"></span>
Expand All @@ -62,16 +65,19 @@
<div id="error" class="error hidden"></div>
<div id="output" class="hidden">
<div id="stdoutContainer" class="code-container">
<code id="stdout"></code>
<code id="stdout" class="code"></code>
<button class="copy-button" data-target="stdout">Copy</button>
</div>
<div id="stderrContainer" class="code-container hidden">
<code id="stderr"></code>
<code id="stderr" class="code"></code>
<button class="copy-button" data-target="stderr">Copy</button>
</div>
</div>
<script src="version.js"></script>
<script src="https://unpkg.com/wasm-feature-detect/dist/umd/index.js"></script>
<script src="main.js"></script>
<!-- N.B. disable-wasm-option.js must come after main.js so that the wasm box is unchecked correctly after parsing argv -->
<script src="disable-wasm-option.js"></script>
<script src="copy-button.js"></script>
</body>
</html>

0 comments on commit 41aa930

Please sign in to comment.