source: src/SymTab/Mangler.h @ 4aa0858

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 4aa0858 was 4aa0858, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

allow user defined routines to override autogenerated routines

  • Property mode set to 100644
File size: 2.2 KB
Line 
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 : Rob Schluntz
12// Last Modified On : Wed Aug 19 15:48:46 2015
13// Update Count     : 14
14//
15
16#ifndef MANGLER_H
17#define MANGLER_H
18
19#include <sstream>
20#include "SynTree/SynTree.h"
21#include "SynTree/Visitor.h"
22
23namespace SymTab {
24        class Mangler : public Visitor {
25          public:
26                template< typename SynTreeClass >
27            static std::string mangle( SynTreeClass *decl, bool mangleOverridable = true ); // interface to clients
28
29///   using Visitor::visit;
30                virtual void visit( ObjectDecl *declaration );
31                virtual void visit( FunctionDecl *declaration );
32                virtual void visit( TypeDecl *declaration );
33
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 );
44 
45                std::string get_mangleName() { return mangleName.str(); }
46          private:
47                std::ostringstream mangleName;
48                typedef std::map< std::string, std::pair< int, int > > VarMapType;
49                VarMapType varNums;
50                int nextVarNum;
51                bool isTopLevel;
52                bool mangleOverridable;
53 
54                Mangler( bool mangleOverridable );
55                Mangler( const Mangler & );
56 
57                void mangleDecl( DeclarationWithType *declaration );
58                void mangleRef( ReferenceToType *refType, std::string prefix );
59 
60                void printQualifiers( Type *type );
61        }; // Mangler
62
63        template< typename SynTreeClass >
64        std::string Mangler::mangle( SynTreeClass *decl, bool mangleOverridable ) {
65                Mangler mangler( mangleOverridable );
66                maybeAccept( decl, mangler );
67                return mangler.get_mangleName();
68        }
69} // SymTab
70
71#endif // MANGLER_H
72
73// Local Variables: //
74// tab-width: 4 //
75// mode: c++ //
76// compile-command: "make install" //
77// End: //
Note: See TracBrowser for help on using the repository browser.