Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixNames.cc

    rc50d54d rfa4c094  
    1919#include <string>                  // for string, operator!=, operator==
    2020
    21 #include "Common/PassVisitor.h"
    2221#include "Common/SemanticError.h"  // for SemanticError
    2322#include "FixMain.h"               // for FixMain
     
    3332
    3433namespace CodeGen {
    35         class FixNames : public WithGuards {
     34        class FixNames : public Visitor {
    3635          public:
    37                 void postvisit( ObjectDecl *objectDecl );
    38                 void postvisit( FunctionDecl *functionDecl );
     36                virtual void visit( ObjectDecl *objectDecl );
     37                virtual void visit( FunctionDecl *functionDecl );
    3938
    40                 void previsit( CompoundStmt *compoundStmt );
     39                virtual void visit( CompoundStmt *compoundStmt );
    4140          private:
    4241                int scopeLevel = 1;
     
    9493        }
    9594
    96         void fixNames( std::list< Declaration* > & translationUnit ) {
    97                 PassVisitor<FixNames> fixer;
     95        void fixNames( std::list< Declaration* > translationUnit ) {
     96                FixNames fixer;
    9897                acceptAll( translationUnit, fixer );
    9998        }
    10099
    101         void FixNames::fixDWT( DeclarationWithType * dwt ) {
     100        void FixNames::fixDWT( DeclarationWithType *dwt ) {
    102101                if ( dwt->get_name() != "" ) {
    103102                        if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) {
     
    108107        }
    109108
    110         void FixNames::postvisit( ObjectDecl * objectDecl ) {
     109        void FixNames::visit( ObjectDecl *objectDecl ) {
     110                Visitor::visit( objectDecl );
    111111                fixDWT( objectDecl );
    112112        }
    113113
    114         void FixNames::postvisit( FunctionDecl * functionDecl ) {
     114        void FixNames::visit( FunctionDecl *functionDecl ) {
     115                Visitor::visit( functionDecl );
    115116                fixDWT( functionDecl );
    116117
     
    120121                                throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
    121122                        }
    122                         functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) );
     123                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
    123124                        CodeGen::FixMain::registerMain( functionDecl );
    124125                }
    125126        }
    126127
    127         void FixNames::previsit( CompoundStmt * ) {
     128        void FixNames::visit( CompoundStmt *compoundStmt ) {
    128129                scopeLevel++;
    129                 GuardAction( [this](){ scopeLevel--; } );
     130                Visitor::visit( compoundStmt );
     131                scopeLevel--;
    130132        }
    131133} // namespace CodeGen
Note: See TracChangeset for help on using the changeset viewer.