Changeset ea3eb06 for translator/SymTab/Mangler.h
- Timestamp:
- Nov 22, 2014, 4:51:46 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- d11f789
- Parents:
- 3c70d38
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SymTab/Mangler.h
r3c70d38 rea3eb06 1 /*2 * This file is part of the Cforall project3 *4 * $Id: Mangler.h,v 1.6 2005/08/29 20:14:18 rcbilson Exp $5 *6 */7 8 1 #ifndef SYMTAB_MANGLER_H 9 2 #define SYMTAB_MANGLER_H … … 14 7 15 8 namespace SymTab { 16 17 class Mangler : public Visitor 18 { 19 public: 20 template< typename SynTreeClass > 21 static std::string mangle( SynTreeClass *decl ); // interface to clients 9 class Mangler : public Visitor { 10 public: 11 template< typename SynTreeClass > 12 static std::string mangle( SynTreeClass *decl ); // interface to clients 22 13 23 14 /// using Visitor::visit; 24 virtual void visit(ObjectDecl *declaration);25 virtual void visit(FunctionDecl *declaration);26 virtual void visit(TypeDecl *declaration);15 virtual void visit( ObjectDecl *declaration ); 16 virtual void visit( FunctionDecl *declaration ); 17 virtual void visit( TypeDecl *declaration ); 27 18 28 virtual void visit(VoidType *voidType);29 virtual void visit(BasicType *basicType);30 virtual void visit(PointerType *pointerType);31 virtual void visit(ArrayType *arrayType);32 virtual void visit(FunctionType *functionType);33 virtual void visit(StructInstType *aggregateUseType);34 virtual void visit(UnionInstType *aggregateUseType);35 virtual void visit(EnumInstType *aggregateUseType);36 virtual void visit(TypeInstType *aggregateUseType);37 virtual void visit(TupleType *tupleType);19 virtual void visit( VoidType *voidType ); 20 virtual void visit( BasicType *basicType ); 21 virtual void visit( PointerType *pointerType ); 22 virtual void visit( ArrayType *arrayType ); 23 virtual void visit( FunctionType *functionType ); 24 virtual void visit( StructInstType *aggregateUseType ); 25 virtual void visit( UnionInstType *aggregateUseType ); 26 virtual void visit( EnumInstType *aggregateUseType ); 27 virtual void visit( TypeInstType *aggregateUseType ); 28 virtual void visit( TupleType *tupleType ); 38 29 39 std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); } 30 std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); } 31 private: 32 std::ostrstream mangleName; 33 typedef std::map< std::string, std::pair< int, int > > VarMapType; 34 VarMapType varNums; 35 int nextVarNum; 36 bool isTopLevel; 37 38 Mangler(); 39 Mangler( const Mangler & ); 40 41 void mangleDecl( DeclarationWithType *declaration ); 42 void mangleRef( ReferenceToType *refType, std::string prefix ); 43 44 void printQualifiers( Type *type ); 45 }; // Mangler 40 46 41 private: 42 std::ostrstream mangleName; 43 typedef std::map< std::string, std::pair< int, int > > VarMapType; 44 VarMapType varNums; 45 int nextVarNum; 46 bool isTopLevel; 47 48 Mangler(); 49 Mangler( const Mangler & ); 50 51 void mangleDecl(DeclarationWithType *declaration); 52 void mangleRef(ReferenceToType *refType, std::string prefix); 53 54 void printQualifiers( Type *type ); 55 }; 47 template< typename SynTreeClass > 48 std::string Mangler::mangle( SynTreeClass *decl ) { 49 Mangler mangler; 50 maybeAccept( decl, mangler ); 51 return mangler.get_mangleName(); 52 } 53 } // SymTab 56 54 57 /* static class method */ 58 template< typename SynTreeClass > 59 std::string 60 Mangler::mangle( SynTreeClass *decl ) 61 { 62 Mangler mangler; 63 maybeAccept( decl, mangler ); 64 return mangler.get_mangleName(); 65 } 66 67 } // namespace SymTab 68 69 #endif /* #ifndef SYMTAB_MANGLER_H */ 55 #endif // SYMTAB_MANGLER_H
Note: See TracChangeset
for help on using the changeset viewer.