diff options
author | alon@honor <none@none> | 2010-10-21 21:41:43 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-21 21:41:43 -0700 |
commit | f57cfb99176a2ec61db5b91aeed1f3ff6a719634 (patch) | |
tree | fbd8d4b17a077685de21010550396dd5d2160206 /src/runtime.js | |
parent | beb16b9d956b0434330d6ce1eefd67eec5bae111 (diff) |
fixes in parseConst; move getFunctionIndex into Runtime; test for global function pointers
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime.js b/src/runtime.js index 43a522e4..8d2df889 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -69,12 +69,24 @@ Runtime = { stackAlloc: unInline('stackAlloc', ['size']), staticAlloc: unInline('staticAlloc', ['size']), alignMemory: unInline('alignMemory', ['size', 'quantum']), + + FUNCTION_TABLE: [], + getFunctionIndex: function getFunctionIndex(func) { + var key = Runtime.FUNCTION_TABLE.length; + FUNCTION_TABLE[key] = func; + return key; + }, }; function getRuntime() { var ret = ''; for (i in Runtime) { - ret += Runtime[i].toString() + '\n'; + var item = Runtime[i]; + if (typeof item === 'function') { + ret += item.toString() + '\n'; + } else { + ret += 'var ' + i + ' = ' + JSON.stringify(item) + ';\n'; + } } return ret + '\n'; } |