aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js19
-rw-r--r--src/runtime.js12
2 files changed, 25 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() {
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]) {