-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ethanwillis/master
Runtime update
- Loading branch information
Showing
5 changed files
with
25 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import startAeonRuntime from "../runtime/start.js"; | ||
import createAeonRuntime from "../runtime/start.js"; | ||
|
||
// Compile the ./main.wat file with https://luna-demo.vercel.app | ||
// Get the hex dump from either the middle div or the console | ||
|
||
// The below example | ||
// The below example | ||
// - exports aeonAddition | ||
// - takes two parameters (i32) | ||
// - performs an addition (i32) | ||
const wasmBinary = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 7, 1, 96, 2, 127, 127, 1, 127, 3, 2, 1, 0, 7, 18, 1, 14, 34, 97, 101, 111, 110, 65, 100, 100, 105, 116, 105, 111, 110, 34, 0, 0, 10, 9, 1, 7, 0, 32, 0, 32, 1, 106, 11]); | ||
|
||
const result = startAeonRuntime(wasmBinary, "aeonAddition", 2, 3) | ||
console.log("Result", result) // prints 5 | ||
const runtime = createAeonRuntime(wasmBinary) | ||
const result = runtime("aeonAddition", 2, 3); | ||
|
||
console.log("Result", result) // prints 5 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import startAeonRuntime from "./runtime/start.js"; | ||
import createAeonRuntime from "./runtime/start.js"; | ||
|
||
const wasmBinary = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 1, 96, 3, 127, 127, 127, 1, 127, 3, 2, 1, 0, 7, 16, 1, 12, 34, 97, 100, 100, 78, 117, 109, 98, 101, 114, 115, 34, 0, 0, 10, 9, 1, 7, 0, 32, 0, 32, 1, 32, 2, 106, 11]); | ||
|
||
const n1 = 8; | ||
const n2 = 20; | ||
const n3 = 23; | ||
|
||
const result = startAeonRuntime(wasmBinary, "addNumbers", n1, n2, n3); | ||
console.log(`${n1} + ${n2} + ${n3} =`, result) | ||
const runtime = createAeonRuntime(wasmBinary); | ||
const result = runtime("addNumbers", n1, n2, n3); | ||
console.log(`${n1} + ${n2} + ${n3} =`, result) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { createAST } from "./ast.js"; | ||
import { invokeFunction } from "./invoker.js"; | ||
|
||
const startAeonRuntime = (wasm, ...args) => { | ||
const ast = createAST(wasm); | ||
const [funcName, ...rest] = args; | ||
const params = rest; | ||
|
||
const result = invokeFunction(ast, funcName, params); | ||
return result; | ||
/** | ||
@param wasm - A wasm binary. | ||
*/ | ||
const createAeonRuntime = (wasm) => { | ||
const ast = createAST(wasm); | ||
return (funcName, params) => invokeFunction(ast, funcName, params); | ||
} | ||
|
||
export default startAeonRuntime; | ||
export default createAeonRuntime; |
39897aa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
luna – ./
luna-demo.vercel.app
luna-git-master-thomscoder.vercel.app
luna-thomscoder.vercel.app