Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: runtime implementation #7

Merged
merged 2 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
runtime/** linguist-vendored
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h1>Luna</h1>
</div>
<div id="btn-result-container"><button id="btn">Result</button></div>
<div id="result"></div>
<div id="result-aeon"></div>
</div>
</div>
<!--
Expand Down
25 changes: 17 additions & 8 deletions example/js/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import startAeonRuntime from '../dist/bundle.js';

const go = new Go(); // Defined in wasm_exec.js. Don't forget to add this in your index.html.


Expand Down Expand Up @@ -48,6 +50,7 @@ const runLunaAddition = async () => {
const btn = document.getElementById('btn')

const res = document.getElementById('result');
const aeonRes = document.getElementById('result-aeon');


btn.setAttribute('disabled', true)
Expand All @@ -60,11 +63,11 @@ const runLunaAddition = async () => {
`


const editor = CodeMirror(codeContainer, {
value: input,
mode: "wast",
lineNumbers: true,
});
const editor = CodeMirror(codeContainer, {
value: input,
mode: "wast",
lineNumbers: true,
});

compile.addEventListener('click', async () => {
moduleContainer.innerHTML = ""
Expand All @@ -88,19 +91,25 @@ const runLunaAddition = async () => {
btn.addEventListener('click', () => {
const n1 = Number(input1.value);
const n2 = Number(input2.value)
console.log("n", input1.value)
console.log("n", input2.value)
// Call Luna add function
res.innerHTML = "Result: "
res.innerHTML += wasmer.instance.exports[fn](n1, n2)

// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// ------------------------------RUN IT WITH AEON RUNTIME---------------------------------
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
const funcName = fn.replace(/"/g, '');

const result = startAeonRuntime(_wasm, funcName, n1, n2);
aeonRes.innerHTML = `Ran with Aeon: ${result}`
})
} catch (err) {
btn.setAttribute('disabled', true)
moduleContainer.innerHTML = String(err);
}


})

};
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf ./dist && make compile",
"start:runtime": "node ./runtime/index.js",
"bundle": "rimraf ./example/dist && esbuild ./runtime/runtime/start.js --bundle --outfile=./example/dist/bundle.js --format=esm",
"commit": "cz"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"commitizen": "^4.2.5",
"esbuild": "^0.15.13",
"rimraf": "^3.0.2"
}
}
230 changes: 230 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading