-
-
Save meddulla/0d01531b7152e6dbedd5375b520ebb43 to your computer and use it in GitHub Desktop.
A simple asm.js module
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
function Calc(stdlib, foreign, heap) { | |
"use asm"; | |
function add(a, b) { | |
a = a|0; | |
b = b|0; | |
return (a + b)|0; | |
} | |
return { | |
add: add | |
}; | |
} | |
var stdlib = null; | |
var foreign = null; | |
var heap = new ArrayBuffer(1000); // 1kb | |
// create module instance | |
var calc = Calc( stdlib, foreign, heap ); | |
// call `add` function | |
var result = calc.add( 1, 2 ); | |
console.log( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment