45 lines
966 B
HTML
45 lines
966 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Examples - Imported</title>
|
|
</head>
|
|
<body>
|
|
<h1>Imported</h1>
|
|
|
|
<a href="index.html">List</a> - <a href="imported.py.html">Source</a> - <a href="imported.wat.html">WebAssembly</a>
|
|
|
|
<div style="white-space: pre;" id="results"></div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
let importObject = {
|
|
'imports': {
|
|
'log': log,
|
|
}
|
|
};
|
|
|
|
let results = document.getElementById('results');
|
|
|
|
function log(txt)
|
|
{
|
|
let span = document.createElement('span');
|
|
span.innerHTML = txt;
|
|
results.appendChild(span);
|
|
let br = document.createElement('br');
|
|
results.appendChild(br);
|
|
}
|
|
|
|
WebAssembly.instantiateStreaming(fetch('imported.wasm'), importObject)
|
|
.then(app => {
|
|
console.log(WebAssembly.Module.imports(app.module));
|
|
app.instance.exports.run(1, 1);
|
|
app.instance.exports.run(3, 5);
|
|
app.instance.exports.run(8, 19);
|
|
app.instance.exports.run(12, 127);
|
|
app.instance.exports.run(79, 193);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|