diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-07-04 11:51:22 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-07-04 11:51:22 -0700 |
commit | a4262aa2c9028145516c1a23cbdc6b7b8a42b353 (patch) | |
tree | bb042e7314d0cbec888c328dd2e64132a2850482 | |
parent | 7653c3b900216a31fd3b6d64afff486bd597111e (diff) |
support for llvm aliases
-rw-r--r-- | src/analyzer.js | 2 | ||||
-rw-r--r-- | src/intertyper.js | 10 | ||||
-rw-r--r-- | src/jsifier.js | 16 | ||||
-rw-r--r-- | src/modules.js | 1 | ||||
-rw-r--r-- | tests/runner.py | 2 |
5 files changed, 27 insertions, 4 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 4f069695..0cb1b160 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -29,7 +29,7 @@ function analyzer(data) { substrate.addActor('Gatherer', { processItem: function(item) { // Single-liners - ['globalVariable', 'functionStub', 'unparsedFunction'].forEach(function(intertype) { + ['globalVariable', 'functionStub', 'unparsedFunction', 'alias'].forEach(function(intertype) { var temp = splitter(item.items, function(item) { return item.intertype == intertype }); item.items = temp.leftIn; item[intertype + 's'] = temp.splitOut; diff --git a/src/intertyper.js b/src/intertyper.js index 972b5de6..b6ff89f5 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -375,7 +375,15 @@ function intertyper(data, parseFunctions, baseLineNum) { } if (item.tokens[2].text == 'alias') { - return null; // TODO: handle this. See raytrace.cpp + cleanOutTokensSet(LLVM.LINKAGES, item.tokens, 3); + cleanOutTokensSet(LLVM.VISIBILITIES, item.tokens, 3); + return [{ + intertype: 'alias', + ident: toNiceIdent(item.tokens[0].text), + aliasee: toNiceIdent(item.tokens[4].text), + type: item.tokens[3].text, + lineNum: item.lineNum + }]; } if (item.tokens[2].text == 'type') { var fields = []; diff --git a/src/jsifier.js b/src/jsifier.js index 1b83b991..486eeb02 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -221,6 +221,21 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { } }); + // alias + substrate.addActor('Alias', { + processItem: function(item) { + item.intertype = 'GlobalVariableStub'; + var ret = [item]; + item.JS = 'var ' + item.ident + ';'; + // Set the actual value in a postset, since it may be a global variable. TODO: handle alias of alias (needs ordering) + ret.push({ + intertype: 'GlobalVariablePostSet', + JS: item.ident + ' = ' + item.aliasee + ';' + }); + return ret; + } + }); + var moduleFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident })); var addedLibraryItems = {}; @@ -830,6 +845,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { substrate.addItems(values(data.globalVariables), 'GlobalVariable'); substrate.addItems(data.functions, 'FunctionSplitter'); substrate.addItems(data.functionStubs, 'FunctionStub'); + substrate.addItems(data.aliass, 'Alias'); return finalCombiner(substrate.solve()); } diff --git a/src/modules.js b/src/modules.js index 91758609..0b00107c 100644 --- a/src/modules.js +++ b/src/modules.js @@ -6,6 +6,7 @@ var LLVM = { LINKAGES: set('private', 'linker_private', 'linker_private_weak', 'linker_private_weak_def_auto', 'internal', 'available_externally', 'linkonce', 'common', 'weak', 'appending', 'extern_weak', 'linkonce_odr', 'weak_odr', 'externally_visible', 'dllimport', 'dllexport', 'unnamed_addr'), + VISIBILITIES: set('default', 'hidden', 'protected'), PARAM_ATTR: set('noalias', 'signext', 'zeroext', 'inreg', 'sret', 'nocapture', 'nest'), CALLING_CONVENTIONS: set('ccc', 'fastcc', 'coldcc', 'cc10') }; diff --git a/tests/runner.py b/tests/runner.py index 9249fc34..318187f2 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -2609,8 +2609,6 @@ if 'benchmark' not in sys.argv: # Way 2: use CppHeaderParser - if COMPILER != LLVM_GCC: return self.skip() # FIXME: proper support for aliases, which clang generates here - basename = os.path.join(self.get_dir(), 'bindingtest') Popen(['python', BINDINGS_GENERATOR, basename, header_filename], stdout=PIPE, stderr=STDOUT).communicate()[0] |