What's the RightWay(tm) to get a named type? I want to use the Module's symbol table as a repository for named types. But, it doesn't have a way to get the type out unless you already know what it is (i.e. the addTypeName() method). Similarly the SymbolTable class's lookup() method requires a type as well. The Type class also didn't have anything obvious. I want something like: Type* Module::getNamedType( std::string& name ); which returns the type if found or null if not found. This is too simple to not be implemented so I figured I'm looking in the wrong places. Enlighten me, please? Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20031231/4ef6fcdc/attachment.sig>
On Tue, 30 Dec 2003, Reid Spencer wrote:> What's the RightWay(tm) to get a named type? I want to use the Module's > symbol table as a repository for named types. But, it doesn't have a way > to get the type out unless you already know what it is (i.e. the > addTypeName() method). Similarly the SymbolTable class's lookup() method > requires a type as well. The Type class also didn't have anything > obvious.Yup, currently you have to directly access the Module's symbol table. Types have class 'Type::TypeTy', so you would do something like this: Type *Module::getNamedType(const std::string &name) { SymbolTable &SymTab = getSymbolTable(); return cast_or_null<Type>(SymTab.lookup(Type::TypeTy, name)); }> which returns the type if found or null if not found. > > This is too simple to not be implemented so I figured I'm looking in the > wrong places.Heh, well it's so simple, it's not yet implemented :). I'll add this though. -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Apparently Analagous Threads
- [LLVMdev] ExecutionEngine/Interpreter/ExternalFunctions.cpp
- [LLVMdev] ExecutionEngine/Interpreter/ExternalFunctions.cpp
- [LLVMdev] ExecutionEngine/Interpreter/ExternalFunctions.cpp
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library