aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-17 10:20:45 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-11-17 10:20:45 -0800
commita4e9c38c371360b3cc652f1fcd11974d0476b54a (patch)
tree64c386bc57cbc117a371b173666d4ded9defcde9 /src/runtime.js
parentdddebe080f0792b1df14c1dbb596961f108cc3b5 (diff)
EM_ASM_INT and EM_ASM_DOUBLE, which allow input and output values from EM_ASM; fixes #1819
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 786ae021..dedaf5ea 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -381,6 +381,18 @@ var Runtime = {
#endif
},
+ getAsmConst: function(code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ return Runtime.asmConstCache[code] = eval('(function(' + args.join(',') + '){ ' + Pointer_stringify(code) + ' })'); // new Function does not allow upvars in node
+ },
+
warnOnce: function(text) {
if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
if (!Runtime.warnOnce.shown[text]) {