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 | // FixNames.cc -- |
---|
8 | // |
---|
9 | // Author : Richard C. Bilson |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Rob Schluntz |
---|
12 | // Last Modified On : Mon Apr 11 15:38:10 2016 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | #include "FixNames.h" |
---|
17 | #include "SynTree/Declaration.h" |
---|
18 | #include "SynTree/Expression.h" |
---|
19 | #include "SynTree/Visitor.h" |
---|
20 | #include "SymTab/Mangler.h" |
---|
21 | #include "OperatorTable.h" |
---|
22 | |
---|
23 | namespace CodeGen { |
---|
24 | class FixNames : public Visitor { |
---|
25 | public: |
---|
26 | virtual void visit( ObjectDecl *objectDecl ); |
---|
27 | virtual void visit( FunctionDecl *functionDecl ); |
---|
28 | |
---|
29 | virtual void visit( CompoundStmt *compoundStmt ); |
---|
30 | |
---|
31 | private: |
---|
32 | int scopeLevel = 1; |
---|
33 | |
---|
34 | void fixDWT( DeclarationWithType *dwt ); |
---|
35 | }; |
---|
36 | |
---|
37 | void fixNames( std::list< Declaration* > translationUnit ) { |
---|
38 | FixNames fixer; |
---|
39 | acceptAll( translationUnit, fixer ); |
---|
40 | } |
---|
41 | |
---|
42 | void FixNames::fixDWT( DeclarationWithType *dwt ) { |
---|
43 | if ( dwt->get_name() != "" ) { |
---|
44 | if ( LinkageSpec::isDecoratable( dwt->get_linkage() ) ) { |
---|
45 | dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) ); |
---|
46 | dwt->set_scopeLevel( scopeLevel ); |
---|
47 | } // if |
---|
48 | } // if |
---|
49 | } |
---|
50 | |
---|
51 | void FixNames::visit( ObjectDecl *objectDecl ) { |
---|
52 | Visitor::visit( objectDecl ); |
---|
53 | fixDWT( objectDecl ); |
---|
54 | } |
---|
55 | |
---|
56 | void FixNames::visit( FunctionDecl *functionDecl ) { |
---|
57 | Visitor::visit( functionDecl ); |
---|
58 | fixDWT( functionDecl ); |
---|
59 | } |
---|
60 | |
---|
61 | void FixNames::visit( CompoundStmt *compoundStmt ) { |
---|
62 | scopeLevel++; |
---|
63 | Visitor::visit( compoundStmt ); |
---|
64 | scopeLevel--; |
---|
65 | } |
---|
66 | } // namespace CodeGen |
---|
67 | |
---|
68 | // Local Variables: // |
---|
69 | // tab-width: 4 // |
---|
70 | // mode: c++ // |
---|
71 | // compile-command: "make install" // |
---|
72 | // End: // |
---|