Changeset 0dd3a2f for translator/SymTab/Mangler.h
- Timestamp:
- May 18, 2015, 11:20:23 AM (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:
- 51587aa
- Parents:
- a32b204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SymTab/Mangler.h
ra32b204 r0dd3a2f 1 #ifndef SYMTAB_MANGLER_H 2 #define SYMTAB_MANGLER_H 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // Mangler.h -- 8 // 9 // Author : Richard C. Bilson 10 // Created On : Sun May 17 21:44:03 2015 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 17 21:45:05 2015 13 // Update Count : 2 14 // 15 16 #ifndef MANGLER_H 17 #define MANGLER_H 3 18 4 19 #include <strstream> … … 9 24 class Mangler : public Visitor { 10 25 public: 11 template< typename SynTreeClass >26 template< typename SynTreeClass > 12 27 static std::string mangle( SynTreeClass *decl ); // interface to clients 13 28 14 29 /// using Visitor::visit; 15 virtual void visit( ObjectDecl *declaration );16 virtual void visit( FunctionDecl *declaration );17 virtual void visit( TypeDecl *declaration );30 virtual void visit( ObjectDecl *declaration ); 31 virtual void visit( FunctionDecl *declaration ); 32 virtual void visit( TypeDecl *declaration ); 18 33 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 );34 virtual void visit( VoidType *voidType ); 35 virtual void visit( BasicType *basicType ); 36 virtual void visit( PointerType *pointerType ); 37 virtual void visit( ArrayType *arrayType ); 38 virtual void visit( FunctionType *functionType ); 39 virtual void visit( StructInstType *aggregateUseType ); 40 virtual void visit( UnionInstType *aggregateUseType ); 41 virtual void visit( EnumInstType *aggregateUseType ); 42 virtual void visit( TypeInstType *aggregateUseType ); 43 virtual void visit( TupleType *tupleType ); 29 44 30 std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); }45 std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); } 31 46 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;47 std::ostrstream mangleName; 48 typedef std::map< std::string, std::pair< int, int > > VarMapType; 49 VarMapType varNums; 50 int nextVarNum; 51 bool isTopLevel; 37 52 38 Mangler();39 Mangler( const Mangler & );53 Mangler(); 54 Mangler( const Mangler & ); 40 55 41 void mangleDecl( DeclarationWithType *declaration );42 void mangleRef( ReferenceToType *refType, std::string prefix );56 void mangleDecl( DeclarationWithType *declaration ); 57 void mangleRef( ReferenceToType *refType, std::string prefix ); 43 58 44 void printQualifiers( Type *type );59 void printQualifiers( Type *type ); 45 60 }; // Mangler 46 61 47 62 template< typename SynTreeClass > 48 63 std::string Mangler::mangle( SynTreeClass *decl ) { 49 Mangler mangler;50 maybeAccept( decl, mangler );51 return mangler.get_mangleName();64 Mangler mangler; 65 maybeAccept( decl, mangler ); 66 return mangler.get_mangleName(); 52 67 } 53 68 } // SymTab 54 69 55 #endif // SYMTAB_MANGLER_H 70 #endif // MANGLER_H 71 72 // Local Variables: // 73 // tab-width: 4 // 74 // mode: c++ // 75 // compile-command: "make install" // 76 // End: //
Note: See TracChangeset
for help on using the changeset viewer.