Changeset 3ca540f for src/CodeGen


Ignore:
Timestamp:
Dec 1, 2017, 2:55:41 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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.
Message:

Merge branch 'master' into with-statement

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixNames.cc

    r882ad37 r3ca540f  
    1919#include <string>                  // for string, operator!=, operator==
    2020
     21#include "Common/PassVisitor.h"
    2122#include "Common/SemanticError.h"  // for SemanticError
    2223#include "FixMain.h"               // for FixMain
     
    3233
    3334namespace CodeGen {
    34         class FixNames : public Visitor {
     35        class FixNames : public WithGuards {
    3536          public:
    36                 virtual void visit( ObjectDecl *objectDecl );
    37                 virtual void visit( FunctionDecl *functionDecl );
     37                void postvisit( ObjectDecl *objectDecl );
     38                void postvisit( FunctionDecl *functionDecl );
    3839
    39                 virtual void visit( CompoundStmt *compoundStmt );
     40                void previsit( CompoundStmt *compoundStmt );
    4041          private:
    4142                int scopeLevel = 1;
     
    9394        }
    9495
    95         void fixNames( std::list< Declaration* > translationUnit ) {
    96                 FixNames fixer;
     96        void fixNames( std::list< Declaration* > & translationUnit ) {
     97                PassVisitor<FixNames> fixer;
    9798                acceptAll( translationUnit, fixer );
    9899        }
    99100
    100         void FixNames::fixDWT( DeclarationWithType *dwt ) {
     101        void FixNames::fixDWT( DeclarationWithType * dwt ) {
    101102                if ( dwt->get_name() != "" ) {
    102103                        if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) {
     
    107108        }
    108109
    109         void FixNames::visit( ObjectDecl *objectDecl ) {
    110                 Visitor::visit( objectDecl );
     110        void FixNames::postvisit( ObjectDecl * objectDecl ) {
    111111                fixDWT( objectDecl );
    112112        }
    113113
    114         void FixNames::visit( FunctionDecl *functionDecl ) {
    115                 Visitor::visit( functionDecl );
     114        void FixNames::postvisit( FunctionDecl * functionDecl ) {
    116115                fixDWT( functionDecl );
    117116
     
    121120                                throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
    122121                        }
    123                         functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
     122                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) );
    124123                        CodeGen::FixMain::registerMain( functionDecl );
    125124                }
    126125        }
    127126
    128         void FixNames::visit( CompoundStmt *compoundStmt ) {
     127        void FixNames::previsit( CompoundStmt * ) {
    129128                scopeLevel++;
    130                 Visitor::visit( compoundStmt );
    131                 scopeLevel--;
     129                GuardAction( [this](){ scopeLevel--; } );
    132130        }
    133131} // namespace CodeGen
  • src/CodeGen/FixNames.h

    r882ad37 r3ca540f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixNames.h -- 
     7// FixNames.h --
    88//
    99// Author           : Richard C. Bilson
     
    2222namespace CodeGen {
    2323        /// mangles object and function names
    24         void fixNames( std::list< Declaration* > translationUnit );
     24        void fixNames( std::list< Declaration* > & translationUnit );
    2525} // namespace CodeGen
    2626
Note: See TracChangeset for help on using the changeset viewer.