diff options
Diffstat (limited to 'demo')
-rw-r--r-- | demo/demo.js | 18 | ||||
-rw-r--r-- | demo/index.html | 8 |
2 files changed, 22 insertions, 4 deletions
diff --git a/demo/demo.js b/demo/demo.js index 16bd66a6..40e937d0 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -97,7 +97,8 @@ function onError(loc, error, sourceLine, sourceLineColumnOffset) { ]; if (sourceLine.length > 0) { var numSpaces = loc.firstColumn - 1 - sourceLineColumnOffset; - var numCarets = loc.lastColumn - loc.firstColumn; + var numCarets = + Math.min(loc.lastColumn - loc.firstColumn, sourceLine.length); lines.push(sourceLine); lines.push(' '.repeat(numSpaces) + '^'.repeat(numCarets)); } @@ -118,6 +119,7 @@ function compile(text) { var jsWriter = new wasm.JSStringWriter(); var logStream = new wasm.Stream(jsWriter.writer); var options = new wasm.WriteBinaryOptions({logStream: logStream}); + wasm.markUsedBlocks(allocator, script); wasm.writeBinaryScript(allocator, memoryWriter.base, script, options); output.textContent = jsWriter.string; } catch (e) { @@ -181,6 +183,20 @@ var examples = [ ' (get_local 0)\n' + ' (i64.const 1)))))))\n' + ' (export "fac" $fac))\n' + }, + + { + name: 'stuff', + contents: + '(module\n' + + ' (memory 1 (segment 0 "hi"))\n' + + ' (type (func (param i32) (result i32)))\n' + + ' (import "foo" "bar" (param f32))\n' + + ' (start 0)\n' + + ' (table 0 1)\n' + + ' (func)\n' + + ' (func (type 0) (i32.const 42))\n' + + ' (export "e" 1))\n' } ]; diff --git a/demo/index.html b/demo/index.html index 6a08d6fd..fecc95b5 100644 --- a/demo/index.html +++ b/demo/index.html @@ -27,9 +27,11 @@ <h1>sexpr-wasm demo</h1> <hr> <p> - Type a .wast file into the textarea on the left. The right side will + Type a <a href="https://github.com/WebAssembly/spec/tree/master/ml-proto#s-expression-syntax">.wast</a> + file into the textarea on the left. The right side will either show an error, or will show a log with a description of the - generated .wasm file. + generated <a href="https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md">.wasm</a> + file. </p> <div class="columns"> <div class="two-fifths column"> @@ -45,7 +47,7 @@ </div> </div> </div> - <script src="libwasm.js"></script> + <script src="libwasm-debug.js"></script> <script src="demo.js"></script> </body> </html> |