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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.