source: translator/SymTab/Mangler.h @ 1db2c5be

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 1db2c5be was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: Mangler.h,v 1.6 2005/08/29 20:14:18 rcbilson Exp $
5 *
6 */
7
8#ifndef SYMTAB_MANGLER_H
9#define SYMTAB_MANGLER_H
10
11#include <strstream>
12#include "SynTree/SynTree.h"
13#include "SynTree/Visitor.h"
14
15namespace SymTab {
16
17class Mangler : public Visitor
18{
19public:
20  template< typename SynTreeClass >
21  static std::string mangle( SynTreeClass *decl );              // interface to clients
22
23///   using Visitor::visit;
24  virtual void visit(ObjectDecl *declaration);
25  virtual void visit(FunctionDecl *declaration);
26  virtual void visit(TypeDecl *declaration);
27
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);
38 
39  std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); }
40
41private:
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};
56
57/* static class method */
58template< typename SynTreeClass >
59std::string
60Mangler::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 */
Note: See TracBrowser for help on using the repository browser.