source: translator/SymTab/Mangler.h @ b87a5ed

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since b87a5ed was ea3eb06, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

formatting changes

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#ifndef SYMTAB_MANGLER_H
2#define SYMTAB_MANGLER_H
3
4#include <strstream>
5#include "SynTree/SynTree.h"
6#include "SynTree/Visitor.h"
7
8namespace SymTab {
9    class Mangler : public Visitor {
10      public:
11        template< typename SynTreeClass >
12            static std::string mangle( SynTreeClass *decl ); // interface to clients
13
14///   using Visitor::visit;
15        virtual void visit( ObjectDecl *declaration );
16        virtual void visit( FunctionDecl *declaration );
17        virtual void visit( TypeDecl *declaration );
18
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 );
29 
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
46
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
54
55#endif // SYMTAB_MANGLER_H
Note: See TracBrowser for help on using the repository browser.