diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-16 11:18:06 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-16 11:18:06 -0800 |
commit | 5fe3bcc54b6c7ee04d0b09cc3e44e0cd06b95405 (patch) | |
tree | 2cf6d3a26b321328941346235d0c4f7db919ab3b /src/preamble_sharedlib.js | |
parent | 58132ad51111bcb024f7a9f2bdce970324c05e00 (diff) |
refactor runtime init and exit code
Diffstat (limited to 'src/preamble_sharedlib.js')
-rw-r--r-- | src/preamble_sharedlib.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/preamble_sharedlib.js b/src/preamble_sharedlib.js index 4b91c44c..2a071f6b 100644 --- a/src/preamble_sharedlib.js +++ b/src/preamble_sharedlib.js @@ -4,7 +4,21 @@ // Runtime essentials //======================================== -var __globalConstructor__ = function globalConstructor() { +function callRuntimeCallbacks(callbacks) { + while(callbacks.length > 0) { + var callback = callbacks.pop(); + var func = callback.func; + if (typeof func === 'number') { + func = FUNCTION_TABLE[func]; + } + func(callback.arg === undefined ? null : callback.arg); + } +} + +var __ATINIT__ = []; // functions called during startup + +function initRuntime() { + callRuntimeCallbacks(__ATINIT__); } // === Body === |