diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-17 10:20:45 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-17 10:20:45 -0800 |
commit | a4e9c38c371360b3cc652f1fcd11974d0476b54a (patch) | |
tree | 64c386bc57cbc117a371b173666d4ded9defcde9 /src/library.js | |
parent | dddebe080f0792b1df14c1dbb596961f108cc3b5 (diff) |
EM_ASM_INT and EM_ASM_DOUBLE, which allow input and output values from EM_ASM; fixes #1819
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/library.js b/src/library.js index 9db99c6c..066a060f 100644 --- a/src/library.js +++ b/src/library.js @@ -8676,12 +8676,19 @@ LibraryManager.library = { }, emscripten_asm_const: function(code) { - // 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(); - func = Runtime.asmConstCache[code] = eval('(function(){ ' + Pointer_stringify(code) + ' })'); // new Function does not allow upvars in node - return func(); + Runtime.getAsmConst(code, 0)(); + }, + + emscripten_asm_const_int__jsargs: true, + emscripten_asm_const_int: function(code) { + var args = Array.prototype.slice.call(arguments, 1); + return Runtime.getAsmConst(code, args.length).apply(null, args) | 0; + }, + + emscripten_asm_const_double__jsargs: true, + emscripten_asm_const_double: function(code) { + var args = Array.prototype.slice.call(arguments, 1); + return +Runtime.getAsmConst(code, args.length).apply(null, args); }, emscripten_get_now: function() { |