diff --git a/examples/buffer.html b/examples/buffer.html new file mode 100644 index 0000000..c5e13ba --- /dev/null +++ b/examples/buffer.html @@ -0,0 +1,54 @@ + + +Examples - Buffer + + +

Buffer

+ +List - Source - WebAssembly + +
+ + + + + + diff --git a/examples/buffer.py b/examples/buffer.py new file mode 100644 index 0000000..6700f6c --- /dev/null +++ b/examples/buffer.py @@ -0,0 +1,3 @@ +@exported +def sum() -> i32: # TODO: Should be [i32] -> i32 + return 0 # TODO: Implement me diff --git a/examples/fib.html b/examples/fib.html index 841e8c7..8d62880 100644 --- a/examples/fib.html +++ b/examples/fib.html @@ -5,7 +5,7 @@

Fibonacci

-Source - WebAssembly +List - Source - WebAssembly
@@ -16,13 +16,13 @@ let importObject = {}; let results = document.getElementById('results'); WebAssembly.instantiateStreaming(fetch('fib.wasm'), importObject) - .then(fib => { + .then(app => { // 93: 7540113804746346429 // i64: 9223372036854775807 // 94: 19740274219868223167 for(let i = BigInt(1); i < 93; ++i) { let span = document.createElement('span'); - span.innerHTML = 'fib(' + i + ') = ' + fib.instance.exports.fib(i); + span.innerHTML = 'fib(' + i + ') = ' + app.instance.exports.fib(i); results.appendChild(span); let br = document.createElement('br'); results.appendChild(br); diff --git a/examples/index.html b/examples/index.html index 0093a41..29e73c8 100644 --- a/examples/index.html +++ b/examples/index.html @@ -4,8 +4,13 @@

Examples

+

Standard

+

Technical

+ diff --git a/py2wasm/compiler.py b/py2wasm/compiler.py index c8fe879..40263a2 100644 --- a/py2wasm/compiler.py +++ b/py2wasm/compiler.py @@ -232,7 +232,7 @@ def module(inp: ourlang.Module) -> wasm.Module: def _generate_allocator(mod: ourlang.Module) -> wasm.Function: return wasm.Function( '___new_reference___', - False, + True, [ ('alloc_size', type_(mod.types['i32']), ), ], diff --git a/py2wasm/wasm.py b/py2wasm/wasm.py index 75c4567..049df62 100644 --- a/py2wasm/wasm.py +++ b/py2wasm/wasm.py @@ -242,7 +242,7 @@ class ModuleMemory: self.data = data def generate(self) -> str: - return '(memory 1)\n (data (memory 0) (i32.const 0) "{}")\n'.format( + return '(memory 1)\n (data (memory 0) (i32.const 0) "{}")\n (export "memory" (memory 0))\n'.format( ''.join( f'\\{x:02x}' for x in self.data