Changes in src/CodeGen/FixNames.cc [c50d54d:fa4c094]
- File:
-
- 1 edited
-
src/CodeGen/FixNames.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
rc50d54d rfa4c094 19 19 #include <string> // for string, operator!=, operator== 20 20 21 #include "Common/PassVisitor.h"22 21 #include "Common/SemanticError.h" // for SemanticError 23 22 #include "FixMain.h" // for FixMain … … 33 32 34 33 namespace CodeGen { 35 class FixNames : public WithGuards{34 class FixNames : public Visitor { 36 35 public: 37 v oid postvisit( ObjectDecl *objectDecl );38 v oid postvisit( FunctionDecl *functionDecl );36 virtual void visit( ObjectDecl *objectDecl ); 37 virtual void visit( FunctionDecl *functionDecl ); 39 38 40 v oid previsit( CompoundStmt *compoundStmt );39 virtual void visit( CompoundStmt *compoundStmt ); 41 40 private: 42 41 int scopeLevel = 1; … … 94 93 } 95 94 96 void fixNames( std::list< Declaration* > &translationUnit ) {97 PassVisitor<FixNames>fixer;95 void fixNames( std::list< Declaration* > translationUnit ) { 96 FixNames fixer; 98 97 acceptAll( translationUnit, fixer ); 99 98 } 100 99 101 void FixNames::fixDWT( DeclarationWithType * dwt ) {100 void FixNames::fixDWT( DeclarationWithType *dwt ) { 102 101 if ( dwt->get_name() != "" ) { 103 102 if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) { … … 108 107 } 109 108 110 void FixNames::postvisit( ObjectDecl * objectDecl ) { 109 void FixNames::visit( ObjectDecl *objectDecl ) { 110 Visitor::visit( objectDecl ); 111 111 fixDWT( objectDecl ); 112 112 } 113 113 114 void FixNames::postvisit( FunctionDecl * functionDecl ) { 114 void FixNames::visit( FunctionDecl *functionDecl ) { 115 Visitor::visit( functionDecl ); 115 116 fixDWT( functionDecl ); 116 117 … … 120 121 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 121 122 } 122 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( n ew ConstantExpr( Constant::from_int( 0 ) ) ) );123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) ); 123 124 CodeGen::FixMain::registerMain( functionDecl ); 124 125 } 125 126 } 126 127 127 void FixNames:: previsit( CompoundStmt *) {128 void FixNames::visit( CompoundStmt *compoundStmt ) { 128 129 scopeLevel++; 129 GuardAction( [this](){ scopeLevel--; } ); 130 Visitor::visit( compoundStmt ); 131 scopeLevel--; 130 132 } 131 133 } // namespace CodeGen
Note:
See TracChangeset
for help on using the changeset viewer.