diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.js | 1 | ||||
-rw-r--r-- | src/modules.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler.js b/src/compiler.js index 699b0393..46d6b5cf 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -74,6 +74,7 @@ var inter = intertyper(lines); for (suffix in set('', '_sdl', '_gl', '_browser')) { eval(processMacros(preprocess(read('library' + suffix + '.js'), CONSTANTS))); } +LibraryManager.init(); JSify(analyzer(inter)); diff --git a/src/modules.js b/src/modules.js index a91a41ec..fd18fc72 100644 --- a/src/modules.js +++ b/src/modules.js @@ -145,9 +145,16 @@ var Functions = { }; var LibraryManager = { + ready: false, + + init: function() { + this.ready = true; + }, + // Given an ident, see if it is an alias for something, and so forth, returning // the earliest ancestor (the root) getRootIdent: function(ident) { + if (!this.ready) return null; var ret = Library[ident]; if (!ret) return null; var last = ident; diff --git a/src/parseTools.js b/src/parseTools.js index 60ebf309..19aaa63d 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -634,9 +634,15 @@ function makeGetValue(ptr, pos, type, noNeedFirst) { } } -function indexizeFunctions(value) { // TODO: Also check for other functions (externals, library, etc.) +function indexizeFunctions(value) { // TODO: Also check for externals if (value in Functions.currFunctions) { - value = Functions.getIndex(value); // Store integer value + return Functions.getIndex(value); + } + if (value && value[0] == '_') { + var rootIdent = LibraryManager.getRootIdent(value.slice(1)); + if (rootIdent && typeof Library[rootIdent] === 'function') { + return Functions.getIndex('_' + rootIdent); + } } return value; } |