Changeset d9a0e76 for translator/SynTree


Ignore:
Timestamp:
Dec 16, 2014, 9:41:50 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
17cd4eb
Parents:
3848e0e
Message:

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

Location:
translator/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/Initializer.cc

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Initializer.cc,v 1.10 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include "Initializer.h"
    92#include "Expression.h"
     
    114
    125
    13 Initializer::Initializer( )
    14 {
    15 }
     6Initializer::Initializer() {}
    167
    17 Initializer::~Initializer( )
    18 {
    19 }
     8Initializer::~Initializer() {}
    209
    2110std::string Initializer::designator_name( Expression *des ) {
    22     if( NameExpr *n = dynamic_cast<NameExpr *>(des) )
     11    if ( NameExpr *n = dynamic_cast<NameExpr *>(des) )
    2312        return n->get_name();
    2413    else
     
    2615}
    2716
    28 void
    29 Initializer::print( std::ostream &os, int indent )
    30 {
     17void Initializer::print( std::ostream &os, int indent ) {}
     18
     19SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators ) : value ( v ), designators( _designators ) {
    3120}
    3221
    33 SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators )
    34     : value ( v ), designators( _designators )
    35 {
    36 }
    37 
    38 SingleInit::SingleInit ( const SingleInit &other )
    39     : value ( other.value )
    40 {
     22SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) {
    4123    cloneAll(other.designators, designators );
    4224}
    4325
    44 SingleInit::~SingleInit()
    45 {
    46 }
     26SingleInit::~SingleInit() {}
    4727
    4828SingleInit *SingleInit::clone() const { return new SingleInit( *this); }
    4929
    50 void SingleInit::print( std::ostream &os, int indent )
    51 {
     30void SingleInit::print( std::ostream &os, int indent ) {
    5231    os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: ";
    5332    value->print( os, indent+2 );
    5433
    55     if ( ! designators.empty() )
    56         {
    57             os << std::endl << std::string(indent + 2, ' ' ) << "designated by: "  ;
    58             for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ )
    59                 ( *i )->print(os, indent + 4 );
    60         }
     34    if ( ! designators.empty() ) {
     35        os << std::endl << std::string(indent + 2, ' ' ) << "designated by: "  ;
     36        for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ )
     37            ( *i )->print(os, indent + 4 );
     38    }
    6139}
    6240
    63 MemberInit::MemberInit( Expression *_value, std::string _member )
    64     : member ( _member ), value ( _value )
    65 {
    66 }
     41MemberInit::MemberInit( Expression *_value, std::string _member ) : member ( _member ), value ( _value ) {}
    6742
    68 MemberInit::~MemberInit()
    69 {
    70 }
     43MemberInit::~MemberInit() {}
    7144
    72 MemberInit * MemberInit::clone() const
    73 {
     45MemberInit * MemberInit::clone() const {
    7446    return new MemberInit( *this );
    7547}
    7648
    77 void MemberInit::print( std::ostream &os, int indent )
    78 {
     49void MemberInit::print( std::ostream &os, int indent ) {
    7950    os << "Member Initializer";
    8051    value->print( os, indent+2 );
     
    8253
    8354ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
    84     : initializers( _initializers ), designators( _designators )
    85 {
     55    : initializers( _initializers ), designators( _designators ) {
    8656}
    8757
    88 ListInit::~ListInit()
    89 {
    90 }
     58ListInit::~ListInit() {}
    9159
    92 ListInit *ListInit::clone() const
    93 {
     60ListInit *ListInit::clone() const {
    9461    return new ListInit( *this );
    9562}
    9663
    97 void ListInit::print( std::ostream &os, int indent )
    98 {
     64void ListInit::print( std::ostream &os, int indent ) {
    9965    os << std::endl << std::string(indent, ' ') << "Compound initializer:  ";
    100     if( ! designators.empty() ) {
     66    if ( ! designators.empty() ) {
    10167        os << std::string(indent + 2, ' ' ) << "designated by: [";
    10268        for ( std::list < Expression * >::iterator i = designators.begin();
  • translator/SynTree/Initializer.h

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Initializer.h,v 1.14 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef INITIALIZER_H
    92#define INITIALIZER_H
     
    1710
    1811// Initializer: base class for object initializers (provide default values)
    19 class Initializer
    20 {
    21 public:
     12class Initializer {
     13  public:
    2214    //  Initializer( std::string _name = std::string(""), int _pos = 0 );
    2315    Initializer( );
     
    4133    virtual Initializer *acceptMutator( Mutator &m ) = 0;
    4234    virtual void print( std::ostream &os, int indent = 0 );
    43    
    44 private:
     35  private:
    4536    //  std::string name;
    4637    //  int pos;
     
    4839
    4940// SingleInit represents an initializer for a common object (e.g., int x = 4)
    50 class SingleInit : public Initializer
    51 {
    52 public:
     41class SingleInit : public Initializer {
     42  public:
    5343    SingleInit( Expression *value, std::list< Expression *> &designators );
    5444    SingleInit( const SingleInit &other );
     
    6555    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    6656    virtual void print( std::ostream &os, int indent = 0 );
    67    
    68 private:
     57  private:
    6958    //Constant *value;
    7059    Expression *value;  // has to be a compile-time constant
     
    7261};
    7362
    74 // MemberInit represents an initializer for a member of an aggregate object
    75 // (e.g., struct q { int a } x = { a: 4 } )
    76 class MemberInit : public Initializer
    77 {
    78 public:
     63// MemberInit represents an initializer for a member of an aggregate object (e.g., struct q { int a; } x = { a : 4 } )
     64class MemberInit : public Initializer {
     65  public:
    7966    MemberInit( Expression *value, std::string member = std::string("") );
    8067    virtual ~MemberInit();
     
    8976    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    9077    virtual void print( std::ostream &os, int indent = 0 );
    91    
    92 private:
     78  private:
    9379    std::string member;
    9480    Expression *value;
    9581};
    9682
    97 // ElementInit represents an initializer of an element of an array
    98 // (e.g., [10] int x = { [7]: 4 }
    99 class ElementInit : public Initializer
    100 {
    101 public:
     83// ElementInit represents an initializer of an element of an array (e.g., [10] int x = { [7] : 4 }
     84class ElementInit : public Initializer {
     85  public:
    10286    ElementInit( Expression *value );
    10387    virtual ~ElementInit();
     
    11296    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    11397    virtual void print( std::ostream &os, int indent = 0 );
    114    
    115 private:
     98  private:
    11699    int index;
    117100    Expression *value;
    118101};
    119102
    120 // ListInit represents an initializer that is composed recursively of a list of initializers; this
    121 // is used to initialize an array or aggregate
    122 class ListInit : public Initializer
    123 {
    124 public:
     103// ListInit represents an initializer that is composed recursively of a list of initializers; this is used to initialize
     104// an array or aggregate
     105class ListInit : public Initializer {
     106  public:
    125107    ListInit( std::list<Initializer*> &,
    126             std::list<Expression *> &designators = *(new std::list<Expression *>()) );
     108              std::list<Expression *> &designators = *(new std::list<Expression *>()) );
    127109    virtual ~ListInit();
    128110
     
    139121    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    140122    virtual void print( std::ostream &os, int indent = 0 );
    141    
    142 private:
     123  private:
    143124    std::list<Initializer*> initializers;  // order *is* important
    144125    std::list<Expression *> designators;
    145126};
    146127
    147 
    148 #endif /* #ifndef INITIALIZER_H */
    149 
    150 /*
    151     Local Variables:
    152     mode: c++
    153     End:
    154 */
     128#endif // INITIALIZER_H
  • translator/SynTree/Mutator.cc

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Mutator.cc,v 1.30 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <cassert>
    92#include "Mutator.h"
     
    169#include "utility.h"
    1710
    18 Mutator::Mutator()
    19 {
    20 }
    21 
    22 Mutator::~Mutator()
    23 {
    24 }
    25 
    26 ObjectDecl*
    27 Mutator::mutate(ObjectDecl *objectDecl)
    28 {
     11Mutator::Mutator() {}
     12
     13Mutator::~Mutator() {}
     14
     15ObjectDecl *Mutator::mutate( ObjectDecl *objectDecl ) {
    2916    objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
    3017    objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
     
    3320}
    3421
    35 DeclarationWithType*
    36 Mutator::mutate(FunctionDecl *functionDecl)
    37 {
     22DeclarationWithType *Mutator::mutate( FunctionDecl *functionDecl ) {
    3823    functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
    3924    mutateAll( functionDecl->get_oldDecls(), *this );
     
    4227}
    4328
    44 Declaration*
    45 Mutator::handleAggregateDecl(AggregateDecl *aggregateDecl)
    46 {
     29Declaration *Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
    4730    mutateAll( aggregateDecl->get_parameters(), *this );
    4831    mutateAll( aggregateDecl->get_members(), *this );
     
    5033}
    5134
    52 Declaration*
    53 Mutator::mutate(StructDecl *aggregateDecl)
    54 {
     35Declaration *Mutator::mutate( StructDecl *aggregateDecl ) {
    5536    handleAggregateDecl( aggregateDecl );
    5637    return aggregateDecl;
    5738}
    5839
    59 Declaration*
    60 Mutator::mutate(UnionDecl *aggregateDecl)
    61 {
     40Declaration *Mutator::mutate( UnionDecl *aggregateDecl ) {
    6241    handleAggregateDecl( aggregateDecl );
    6342    return aggregateDecl;
    6443}
    6544
    66 Declaration*
    67 Mutator::mutate(EnumDecl *aggregateDecl)
    68 {
     45Declaration *Mutator::mutate( EnumDecl *aggregateDecl ) {
    6946    handleAggregateDecl( aggregateDecl );
    7047    return aggregateDecl;
    7148}
    7249
    73 Declaration*
    74 Mutator::mutate(ContextDecl *aggregateDecl)
    75 {
     50Declaration *Mutator::mutate( ContextDecl *aggregateDecl ) {
    7651    handleAggregateDecl( aggregateDecl );
    7752    return aggregateDecl;
    7853}
    7954
    80 Declaration*
    81 Mutator::handleNamedTypeDecl(NamedTypeDecl *typeDecl)
    82 {
     55Declaration *Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
    8356    mutateAll( typeDecl->get_parameters(), *this );
    8457    mutateAll( typeDecl->get_assertions(), *this );
     
    8760}
    8861
    89 TypeDecl*
    90 Mutator::mutate(TypeDecl *typeDecl)
    91 {
     62TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) {
    9263    handleNamedTypeDecl( typeDecl );
    9364    return typeDecl;
    9465}
    9566
    96 Declaration*
    97 Mutator::mutate(TypedefDecl *typeDecl)
    98 {
     67Declaration *Mutator::mutate( TypedefDecl *typeDecl ) {
    9968    handleNamedTypeDecl( typeDecl );
    10069    return typeDecl;
    10170}
    10271
    103 CompoundStmt*
    104 Mutator::mutate(CompoundStmt *compoundStmt)
    105 {
     72CompoundStmt *Mutator::mutate( CompoundStmt *compoundStmt ) {
    10673    mutateAll( compoundStmt->get_kids(), *this );
    10774    return compoundStmt;
    10875}
    10976
    110 Statement*
    111 Mutator::mutate(ExprStmt *exprStmt)
    112 {
     77Statement *Mutator::mutate( ExprStmt *exprStmt ) {
    11378    exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
    11479    return exprStmt;
    11580}
    11681
    117 Statement*
    118 Mutator::mutate(IfStmt *ifStmt)
    119 {
    120     ifStmt->set_condition(  maybeMutate( ifStmt->get_condition(), *this ) );
    121     ifStmt->set_thenPart(  maybeMutate( ifStmt->get_thenPart(), *this ) );
    122     ifStmt->set_elsePart(  maybeMutate( ifStmt->get_elsePart(), *this ) );
     82Statement *Mutator::mutate( IfStmt *ifStmt ) {
     83    ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
     84    ifStmt->set_thenPart( maybeMutate( ifStmt->get_thenPart(), *this ) );
     85    ifStmt->set_elsePart( maybeMutate( ifStmt->get_elsePart(), *this ) );
    12386    return ifStmt;
    12487}
    12588
    126 Statement*
    127 Mutator::mutate(WhileStmt *whileStmt)
    128 {
    129     whileStmt->set_condition(  maybeMutate( whileStmt->get_condition(), *this ) );
    130     whileStmt->set_body(    maybeMutate( whileStmt->get_body(), *this ) );
     89Statement *Mutator::mutate( WhileStmt *whileStmt ) {
     90    whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
     91    whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) );
    13192    return whileStmt;
    13293}
    13394
    134 Statement*
    135 Mutator::mutate(ForStmt *forStmt)
    136 {
    137     forStmt->set_initialization(    maybeMutate( forStmt->get_initialization(), *this ) );
    138     forStmt->set_condition(  maybeMutate( forStmt->get_condition(), *this ) );
    139     forStmt->set_increment(  maybeMutate( forStmt->get_increment(), *this ) );
    140     forStmt->set_body(  maybeMutate( forStmt->get_body(), *this ) );
     95Statement *Mutator::mutate( ForStmt *forStmt ) {
     96    forStmt->set_initialization( maybeMutate( forStmt->get_initialization(), *this ) );
     97    forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) );
     98    forStmt->set_increment( maybeMutate( forStmt->get_increment(), *this ) );
     99    forStmt->set_body( maybeMutate( forStmt->get_body(), *this ) );
    141100    return forStmt;
    142101}
    143102
    144 Statement*
    145 Mutator::mutate(SwitchStmt *switchStmt)
    146 {
     103Statement *Mutator::mutate( SwitchStmt *switchStmt ) {
    147104    switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    148105    mutateAll( switchStmt->get_branches(), *this );
     
    150107}
    151108
    152 Statement*
    153 Mutator::mutate(ChooseStmt *switchStmt)
    154 {
    155     switchStmt->set_condition(  maybeMutate( switchStmt->get_condition(), *this ) );
     109Statement *Mutator::mutate( ChooseStmt *switchStmt ) {
     110    switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    156111    mutateAll( switchStmt->get_branches(), *this );
    157112    return switchStmt;
    158113}
    159114
    160 Statement*
    161 Mutator::mutate(FallthruStmt *fallthruStmt)
    162 {
     115Statement *Mutator::mutate( FallthruStmt *fallthruStmt ) {
    163116    return fallthruStmt;
    164117}
    165118
    166 Statement*
    167 Mutator::mutate(CaseStmt *caseStmt)
    168 {
    169     caseStmt->set_condition(    maybeMutate( caseStmt->get_condition(), *this ) );
     119Statement *Mutator::mutate( CaseStmt *caseStmt ) {
     120    caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
    170121    mutateAll (caseStmt->get_statements(), *this );
    171122
     
    173124}
    174125
    175 Statement*
    176 Mutator::mutate(BranchStmt *branchStmt)
    177 {
     126Statement *Mutator::mutate( BranchStmt *branchStmt ) {
    178127    return branchStmt;
    179128}
    180129
    181 Statement*
    182 Mutator::mutate(ReturnStmt *returnStmt)
    183 {
    184     returnStmt->set_expr(  maybeMutate( returnStmt->get_expr(), *this ) );
     130Statement *Mutator::mutate( ReturnStmt *returnStmt ) {
     131    returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
    185132    return returnStmt;
    186133}
    187134
    188 Statement*
    189 Mutator::mutate(TryStmt *tryStmt)
    190 {
     135Statement *Mutator::mutate( TryStmt *tryStmt ) {
    191136    tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    192137    mutateAll( tryStmt->get_catchers(), *this );
     
    194139}
    195140
    196 Statement*
    197 Mutator::mutate(CatchStmt *catchStmt)
    198 {
     141Statement *Mutator::mutate( CatchStmt *catchStmt ) {
    199142    catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
    200143    catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
     
    202145}
    203146
    204 Statement*
    205 Mutator::mutate(FinallyStmt *finalStmt)
    206 {
     147Statement *Mutator::mutate( FinallyStmt *finalStmt ) {
    207148    finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
    208149    return finalStmt;
    209150}
    210151
    211 NullStmt*
    212 Mutator::mutate(NullStmt *nullStmt)
    213 {
     152NullStmt *Mutator::mutate( NullStmt *nullStmt ) {
    214153    return nullStmt;
    215154}
    216155
    217 Statement*
    218 Mutator::mutate(DeclStmt *declStmt)
    219 {
     156Statement *Mutator::mutate( DeclStmt *declStmt ) {
    220157    declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
    221158    return declStmt;
    222159}
    223160
    224 Expression*
    225 Mutator::mutate(ApplicationExpr *applicationExpr)
    226 {
     161Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    227162    mutateAll( applicationExpr->get_results(), *this );
    228     applicationExpr->set_function(  maybeMutate( applicationExpr->get_function(), *this ) );
     163    applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    229164    mutateAll( applicationExpr->get_args(), *this );
    230165    return applicationExpr;
    231166}
    232167
    233 Expression*
    234 Mutator::mutate(UntypedExpr *untypedExpr)
    235 {
     168Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
    236169    mutateAll( untypedExpr->get_results(), *this );
    237170    mutateAll( untypedExpr->get_args(), *this );
     
    239172}
    240173
    241 Expression*
    242 Mutator::mutate(NameExpr *nameExpr)
    243 {
     174Expression *Mutator::mutate( NameExpr *nameExpr ) {
    244175    mutateAll( nameExpr->get_results(), *this );
    245176    return nameExpr;
    246177}
    247178
    248 Expression*
    249 Mutator::mutate(AddressExpr *addressExpr)
    250 {
     179Expression *Mutator::mutate( AddressExpr *addressExpr ) {
    251180    mutateAll( addressExpr->get_results(), *this );
    252     addressExpr->set_arg(  maybeMutate( addressExpr->get_arg(), *this ) );
     181    addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    253182    return addressExpr;
    254183}
    255184
    256 Expression*
    257 Mutator::mutate(LabelAddressExpr *labelAddressExpr)
    258 {
     185Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    259186    mutateAll( labelAddressExpr->get_results(), *this );
    260     labelAddressExpr->set_arg(  maybeMutate( labelAddressExpr->get_arg(), *this ) );
     187    labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    261188    return labelAddressExpr;
    262189}
    263190
    264 Expression*
    265 Mutator::mutate(CastExpr *castExpr)
    266 {
     191Expression *Mutator::mutate( CastExpr *castExpr ) {
    267192    mutateAll( castExpr->get_results(), *this );
    268     castExpr->set_arg(  maybeMutate( castExpr->get_arg(), *this ) );
     193    castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    269194    return castExpr;
    270195}
    271196
    272 Expression*
    273 Mutator::mutate(UntypedMemberExpr *memberExpr)
    274 {
     197Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    275198    mutateAll( memberExpr->get_results(), *this );
    276     memberExpr->set_aggregate(  maybeMutate( memberExpr->get_aggregate(), *this ) );
     199    memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    277200    return memberExpr;
    278201}
    279202
    280 Expression*
    281 Mutator::mutate(MemberExpr *memberExpr)
    282 {
     203Expression *Mutator::mutate( MemberExpr *memberExpr ) {
    283204    mutateAll( memberExpr->get_results(), *this );
    284     memberExpr->set_aggregate(  maybeMutate( memberExpr->get_aggregate(), *this ) );
     205    memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    285206    return memberExpr;
    286207}
    287208
    288 Expression*
    289 Mutator::mutate(VariableExpr *variableExpr)
    290 {
     209Expression *Mutator::mutate( VariableExpr *variableExpr ) {
    291210    mutateAll( variableExpr->get_results(), *this );
    292211    return variableExpr;
    293212}
    294213
    295 Expression*
    296 Mutator::mutate(ConstantExpr *constantExpr)
    297 {
     214Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
    298215    mutateAll( constantExpr->get_results(), *this );
    299216//  maybeMutate( constantExpr->get_constant(), *this )
     
    301218}
    302219
    303 Expression*
    304 Mutator::mutate(SizeofExpr *sizeofExpr)
    305 {
     220Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
    306221    mutateAll( sizeofExpr->get_results(), *this );
    307     if( sizeofExpr->get_isType() ) {
    308         sizeofExpr->set_type(    maybeMutate( sizeofExpr->get_type(), *this ) );
     222    if ( sizeofExpr->get_isType() ) {
     223        sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
    309224    } else {
    310         sizeofExpr->set_expr(    maybeMutate( sizeofExpr->get_expr(), *this ) );
     225        sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
    311226    }
    312227    return sizeofExpr;
    313228}
    314229
    315 Expression*
    316 Mutator::mutate(AttrExpr *attrExpr)
    317 {
     230Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    318231    mutateAll( attrExpr->get_results(), *this );
    319     if( attrExpr->get_isType() ) {
    320         attrExpr->set_type(      maybeMutate( attrExpr->get_type(), *this ) );
     232    if ( attrExpr->get_isType() ) {
     233        attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
    321234    } else {
    322         attrExpr->set_expr(      maybeMutate( attrExpr->get_expr(), *this ) );
     235        attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
    323236    }
    324237    return attrExpr;
    325238}
    326239
    327 Expression*
    328 Mutator::mutate(LogicalExpr *logicalExpr)
    329 {
     240Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
    330241    mutateAll( logicalExpr->get_results(), *this );
    331     logicalExpr->set_arg1(  maybeMutate( logicalExpr->get_arg1(), *this ) );
    332     logicalExpr->set_arg2(  maybeMutate( logicalExpr->get_arg2(), *this ) );
     242    logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
     243    logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
    333244    return logicalExpr;
    334245}
    335246
    336 Expression*
    337 Mutator::mutate(ConditionalExpr *conditionalExpr)
    338 {
     247Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    339248    mutateAll( conditionalExpr->get_results(), *this );
    340     conditionalExpr->set_arg1(  maybeMutate( conditionalExpr->get_arg1(), *this ) );
    341     conditionalExpr->set_arg2(  maybeMutate( conditionalExpr->get_arg2(), *this ) );
    342     conditionalExpr->set_arg3(  maybeMutate( conditionalExpr->get_arg3(), *this ) );
     249    conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
     250    conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
     251    conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
    343252    return conditionalExpr;
    344253}
    345254
    346 Expression*
    347 Mutator::mutate(CommaExpr *commaExpr)
    348 {
     255Expression *Mutator::mutate( CommaExpr *commaExpr ) {
    349256    mutateAll( commaExpr->get_results(), *this );
    350     commaExpr->set_arg1(    maybeMutate( commaExpr->get_arg1(), *this ) );
    351     commaExpr->set_arg2(    maybeMutate( commaExpr->get_arg2(), *this ) );
     257    commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
     258    commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
    352259    return commaExpr;
    353260}
    354261
    355 Expression*
    356 Mutator::mutate(TupleExpr *tupleExpr)
    357 {
     262Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
    358263    mutateAll( tupleExpr->get_results(), *this );
    359264    mutateAll( tupleExpr->get_exprs(), *this );
     
    361266}
    362267
    363 Expression*
    364 Mutator::mutate(SolvedTupleExpr *tupleExpr)
    365 {
     268Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {
    366269    mutateAll( tupleExpr->get_results(), *this );
    367270    mutateAll( tupleExpr->get_exprs(), *this );
     
    369272}
    370273
    371 Expression*
    372 Mutator::mutate(TypeExpr *typeExpr)
    373 {
     274Expression *Mutator::mutate( TypeExpr *typeExpr ) {
    374275    mutateAll( typeExpr->get_results(), *this );
    375276    typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
     
    377278}
    378279
    379 Expression*
    380 Mutator::mutate(UntypedValofExpr *valofExpr)
    381 {
     280Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    382281    mutateAll( valofExpr->get_results(), *this );
    383282    return valofExpr;
    384283}
    385284
    386 Type*
    387 Mutator::mutate(VoidType *voidType)
    388 {
     285Type *Mutator::mutate( VoidType *voidType ) {
    389286    mutateAll( voidType->get_forall(), *this );
    390287    return voidType;
    391288}
    392289
    393 Type*
    394 Mutator::mutate(BasicType *basicType)
    395 {
     290Type *Mutator::mutate( BasicType *basicType ) {
    396291    mutateAll( basicType->get_forall(), *this );
    397292    return basicType;
    398293}
    399294
    400 Type*
    401 Mutator::mutate(PointerType *pointerType)
    402 {
     295Type *Mutator::mutate( PointerType *pointerType ) {
    403296    mutateAll( pointerType->get_forall(), *this );
    404297    pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
     
    406299}
    407300
    408 Type*
    409 Mutator::mutate(ArrayType *arrayType)
    410 {
     301Type *Mutator::mutate( ArrayType *arrayType ) {
    411302    mutateAll( arrayType->get_forall(), *this );
    412303    arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
     
    415306}
    416307
    417 Type*
    418 Mutator::mutate(FunctionType *functionType)
    419 {
     308Type *Mutator::mutate( FunctionType *functionType ) {
    420309    mutateAll( functionType->get_forall(), *this );
    421310    mutateAll( functionType->get_returnVals(), *this );
     
    424313}
    425314
    426 Type*
    427 Mutator::handleReferenceToType(ReferenceToType *aggregateUseType)
    428 {
     315Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
    429316    mutateAll( aggregateUseType->get_forall(), *this );
    430317    mutateAll( aggregateUseType->get_parameters(), *this );
     
    432319}
    433320
    434 Type*
    435 Mutator::mutate(StructInstType *aggregateUseType)
    436 {
    437     handleReferenceToType( aggregateUseType );
    438     return aggregateUseType;
    439 }
    440 
    441 Type*
    442 Mutator::mutate(UnionInstType *aggregateUseType)
    443 {
    444     handleReferenceToType( aggregateUseType );
    445     return aggregateUseType;
    446 }
    447 
    448 Type*
    449 Mutator::mutate(EnumInstType *aggregateUseType)
    450 {
    451     handleReferenceToType( aggregateUseType );
    452     return aggregateUseType;
    453 }
    454 
    455 Type*
    456 Mutator::mutate(ContextInstType *aggregateUseType)
    457 {
     321Type *Mutator::mutate( StructInstType *aggregateUseType ) {
     322    handleReferenceToType( aggregateUseType );
     323    return aggregateUseType;
     324}
     325
     326Type *Mutator::mutate( UnionInstType *aggregateUseType ) {
     327    handleReferenceToType( aggregateUseType );
     328    return aggregateUseType;
     329}
     330
     331Type *Mutator::mutate( EnumInstType *aggregateUseType ) {
     332    handleReferenceToType( aggregateUseType );
     333    return aggregateUseType;
     334}
     335
     336Type *Mutator::mutate( ContextInstType *aggregateUseType ) {
    458337    handleReferenceToType( aggregateUseType );
    459338    mutateAll( aggregateUseType->get_members(), *this );
     
    461340}
    462341
    463 Type*
    464 Mutator::mutate(TypeInstType *aggregateUseType)
    465 {
    466     handleReferenceToType( aggregateUseType );
    467     return aggregateUseType;
    468 }
    469 
    470 Type*
    471 Mutator::mutate(TupleType *tupleType)
    472 {
     342Type *Mutator::mutate( TypeInstType *aggregateUseType ) {
     343    handleReferenceToType( aggregateUseType );
     344    return aggregateUseType;
     345}
     346
     347Type *Mutator::mutate( TupleType *tupleType ) {
    473348    mutateAll( tupleType->get_forall(), *this );
    474349    mutateAll( tupleType->get_types(), *this );
     
    476351}
    477352
    478 Type*
    479 Mutator::mutate(TypeofType *typeofType)
    480 {
     353Type *Mutator::mutate( TypeofType *typeofType ) {
    481354    assert( typeofType->get_expr() );
    482355    typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
     
    484357}
    485358
    486 Type*
    487 Mutator::mutate(AttrType *attrType)
    488 {
    489     if( attrType->get_isType() ) {
     359Type *Mutator::mutate( AttrType *attrType ) {
     360    if ( attrType->get_isType() ) {
    490361        assert( attrType->get_type() );
    491362        attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
     
    497368}
    498369
    499 Initializer*
    500 Mutator::mutate(MemberInit *memberInit)
    501 {
     370Initializer *Mutator::mutate( MemberInit *memberInit ) {
    502371    memberInit->set_value( memberInit->get_value()->acceptMutator( *this ) );
    503372    return memberInit;
    504373}
    505374
    506 Initializer*
    507 Mutator::mutate(ElementInit *elementInit)
    508 {
     375Initializer *Mutator::mutate( ElementInit *elementInit ) {
    509376    elementInit->set_value( elementInit->get_value()->acceptMutator( *this ) );
    510377    return elementInit;
    511378}
    512379
    513 Initializer*
    514 Mutator::mutate(SingleInit *singleInit)
    515 {
     380Initializer *Mutator::mutate( SingleInit *singleInit ) {
    516381    singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
    517382    return singleInit;
    518383}
    519384
    520 Initializer*
    521 Mutator::mutate(ListInit *listInit)
    522 {
     385Initializer *Mutator::mutate( ListInit *listInit ) {
    523386    mutateAll( listInit->get_designators(), *this );
    524387    mutateAll( listInit->get_initializers(), *this );
     
    526389}
    527390
    528 Subrange *
    529 Mutator::mutate(Subrange *subrange)
    530 {
     391Subrange *Mutator::mutate( Subrange *subrange ) {
    531392    return subrange;
    532393}
    533394
    534 Constant *
    535 Mutator::mutate(Constant *constant)
    536 {
     395Constant *Mutator::mutate( Constant *constant ) {
    537396    return constant;
    538397}
    539 
  • translator/SynTree/Mutator.h

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Mutator.h,v 1.19 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <cassert>
    92
     
    147#define SYNTREE_MUTATOR_H
    158
    16 
    17 class Mutator
    18 {
    19 protected:
     9class Mutator {
     10  protected:
    2011    Mutator();
    2112    virtual ~Mutator();
     13  public:
     14    virtual ObjectDecl* mutate( ObjectDecl *objectDecl );
     15    virtual DeclarationWithType* mutate( FunctionDecl *functionDecl );
     16    virtual Declaration* mutate( StructDecl *aggregateDecl );
     17    virtual Declaration* mutate( UnionDecl *aggregateDecl );
     18    virtual Declaration* mutate( EnumDecl *aggregateDecl );
     19    virtual Declaration* mutate( ContextDecl *aggregateDecl );
     20    virtual TypeDecl* mutate( TypeDecl *typeDecl );
     21    virtual Declaration* mutate( TypedefDecl *typeDecl );
    2222
    23 public:
    24     virtual ObjectDecl* mutate(ObjectDecl *objectDecl);
    25     virtual DeclarationWithType* mutate(FunctionDecl *functionDecl);
    26     virtual Declaration* mutate(StructDecl *aggregateDecl);
    27     virtual Declaration* mutate(UnionDecl *aggregateDecl);
    28     virtual Declaration* mutate(EnumDecl *aggregateDecl);
    29     virtual Declaration* mutate(ContextDecl *aggregateDecl);
    30     virtual TypeDecl* mutate(TypeDecl *typeDecl);
    31     virtual Declaration* mutate(TypedefDecl *typeDecl);
     23    virtual CompoundStmt* mutate( CompoundStmt *compoundStmt );
     24    virtual Statement* mutate( ExprStmt *exprStmt );
     25    virtual Statement* mutate( IfStmt *ifStmt );
     26    virtual Statement* mutate( WhileStmt *whileStmt );
     27    virtual Statement* mutate( ForStmt *forStmt );
     28    virtual Statement* mutate( SwitchStmt *switchStmt );
     29    virtual Statement* mutate( ChooseStmt *chooseStmt );
     30    virtual Statement* mutate( FallthruStmt *fallthruStmt );
     31    virtual Statement* mutate( CaseStmt *caseStmt );
     32    virtual Statement* mutate( BranchStmt *branchStmt );
     33    virtual Statement* mutate( ReturnStmt *returnStmt );
     34    virtual Statement* mutate( TryStmt *returnStmt );
     35    virtual Statement* mutate( CatchStmt *catchStmt );
     36    virtual Statement* mutate( FinallyStmt *catchStmt );
     37    virtual NullStmt* mutate( NullStmt *nullStmt );
     38    virtual Statement* mutate( DeclStmt *declStmt );
    3239
    33     virtual CompoundStmt* mutate(CompoundStmt *compoundStmt);
    34     virtual Statement* mutate(ExprStmt *exprStmt);
    35     virtual Statement* mutate(IfStmt *ifStmt);
    36     virtual Statement* mutate(WhileStmt *whileStmt);
    37     virtual Statement* mutate(ForStmt *forStmt);
    38     virtual Statement* mutate(SwitchStmt *switchStmt);
    39     virtual Statement* mutate(ChooseStmt *chooseStmt);
    40     virtual Statement* mutate(FallthruStmt *fallthruStmt);
    41     virtual Statement* mutate(CaseStmt *caseStmt);
    42     virtual Statement* mutate(BranchStmt *branchStmt);
    43     virtual Statement* mutate(ReturnStmt *returnStmt);
    44     virtual Statement* mutate(TryStmt *returnStmt);
    45     virtual Statement* mutate(CatchStmt *catchStmt);
    46     virtual Statement* mutate(FinallyStmt *catchStmt);
    47     virtual NullStmt* mutate(NullStmt *nullStmt);
    48     virtual Statement* mutate(DeclStmt *declStmt);
     40    virtual Expression* mutate( ApplicationExpr *applicationExpr );
     41    virtual Expression* mutate( UntypedExpr *untypedExpr );
     42    virtual Expression* mutate( NameExpr *nameExpr );
     43    virtual Expression* mutate( AddressExpr *castExpr );
     44    virtual Expression* mutate( LabelAddressExpr *labAddressExpr );
     45    virtual Expression* mutate( CastExpr *castExpr );
     46    virtual Expression* mutate( UntypedMemberExpr *memberExpr );
     47    virtual Expression* mutate( MemberExpr *memberExpr );
     48    virtual Expression* mutate( VariableExpr *variableExpr );
     49    virtual Expression* mutate( ConstantExpr *constantExpr );
     50    virtual Expression* mutate( SizeofExpr *sizeofExpr );
     51    virtual Expression* mutate( AttrExpr *attrExpr );
     52    virtual Expression* mutate( LogicalExpr *logicalExpr );
     53    virtual Expression* mutate( ConditionalExpr *conditionalExpr );
     54    virtual Expression* mutate( CommaExpr *commaExpr );
     55    virtual Expression* mutate( TupleExpr *tupleExpr );
     56    virtual Expression* mutate( SolvedTupleExpr *tupleExpr );
     57    virtual Expression* mutate( TypeExpr *typeExpr );
     58    virtual Expression* mutate( UntypedValofExpr *valofExpr );
    4959
    50     virtual Expression* mutate(ApplicationExpr *applicationExpr);
    51     virtual Expression* mutate(UntypedExpr *untypedExpr);
    52     virtual Expression* mutate(NameExpr *nameExpr);
    53     virtual Expression* mutate(AddressExpr *castExpr);
    54     virtual Expression* mutate(LabelAddressExpr *labAddressExpr);
    55     virtual Expression* mutate(CastExpr *castExpr);
    56     virtual Expression* mutate(UntypedMemberExpr *memberExpr);
    57     virtual Expression* mutate(MemberExpr *memberExpr);
    58     virtual Expression* mutate(VariableExpr *variableExpr);
    59     virtual Expression* mutate(ConstantExpr *constantExpr);
    60     virtual Expression* mutate(SizeofExpr *sizeofExpr);
    61     virtual Expression* mutate(AttrExpr *attrExpr);
    62     virtual Expression* mutate(LogicalExpr *logicalExpr);
    63     virtual Expression* mutate(ConditionalExpr *conditionalExpr);
    64     virtual Expression* mutate(CommaExpr *commaExpr);
    65     virtual Expression* mutate(TupleExpr *tupleExpr);
    66     virtual Expression* mutate(SolvedTupleExpr *tupleExpr);
    67     virtual Expression* mutate(TypeExpr *typeExpr);
    68     virtual Expression* mutate(UntypedValofExpr *valofExpr);
     60    virtual Type* mutate( VoidType *basicType );
     61    virtual Type* mutate( BasicType *basicType );
     62    virtual Type* mutate( PointerType *pointerType );
     63    virtual Type* mutate( ArrayType *arrayType );
     64    virtual Type* mutate( FunctionType *functionType );
     65    virtual Type* mutate( StructInstType *aggregateUseType );
     66    virtual Type* mutate( UnionInstType *aggregateUseType );
     67    virtual Type* mutate( EnumInstType *aggregateUseType );
     68    virtual Type* mutate( ContextInstType *aggregateUseType );
     69    virtual Type* mutate( TypeInstType *aggregateUseType );
     70    virtual Type* mutate( TupleType *tupleType );
     71    virtual Type* mutate( TypeofType *typeofType );
     72    virtual Type* mutate( AttrType *attrType );
    6973
    70     virtual Type* mutate(VoidType *basicType);
    71     virtual Type* mutate(BasicType *basicType);
    72     virtual Type* mutate(PointerType *pointerType);
    73     virtual Type* mutate(ArrayType *arrayType);
    74     virtual Type* mutate(FunctionType *functionType);
    75     virtual Type* mutate(StructInstType *aggregateUseType);
    76     virtual Type* mutate(UnionInstType *aggregateUseType);
    77     virtual Type* mutate(EnumInstType *aggregateUseType);
    78     virtual Type* mutate(ContextInstType *aggregateUseType);
    79     virtual Type* mutate(TypeInstType *aggregateUseType);
    80     virtual Type* mutate(TupleType *tupleType);
    81     virtual Type* mutate(TypeofType *typeofType);
    82     virtual Type* mutate(AttrType *attrType);
     74    virtual Initializer* mutate( MemberInit *memberInit );
     75    virtual Initializer* mutate( ElementInit *elementInit );
     76    virtual Initializer* mutate( SingleInit *singleInit );
     77    virtual Initializer* mutate( ListInit *listInit );
    8378
    84     virtual Initializer* mutate(MemberInit *memberInit);
    85     virtual Initializer* mutate(ElementInit *elementInit);
    86     virtual Initializer* mutate(SingleInit *singleInit);
    87     virtual Initializer* mutate(ListInit *listInit);
     79    virtual Subrange *mutate( Subrange *subrange );
    8880
    89     virtual Subrange *mutate(Subrange *subrange);
    90 
    91     virtual Constant *mutate(Constant *constant);
    92 
    93 private:
    94     virtual Declaration* handleAggregateDecl(AggregateDecl *aggregateDecl);
    95     virtual Declaration* handleNamedTypeDecl(NamedTypeDecl *typeDecl);
    96     virtual Type* handleReferenceToType(ReferenceToType *aggregateUseType);
     81    virtual Constant *mutate( Constant *constant );
     82  private:
     83    virtual Declaration* handleAggregateDecl(AggregateDecl *aggregateDecl );
     84    virtual Declaration* handleNamedTypeDecl(NamedTypeDecl *typeDecl );
     85    virtual Type* handleReferenceToType(ReferenceToType *aggregateUseType );
    9786};
    9887
    9988template< typename TreeType, typename MutatorType >
    100 inline TreeType *
    101 maybeMutate( TreeType *tree, MutatorType &mutator )
    102 {
    103     if( tree ) {
     89inline TreeType *maybeMutate( TreeType *tree, MutatorType &mutator ) {
     90    if ( tree ) {
    10491        TreeType *newnode = dynamic_cast< TreeType* >( tree->acceptMutator( mutator ) );
    10592        assert( newnode );
     
    11299
    113100template< typename Container, typename MutatorType >
    114 inline void
    115 mutateAll( Container &container, MutatorType &mutator )
    116 {
     101inline void mutateAll( Container &container, MutatorType &mutator ) {
    117102    SemanticError errors;
    118     for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     103    for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    119104        try {
    120             if( *i ) {
     105            if ( *i ) {
    121106///                 *i = (*i)->acceptMutator( mutator );
    122107                *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
     
    127112        }
    128113    }
    129     if( !errors.isEmpty() ) {
     114    if ( !errors.isEmpty() ) {
    130115        throw errors;
    131116    }
    132117}
    133118
    134 
    135 
    136 #endif /* #ifndef SYNTREE_MUTATOR_H */
     119#endif // SYNTREE_MUTATOR_H
    137120
    138121// Local Variables: //
  • translator/SynTree/ObjectDecl.cc

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: ObjectDecl.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include "Declaration.h"
    92#include "Type.h"
     
    147
    158ObjectDecl::ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init )
    16     : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth )
    17 {
     9    : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    1810}
    1911
    2012ObjectDecl::ObjectDecl( const ObjectDecl &other )
    21     : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) )
    22 {
     13    : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
    2314}
    2415
    25 ObjectDecl::~ObjectDecl()
    26 {
     16ObjectDecl::~ObjectDecl() {
    2717    delete type;
    2818    delete init;
     
    3020}
    3121
    32 void
    33 ObjectDecl::print( std::ostream &os, int indent ) const
    34 {
    35     if( get_name() != "" ) {
     22void ObjectDecl::print( std::ostream &os, int indent ) const {
     23    if ( get_name() != "" ) {
    3624        os << get_name() << ": a ";
    3725    }
    38     if( get_linkage() != LinkageSpec::Cforall ) {
     26
     27    if ( get_linkage() != LinkageSpec::Cforall ) {
    3928        os << LinkageSpec::toString( get_linkage() ) << " ";
    4029    }
    41     if( get_storageClass() != NoStorageClass ) {
     30
     31    if ( get_storageClass() != NoStorageClass ) {
    4232        os << storageClassName[ get_storageClass() ] << ' ';
    4333    }
    44     if( get_type() ) {
     34
     35    if ( get_type() ) {
    4536        get_type()->print( os, indent );
    4637    } else {
    4738        os << "untyped entity ";
    4839    }
    49     if( init ) {
     40
     41    if ( init ) {
    5042        os << "with initializer ";
    5143        init->print( os, indent );
    5244    }
    53     if( bitfieldWidth ) {
     45
     46    if ( bitfieldWidth ) {
    5447        os << "with bitfield width ";
    5548        bitfieldWidth->print( os );
     
    5750}
    5851
    59 void
    60 ObjectDecl::printShort( std::ostream &os, int indent ) const
    61 {
    62     if( get_name() != "" ) {
     52void ObjectDecl::printShort( std::ostream &os, int indent ) const {
     53    if ( get_name() != "" ) {
    6354        os << get_name() << ": a ";
    6455    }
    65     if( get_storageClass() != NoStorageClass ) {
     56
     57    if ( get_storageClass() != NoStorageClass ) {
    6658        os << storageClassName[ get_storageClass() ] << ' ';
    6759    }
    68     if( get_type() ) {
     60
     61    if ( get_type() ) {
    6962        get_type()->print( os, indent );
    7063    } else {
    7164        os << "untyped entity ";
    7265    }
    73     if( bitfieldWidth ) {
     66
     67    if ( bitfieldWidth ) {
    7468        os << "with bitfield width ";
    7569        bitfieldWidth->print( os );
    7670    }
    7771}
    78 
  • translator/SynTree/Visitor.cc

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Visitor.cc,v 1.30 2005/08/29 20:59:27 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <cassert>
    92#include "Visitor.h"
     
    169
    1710
    18 Visitor::Visitor()
    19 {
    20 }
    21 
    22 Visitor::~Visitor()
    23 {
    24 }
    25 
    26 void
    27 Visitor::visit(ObjectDecl *objectDecl)
    28 {
     11Visitor::Visitor() {}
     12
     13Visitor::~Visitor() {}
     14
     15void Visitor::visit(ObjectDecl *objectDecl) {
    2916    maybeAccept( objectDecl->get_type(), *this );
    3017    maybeAccept( objectDecl->get_init(), *this );
     
    3219}
    3320
    34 void
    35 Visitor::visit(FunctionDecl *functionDecl)
    36 {
     21void Visitor::visit(FunctionDecl *functionDecl) {
    3722    maybeAccept( functionDecl->get_functionType(), *this );
    3823    acceptAll( functionDecl->get_oldDecls(), *this );
     
    4025}
    4126
    42 void
    43 Visitor::visit(AggregateDecl *aggregateDecl)
    44 {
     27void Visitor::visit(AggregateDecl *aggregateDecl) {
    4528    acceptAll( aggregateDecl->get_parameters(), *this );
    4629    acceptAll( aggregateDecl->get_members(), *this );
    4730}
    4831
    49 void
    50 Visitor::visit(StructDecl *aggregateDecl)
    51 {
     32void Visitor::visit(StructDecl *aggregateDecl) {
    5233    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
    5334}
    5435
    55 void
    56 Visitor::visit(UnionDecl *aggregateDecl)
    57 {
     36void Visitor::visit(UnionDecl *aggregateDecl) {
    5837    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
    5938}
    6039
    61 void
    62 Visitor::visit(EnumDecl *aggregateDecl)
    63 {
     40void Visitor::visit(EnumDecl *aggregateDecl) {
    6441    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
    6542}
    6643
    67 void
    68 Visitor::visit(ContextDecl *aggregateDecl)
    69 {
     44void Visitor::visit(ContextDecl *aggregateDecl) {
    7045    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
    7146}
    7247
    73 void
    74 Visitor::visit(NamedTypeDecl *typeDecl)
    75 {
     48void Visitor::visit(NamedTypeDecl *typeDecl) {
    7649    acceptAll( typeDecl->get_parameters(), *this );
    7750    acceptAll( typeDecl->get_assertions(), *this );
     
    7952}
    8053
    81 void
    82 Visitor::visit(TypeDecl *typeDecl)
    83 {
     54void Visitor::visit(TypeDecl *typeDecl) {
    8455    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
    8556}
    8657
    87 void
    88 Visitor::visit(TypedefDecl *typeDecl)
    89 {
     58void Visitor::visit(TypedefDecl *typeDecl) {
    9059    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
    9160}
    9261
    93 void
    94 Visitor::visit(CompoundStmt *compoundStmt)
    95 {
     62void Visitor::visit(CompoundStmt *compoundStmt) {
    9663    acceptAll( compoundStmt->get_kids(), *this );
    9764}
    9865
    99 void
    100 Visitor::visit(ExprStmt *exprStmt)
    101 {
     66void Visitor::visit(ExprStmt *exprStmt) {
    10267    maybeAccept( exprStmt->get_expr(), *this );
    10368}
    10469
    105 void
    106 Visitor::visit(IfStmt *ifStmt)
    107 {
     70void Visitor::visit(IfStmt *ifStmt) {
    10871    maybeAccept( ifStmt->get_condition(), *this );
    10972    maybeAccept( ifStmt->get_thenPart(), *this );
     
    11174}
    11275
    113 void
    114 Visitor::visit(WhileStmt *whileStmt)
    115 {
     76void Visitor::visit(WhileStmt *whileStmt) {
    11677    maybeAccept( whileStmt->get_condition(), *this );
    11778    maybeAccept( whileStmt->get_body(), *this );
    11879}
    11980
    120 void
    121 Visitor::visit(ForStmt *forStmt)
    122 {
     81void Visitor::visit(ForStmt *forStmt) {
    12382    // ForStmt still needs to be fixed
    12483    maybeAccept( forStmt->get_initialization(), *this );
     
    12887}
    12988
    130 void
    131 Visitor::visit(SwitchStmt *switchStmt)
    132 {
     89void Visitor::visit(SwitchStmt *switchStmt) {
    13390    maybeAccept( switchStmt->get_condition(), *this );
    13491    acceptAll( switchStmt->get_branches(), *this );
    13592}
    13693
    137 void
    138 Visitor::visit(ChooseStmt *switchStmt)
    139 {
     94void Visitor::visit(ChooseStmt *switchStmt) {
    14095    maybeAccept( switchStmt->get_condition(), *this );
    14196    acceptAll( switchStmt->get_branches(), *this );
    14297}
    14398
    144 void
    145 Visitor::visit(FallthruStmt *fallthruStmt){}
    146 
    147 void
    148 Visitor::visit(CaseStmt *caseStmt)
    149 {
     99void Visitor::visit(FallthruStmt *fallthruStmt){}
     100
     101void Visitor::visit(CaseStmt *caseStmt) {
    150102    maybeAccept( caseStmt->get_condition(), *this );
    151103    acceptAll( caseStmt->get_statements(), *this );
    152104}
    153105
    154 void
    155 Visitor::visit(BranchStmt *branchStmt)
    156 {
    157 }
    158 
    159 void
    160 Visitor::visit(ReturnStmt *returnStmt)
    161 {
     106void Visitor::visit(BranchStmt *branchStmt) {
     107}
     108
     109void Visitor::visit(ReturnStmt *returnStmt) {
    162110    maybeAccept( returnStmt->get_expr(), *this );
    163111}
    164112
    165 void
    166 Visitor::visit(TryStmt *tryStmt)
    167 {
     113void Visitor::visit(TryStmt *tryStmt) {
    168114    maybeAccept( tryStmt->get_block(), *this );
    169115    acceptAll( tryStmt->get_catchers(), *this );
    170116}
    171117
    172 void
    173 Visitor::visit(CatchStmt *catchStmt)
    174 {
     118void Visitor::visit(CatchStmt *catchStmt) {
    175119    maybeAccept( catchStmt->get_decl(), *this );
    176120    maybeAccept( catchStmt->get_body(), *this );
    177121}
    178122
    179 void
    180 Visitor::visit(FinallyStmt *finalStmt)
    181 {
     123void Visitor::visit(FinallyStmt *finalStmt) {
    182124    maybeAccept( finalStmt->get_block(), *this );
    183125}
    184126
    185 void
    186 Visitor::visit(NullStmt *nullStmt)
    187 {
    188 }
    189 
    190 void
    191 Visitor::visit(DeclStmt *declStmt)
    192 {
     127void Visitor::visit(NullStmt *nullStmt) {
     128}
     129
     130void Visitor::visit(DeclStmt *declStmt) {
    193131    maybeAccept( declStmt->get_decl(), *this );
    194132}
    195133
    196 void
    197 Visitor::visit(ApplicationExpr *applicationExpr)
    198 {
     134void Visitor::visit(ApplicationExpr *applicationExpr) {
    199135    acceptAll( applicationExpr->get_results(), *this );
    200136    maybeAccept( applicationExpr->get_function(), *this );
     
    202138}
    203139
    204 void
    205 Visitor::visit(UntypedExpr *untypedExpr)
    206 {
     140void Visitor::visit(UntypedExpr *untypedExpr) {
    207141    acceptAll( untypedExpr->get_results(), *this );
    208142    acceptAll( untypedExpr->get_args(), *this );
    209143}
    210144
    211 void
    212 Visitor::visit(NameExpr *nameExpr)
    213 {
     145void Visitor::visit(NameExpr *nameExpr) {
    214146    acceptAll( nameExpr->get_results(), *this );
    215147}
    216148
    217 void
    218 Visitor::visit(AddressExpr *addressExpr)
    219 {
     149void Visitor::visit(AddressExpr *addressExpr) {
    220150    acceptAll( addressExpr->get_results(), *this );
    221151    maybeAccept( addressExpr->get_arg(), *this );
    222152}
    223153
    224 void
    225 Visitor::visit(LabelAddressExpr *labAddressExpr)
    226 {
     154void Visitor::visit(LabelAddressExpr *labAddressExpr) {
    227155    acceptAll( labAddressExpr->get_results(), *this );
    228156    maybeAccept( labAddressExpr->get_arg(), *this );
    229157}
    230158
    231 void
    232 Visitor::visit(CastExpr *castExpr)
    233 {
     159void Visitor::visit(CastExpr *castExpr) {
    234160    acceptAll( castExpr->get_results(), *this );
    235161    maybeAccept( castExpr->get_arg(), *this );
    236162}
    237163
    238 void
    239 Visitor::visit(UntypedMemberExpr *memberExpr)
    240 {
     164void Visitor::visit(UntypedMemberExpr *memberExpr) {
    241165    acceptAll( memberExpr->get_results(), *this );
    242166    maybeAccept( memberExpr->get_aggregate(), *this );
    243167}
    244168
    245 void
    246 Visitor::visit(MemberExpr *memberExpr)
    247 {
     169void Visitor::visit(MemberExpr *memberExpr) {
    248170    acceptAll( memberExpr->get_results(), *this );
    249171    maybeAccept( memberExpr->get_aggregate(), *this );
    250172}
    251173
    252 void
    253 Visitor::visit(VariableExpr *variableExpr)
    254 {
     174void Visitor::visit(VariableExpr *variableExpr) {
    255175    acceptAll( variableExpr->get_results(), *this );
    256176}
    257177
    258 void
    259 Visitor::visit(ConstantExpr *constantExpr)
    260 {
     178void Visitor::visit(ConstantExpr *constantExpr) {
    261179    acceptAll( constantExpr->get_results(), *this );
    262180    maybeAccept( constantExpr->get_constant(), *this );
    263181}
    264182
    265 void
    266 Visitor::visit(SizeofExpr *sizeofExpr)
    267 {
     183void Visitor::visit(SizeofExpr *sizeofExpr) {
    268184    acceptAll( sizeofExpr->get_results(), *this );
    269     if( sizeofExpr->get_isType() ) {
     185    if ( sizeofExpr->get_isType() ) {
    270186        maybeAccept( sizeofExpr->get_type(), *this );
    271187    } else {
     
    274190}
    275191
    276 void
    277 Visitor::visit(AttrExpr *attrExpr)
    278 {
     192void Visitor::visit(AttrExpr *attrExpr) {
    279193    acceptAll( attrExpr->get_results(), *this );
    280     if( attrExpr->get_isType() ) {
     194    if ( attrExpr->get_isType() ) {
    281195        maybeAccept( attrExpr->get_type(), *this );
    282196    } else {
     
    285199}
    286200
    287 void
    288 Visitor::visit(LogicalExpr *logicalExpr)
    289 {
     201void Visitor::visit(LogicalExpr *logicalExpr) {
    290202    acceptAll( logicalExpr->get_results(), *this );
    291203    maybeAccept( logicalExpr->get_arg1(), *this );
     
    293205}
    294206
    295 void
    296 Visitor::visit(ConditionalExpr *conditionalExpr)
    297 {
     207void Visitor::visit(ConditionalExpr *conditionalExpr) {
    298208    acceptAll( conditionalExpr->get_results(), *this );
    299209    maybeAccept( conditionalExpr->get_arg1(), *this );
     
    302212}
    303213
    304 void
    305 Visitor::visit(CommaExpr *commaExpr)
    306 {
     214void Visitor::visit(CommaExpr *commaExpr) {
    307215    acceptAll( commaExpr->get_results(), *this );
    308216    maybeAccept( commaExpr->get_arg1(), *this );
     
    310218}
    311219
    312 void
    313 Visitor::visit(TupleExpr *tupleExpr)
    314 {
     220void Visitor::visit(TupleExpr *tupleExpr) {
    315221    acceptAll( tupleExpr->get_results(), *this );
    316222    acceptAll( tupleExpr->get_exprs(), *this );
    317223}
    318224
    319 void
    320 Visitor::visit(SolvedTupleExpr *tupleExpr)
    321 {
     225void Visitor::visit(SolvedTupleExpr *tupleExpr) {
    322226    acceptAll( tupleExpr->get_results(), *this );
    323227    acceptAll( tupleExpr->get_exprs(), *this );
    324228}
    325229
    326 void
    327 Visitor::visit(TypeExpr *typeExpr)
    328 {
     230void Visitor::visit(TypeExpr *typeExpr) {
    329231    acceptAll( typeExpr->get_results(), *this );
    330232    maybeAccept( typeExpr->get_type(), *this );
    331233}
    332234
    333 void
    334 Visitor::visit(UntypedValofExpr *valofExpr)
    335 {
     235void Visitor::visit(UntypedValofExpr *valofExpr) {
    336236    acceptAll( valofExpr->get_results(), *this );
    337237    maybeAccept( valofExpr->get_body(), *this );
    338238}
    339239
    340 void
    341 Visitor::visit(VoidType *voidType)
    342 {
     240void Visitor::visit(VoidType *voidType) {
    343241    acceptAll( voidType->get_forall(), *this );
    344242}
    345243
    346 void
    347 Visitor::visit(BasicType *basicType)
    348 {
     244void Visitor::visit(BasicType *basicType) {
    349245    acceptAll( basicType->get_forall(), *this );
    350246}
    351247
    352 void
    353 Visitor::visit(PointerType *pointerType)
    354 {
     248void Visitor::visit(PointerType *pointerType) {
    355249    acceptAll( pointerType->get_forall(), *this );
    356250    maybeAccept( pointerType->get_base(), *this );
    357251}
    358252
    359 void
    360 Visitor::visit(ArrayType *arrayType)
    361 {
     253void Visitor::visit(ArrayType *arrayType) {
    362254    acceptAll( arrayType->get_forall(), *this );
    363255    maybeAccept( arrayType->get_dimension(), *this );
     
    365257}
    366258
    367 void
    368 Visitor::visit(FunctionType *functionType)
    369 {
     259void Visitor::visit(FunctionType *functionType) {
    370260    acceptAll( functionType->get_forall(), *this );
    371261    acceptAll( functionType->get_returnVals(), *this );
     
    373263}
    374264
    375 void
    376 Visitor::visit(ReferenceToType *aggregateUseType)
    377 {
     265void Visitor::visit(ReferenceToType *aggregateUseType) {
    378266    acceptAll( aggregateUseType->get_forall(), *this );
    379267    acceptAll( aggregateUseType->get_parameters(), *this );
    380268}
    381269
    382 void
    383 Visitor::visit(StructInstType *aggregateUseType)
    384 {
    385     visit( static_cast< ReferenceToType* >( aggregateUseType ) );
    386 }
    387 
    388 void
    389 Visitor::visit(UnionInstType *aggregateUseType)
    390 {
    391     visit( static_cast< ReferenceToType* >( aggregateUseType ) );
    392 }
    393 
    394 void
    395 Visitor::visit(EnumInstType *aggregateUseType)
    396 {
    397     visit( static_cast< ReferenceToType* >( aggregateUseType ) );
    398 }
    399 
    400 void
    401 Visitor::visit(ContextInstType *aggregateUseType)
    402 {
     270void Visitor::visit(StructInstType *aggregateUseType) {
     271    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
     272}
     273
     274void Visitor::visit(UnionInstType *aggregateUseType) {
     275    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
     276}
     277
     278void Visitor::visit(EnumInstType *aggregateUseType) {
     279    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
     280}
     281
     282void Visitor::visit(ContextInstType *aggregateUseType) {
    403283    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
    404284    acceptAll( aggregateUseType->get_members(), *this );
    405285}
    406286
    407 void
    408 Visitor::visit(TypeInstType *aggregateUseType)
    409 {
    410     visit( static_cast< ReferenceToType* >( aggregateUseType ) );
    411 }
    412 
    413 void
    414 Visitor::visit(TupleType *tupleType)
    415 {
     287void Visitor::visit(TypeInstType *aggregateUseType) {
     288    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
     289}
     290
     291void Visitor::visit(TupleType *tupleType) {
    416292    acceptAll( tupleType->get_forall(), *this );
    417293    acceptAll( tupleType->get_types(), *this );
    418294}
    419295
    420 void
    421 Visitor::visit(TypeofType *typeofType)
    422 {
     296void Visitor::visit(TypeofType *typeofType) {
    423297    assert( typeofType->get_expr() );
    424298    typeofType->get_expr()->accept( *this );
    425299}
    426300
    427 void
    428 Visitor::visit(AttrType *attrType)
    429 {
    430     if( attrType->get_isType() ) {
     301void Visitor::visit(AttrType *attrType) {
     302    if ( attrType->get_isType() ) {
    431303        assert( attrType->get_type() );
    432304        attrType->get_type()->accept( *this );
     
    437309}
    438310
    439 void
    440 Visitor::visit(MemberInit *memberInit)
    441 {
     311void Visitor::visit(MemberInit *memberInit) {
    442312    memberInit->get_value()->accept( *this );
    443313}
    444314
    445 void
    446 Visitor::visit(ElementInit *elementInit)
    447 {
     315void Visitor::visit(ElementInit *elementInit) {
    448316    elementInit->get_value()->accept( *this );
    449317}
    450318
    451 void
    452 Visitor::visit(SingleInit *singleInit)
    453 {
     319void Visitor::visit(SingleInit *singleInit) {
    454320    singleInit->get_value()->accept( *this );
    455321}
    456322
    457 void
    458 Visitor::visit(ListInit *listInit)
    459 {
     323void Visitor::visit(ListInit *listInit) {
    460324    acceptAll( listInit->get_designators(), *this );
    461325    acceptAll( listInit->get_initializers(), *this );
    462326}
    463327
    464 void
    465 Visitor::visit(Subrange *subrange)
    466 {
    467 }
    468 
    469 void
    470 Visitor::visit(Constant *constant)
    471 {
    472 }
    473 
     328void Visitor::visit(Subrange *subrange) {}
     329
     330void Visitor::visit(Constant *constant) {}
  • translator/SynTree/Visitor.h

    r3848e0e rd9a0e76  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Visitor.h,v 1.23 2005/08/29 20:59:27 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef VISITOR_H
    92#define VISITOR_H
     
    147
    158
    16 class Visitor
    17 {
    18 protected:
     9class Visitor {
     10  protected:
    1911    Visitor();
    2012    virtual ~Visitor();
     13  public:
     14    virtual void visit( ObjectDecl *objectDecl );
     15    virtual void visit( FunctionDecl *functionDecl );
     16    virtual void visit( StructDecl *aggregateDecl );
     17    virtual void visit( UnionDecl *aggregateDecl );
     18    virtual void visit( EnumDecl *aggregateDecl );
     19    virtual void visit( ContextDecl *aggregateDecl );
     20    virtual void visit( TypeDecl *typeDecl );
     21    virtual void visit( TypedefDecl *typeDecl );
    2122
    22 public:
    23     virtual void visit(ObjectDecl *objectDecl);
    24     virtual void visit(FunctionDecl *functionDecl);
    25     virtual void visit(StructDecl *aggregateDecl);
    26     virtual void visit(UnionDecl *aggregateDecl);
    27     virtual void visit(EnumDecl *aggregateDecl);
    28     virtual void visit(ContextDecl *aggregateDecl);
    29     virtual void visit(TypeDecl *typeDecl);
    30     virtual void visit(TypedefDecl *typeDecl);
     23    virtual void visit( CompoundStmt *compoundStmt );
     24    virtual void visit( ExprStmt *exprStmt );
     25    virtual void visit( IfStmt *ifStmt );
     26    virtual void visit( WhileStmt *whileStmt );
     27    virtual void visit( ForStmt *forStmt );
     28    virtual void visit( SwitchStmt *switchStmt );
     29    virtual void visit( ChooseStmt *switchStmt );
     30    virtual void visit( FallthruStmt *switchStmt );
     31    virtual void visit( CaseStmt *caseStmt );
     32    virtual void visit( BranchStmt *branchStmt );
     33    virtual void visit( ReturnStmt *returnStmt );
     34    virtual void visit( TryStmt *tryStmt );
     35    virtual void visit( CatchStmt *catchStmt );
     36    virtual void visit( FinallyStmt *finallyStmt );
     37    virtual void visit( NullStmt *nullStmt );
     38    virtual void visit( DeclStmt *declStmt );
    3139
    32     virtual void visit(CompoundStmt *compoundStmt);
    33     virtual void visit(ExprStmt *exprStmt);
    34     virtual void visit(IfStmt *ifStmt);
    35     virtual void visit(WhileStmt *whileStmt);
    36     virtual void visit(ForStmt *forStmt);
    37     virtual void visit(SwitchStmt *switchStmt);
    38     virtual void visit(ChooseStmt *switchStmt);
    39     virtual void visit(FallthruStmt *switchStmt);
    40     virtual void visit(CaseStmt *caseStmt);
    41     virtual void visit(BranchStmt *branchStmt);
    42     virtual void visit(ReturnStmt *returnStmt);
    43     virtual void visit(TryStmt *tryStmt);
    44     virtual void visit(CatchStmt *catchStmt);
    45     virtual void visit(FinallyStmt *finallyStmt);
    46     virtual void visit(NullStmt *nullStmt);
    47     virtual void visit(DeclStmt *declStmt);
     40    virtual void visit( ApplicationExpr *applicationExpr );
     41    virtual void visit( UntypedExpr *untypedExpr );
     42    virtual void visit( NameExpr *nameExpr );
     43    virtual void visit( CastExpr *castExpr );
     44    virtual void visit( AddressExpr *addressExpr );
     45    virtual void visit( LabelAddressExpr *labAddressExpr );
     46    virtual void visit( UntypedMemberExpr *memberExpr );
     47    virtual void visit( MemberExpr *memberExpr );
     48    virtual void visit( VariableExpr *variableExpr );
     49    virtual void visit( ConstantExpr *constantExpr );
     50    virtual void visit( SizeofExpr *sizeofExpr );
     51    virtual void visit( AttrExpr *attrExpr );
     52    virtual void visit( LogicalExpr *logicalExpr );
     53    virtual void visit( ConditionalExpr *conditionalExpr );
     54    virtual void visit( CommaExpr *commaExpr );
     55    virtual void visit( TupleExpr *tupleExpr );
     56    virtual void visit( SolvedTupleExpr *tupleExpr );
     57    virtual void visit( TypeExpr *typeExpr );
     58    virtual void visit( UntypedValofExpr *valofExpr );
    4859
    49     virtual void visit(ApplicationExpr *applicationExpr);
    50     virtual void visit(UntypedExpr *untypedExpr);
    51     virtual void visit(NameExpr *nameExpr);
    52     virtual void visit(CastExpr *castExpr);
    53     virtual void visit(AddressExpr *addressExpr);
    54     virtual void visit(LabelAddressExpr *labAddressExpr);
    55     virtual void visit(UntypedMemberExpr *memberExpr);
    56     virtual void visit(MemberExpr *memberExpr);
    57     virtual void visit(VariableExpr *variableExpr);
    58     virtual void visit(ConstantExpr *constantExpr);
    59     virtual void visit(SizeofExpr *sizeofExpr);
    60     virtual void visit(AttrExpr *attrExpr);
    61     virtual void visit(LogicalExpr *logicalExpr);
    62     virtual void visit(ConditionalExpr *conditionalExpr);
    63     virtual void visit(CommaExpr *commaExpr);
    64     virtual void visit(TupleExpr *tupleExpr);
    65     virtual void visit(SolvedTupleExpr *tupleExpr);
    66     virtual void visit(TypeExpr *typeExpr);
    67     virtual void visit(UntypedValofExpr *valofExpr);
     60    virtual void visit( VoidType *basicType );
     61    virtual void visit( BasicType *basicType );
     62    virtual void visit( PointerType *pointerType );
     63    virtual void visit( ArrayType *arrayType );
     64    virtual void visit( FunctionType *functionType );
     65    virtual void visit( StructInstType *aggregateUseType );
     66    virtual void visit( UnionInstType *aggregateUseType );
     67    virtual void visit( EnumInstType *aggregateUseType );
     68    virtual void visit( ContextInstType *aggregateUseType );
     69    virtual void visit( TypeInstType *aggregateUseType );
     70    virtual void visit( TupleType *tupleType );
     71    virtual void visit( TypeofType *typeofType );
     72    virtual void visit( AttrType *attrType );
    6873
    69     virtual void visit(VoidType *basicType);
    70     virtual void visit(BasicType *basicType);
    71     virtual void visit(PointerType *pointerType);
    72     virtual void visit(ArrayType *arrayType);
    73     virtual void visit(FunctionType *functionType);
    74     virtual void visit(StructInstType *aggregateUseType);
    75     virtual void visit(UnionInstType *aggregateUseType);
    76     virtual void visit(EnumInstType *aggregateUseType);
    77     virtual void visit(ContextInstType *aggregateUseType);
    78     virtual void visit(TypeInstType *aggregateUseType);
    79     virtual void visit(TupleType *tupleType);
    80     virtual void visit(TypeofType *typeofType);
    81     virtual void visit(AttrType *attrType);
     74    virtual void visit( MemberInit *memberInit );
     75    virtual void visit( ElementInit *elementInit );
     76    virtual void visit( SingleInit *singleInit );
     77    virtual void visit( ListInit *listInit );
    8278
    83     virtual void visit(MemberInit *memberInit);
    84     virtual void visit(ElementInit *elementInit);
    85     virtual void visit(SingleInit *singleInit);
    86     virtual void visit(ListInit *listInit);
     79    virtual void visit( Subrange *subrange );
    8780
    88     virtual void visit(Subrange *subrange);
    89 
    90     virtual void visit(Constant *constant);
    91 
    92 private:
    93     virtual void visit(AggregateDecl *aggregateDecl);
    94     virtual void visit(NamedTypeDecl *typeDecl);
    95     virtual void visit(ReferenceToType *aggregateUseType);
     81    virtual void visit( Constant *constant );
     82  private:
     83    virtual void visit( AggregateDecl *aggregateDecl );
     84    virtual void visit( NamedTypeDecl *typeDecl );
     85    virtual void visit( ReferenceToType *aggregateUseType );
    9686};
    9787
    9888template< typename TreeType, typename VisitorType >
    99 inline void
    100 maybeAccept( TreeType *tree, VisitorType &visitor )
    101 {
    102     if( tree ) {
     89inline void maybeAccept( TreeType *tree, VisitorType &visitor ) {
     90    if ( tree ) {
    10391        tree->accept( visitor );
    10492    }
     
    10694
    10795template< typename Container, typename VisitorType >
    108 inline void
    109 acceptAll( Container &container, VisitorType &visitor )
    110 {
     96inline void acceptAll( Container &container, VisitorType &visitor ) {
    11197    SemanticError errors;
    112    for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     98    for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    11399        try {
    114             if( *i ) {
     100            if ( *i ) {
    115101                (*i)->accept( visitor );
    116102            }
     
    119105        }
    120106    }
    121     if( !errors.isEmpty() ) {
     107    if ( !errors.isEmpty() ) {
    122108        throw errors;
    123109    }
     
    125111
    126112template< typename Container, typename VisitorType >
    127 void
    128 acceptAllFold( Container &container, VisitorType &visitor, VisitorType &around )
    129 {
     113void acceptAllFold( Container &container, VisitorType &visitor, VisitorType &around ) {
    130114    SemanticError errors;
    131     for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     115    for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    132116        try {
    133             if( *i ) {
    134     VisitorType *v = new VisitorType;
     117            if ( *i ) {
     118                VisitorType *v = new VisitorType;
    135119                (*i)->accept( *v );
    136120
    137     typename Container::iterator nxt = i; nxt++; // forward_iterator
    138     if( nxt == container.end() )
    139         visitor += *v;
    140     else
    141         visitor += *v + around;
     121                typename Container::iterator nxt = i; nxt++; // forward_iterator
     122                if ( nxt == container.end() )
     123                    visitor += *v;
     124                else
     125                    visitor += *v + around;
    142126
    143     delete v;
     127                delete v;
    144128            }
    145129        } catch( SemanticError &e ) {
     
    147131        }
    148132    }
    149     if( !errors.isEmpty() ) {
     133    if ( !errors.isEmpty() ) {
    150134        throw errors;
    151135    }
    152136}
    153137
    154 
    155 #endif /* #ifndef VISITOR_H */
    156 
    157 
    158 /*
    159     Local Variables:
    160     mode: c++
    161     End:
    162 */
     138#endif // VISITOR_H
Note: See TracChangeset for help on using the changeset viewer.