source: src/SymTab/Mangler.h @ bfbf97f

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 bfbf97f was 5f2f2d7, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

fix constant types, remove unnecessary string copying, work on regression testing, fix several memory leaks

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