Changeset 3ca540f for src/CodeGen
- Timestamp:
- Dec 1, 2017, 2:55:41 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a40d503
- Parents:
- 882ad37 (diff), 5da9d6a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
r882ad37 r3ca540f 19 19 #include <string> // for string, operator!=, operator== 20 20 21 #include "Common/PassVisitor.h" 21 22 #include "Common/SemanticError.h" // for SemanticError 22 23 #include "FixMain.h" // for FixMain … … 32 33 33 34 namespace CodeGen { 34 class FixNames : public Visitor{35 class FixNames : public WithGuards { 35 36 public: 36 v irtual voidvisit( ObjectDecl *objectDecl );37 v irtual voidvisit( FunctionDecl *functionDecl );37 void postvisit( ObjectDecl *objectDecl ); 38 void postvisit( FunctionDecl *functionDecl ); 38 39 39 v irtual voidvisit( CompoundStmt *compoundStmt );40 void previsit( CompoundStmt *compoundStmt ); 40 41 private: 41 42 int scopeLevel = 1; … … 93 94 } 94 95 95 void fixNames( std::list< Declaration* > translationUnit ) {96 FixNamesfixer;96 void fixNames( std::list< Declaration* > & translationUnit ) { 97 PassVisitor<FixNames> fixer; 97 98 acceptAll( translationUnit, fixer ); 98 99 } 99 100 100 void FixNames::fixDWT( DeclarationWithType * dwt ) {101 void FixNames::fixDWT( DeclarationWithType * dwt ) { 101 102 if ( dwt->get_name() != "" ) { 102 103 if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) { … … 107 108 } 108 109 109 void FixNames::visit( ObjectDecl *objectDecl ) { 110 Visitor::visit( objectDecl ); 110 void FixNames::postvisit( ObjectDecl * objectDecl ) { 111 111 fixDWT( objectDecl ); 112 112 } 113 113 114 void FixNames::visit( FunctionDecl *functionDecl ) { 115 Visitor::visit( functionDecl ); 114 void FixNames::postvisit( FunctionDecl * functionDecl ) { 116 115 fixDWT( functionDecl ); 117 116 … … 121 120 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 122 121 } 123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( n oLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );122 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) ); 124 123 CodeGen::FixMain::registerMain( functionDecl ); 125 124 } 126 125 } 127 126 128 void FixNames:: visit( CompoundStmt *compoundStmt) {127 void FixNames::previsit( CompoundStmt * ) { 129 128 scopeLevel++; 130 Visitor::visit( compoundStmt ); 131 scopeLevel--; 129 GuardAction( [this](){ scopeLevel--; } ); 132 130 } 133 131 } // namespace CodeGen -
src/CodeGen/FixNames.h
r882ad37 r3ca540f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixNames.h -- 7 // FixNames.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 22 22 namespace CodeGen { 23 23 /// mangles object and function names 24 void fixNames( std::list< Declaration* > translationUnit );24 void fixNames( std::list< Declaration* > & translationUnit ); 25 25 } // namespace CodeGen 26 26
Note: See TracChangeset
for help on using the changeset viewer.