diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-14 12:16:45 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-14 12:16:45 -0800 |
commit | 02ab691e5965b6500886edea8289f3fac792ef75 (patch) | |
tree | e0c83fe6927cc5a28032769934872e962e1bccac /lib/Target/CppBackend/CPPBackend.cpp | |
parent | a3388042b3cf9be51a9c5b54d0d36bfde97e640b (diff) |
export used redirects
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 4d711827a5..57427c05bd 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -113,6 +113,7 @@ namespace { typedef std::map<std::string, Address> GlobalAddressMap; typedef std::vector<std::string> FunctionTable; typedef std::map<std::string, FunctionTable> FunctionTableMap; + typedef std::map<std::string, std::string> StringMap; /// CppWriter - This class is the main chunk of code that converts an LLVM /// module to a C++ translation unit. @@ -135,6 +136,7 @@ namespace { GlobalAddressMap GlobalAddresses; NameSet Externals; // vars NameSet Declares; // funcs + StringMap Redirects; // library function redirects actually used, needed for wrapper funcs in tables std::string PostSets; std::map<std::string, unsigned> IndexedFunctions; // name -> index FunctionTableMap FunctionTables; // sig => list of functions @@ -250,6 +252,13 @@ namespace { unsigned Index = Table.size(); Table.push_back(Name); IndexedFunctions[Name] = Index; + + // invoke the callHandler for this, if there is one. the function may only be indexed but never called directly, we need to catch it in the handler + CallHandlerMap::iterator CH = CallHandlers->find(Name); + if (CH != CallHandlers->end()) { + (this->*(CH->second))(NULL, Name, -1); + } + return Index; } void ensureFunctionTable(const FunctionType *F) { @@ -2404,6 +2413,19 @@ void CppWriter::printModuleBody() { } Out << "],"; + Out << "\"redirects\": {"; + first = true; + for (StringMap::iterator I = Redirects.begin(), E = Redirects.end(); + I != E; ++I) { + if (first) { + first = false; + } else { + Out << ", "; + } + Out << "\"_" << I->first << "\": \"" + I->second + "\""; + } + Out << "},"; + Out << "\"externs\": ["; first = true; for (NameSet::iterator I = Externals.begin(), E = Externals.end(); |