Created
May 22, 2017 01:55
-
-
Save yutopp/18f38b5eebba1ebf1422243a79dfe689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main() { | |
ref a = fib(10); | |
a.print(); | |
} | |
import std.stdio; | |
def fib(v: int32): int32 { | |
return if ( v == 0 ) 0 | |
else if ( v == 1 ) 1 | |
else fib(v-1) + fib(v-2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>zoi</title> | |
<script> | |
fetch('fib.wasm') | |
.then(response => response.arrayBuffer()) | |
.then(buffer => WebAssembly.compile(buffer)) | |
.then(module => { | |
let importObject = { | |
env: {rill_print_int32: (i32) => { alert(`print_int32: ${i32}`); }} | |
}; | |
let instance = new WebAssembly.Instance(module, importObject); | |
instance.exports._Rill_main(); // main()呼び出し | |
}); | |
</script> | |
</head> | |
<body>Hello</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment