Changes in / [12914e9:ea156ae]


Ignore:
Location:
src
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r12914e9 rea156ae  
    540540                extension( nameExpr );
    541541                OperatorInfo opInfo;
    542                 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
    543                         assert( opInfo.type == OT_CONSTANT );
    544                         output << opInfo.symbol;
     542                if ( operatorLookup( nameExpr->name, opInfo ) ) {
     543                        if ( opInfo.type == OT_CONSTANT ) {
     544                                output << opInfo.symbol;
     545                        } else {
     546                                output << opInfo.outputName;
     547                        }
    545548                } else {
    546549                        output << nameExpr->get_name();
  • src/Common/PassVisitor.h

    r12914e9 rea156ae  
    1010#include "SymTab/Indexer.h"
    1111
     12#include "SynTree/Attribute.h"
    1213#include "SynTree/Initializer.h"
    1314#include "SynTree/Statement.h"
     
    5354        pass_type pass;
    5455
    55         virtual void visit( ObjectDecl *objectDecl ) override final;
    56         virtual void visit( FunctionDecl *functionDecl ) override final;
    57         virtual void visit( StructDecl *aggregateDecl ) override final;
    58         virtual void visit( UnionDecl *aggregateDecl ) override final;
    59         virtual void visit( EnumDecl *aggregateDecl ) override final;
    60         virtual void visit( TraitDecl *aggregateDecl ) override final;
    61         virtual void visit( TypeDecl *typeDecl ) override final;
    62         virtual void visit( TypedefDecl *typeDecl ) override final;
    63         virtual void visit( AsmDecl *asmDecl ) override final;
    64 
    65         virtual void visit( CompoundStmt *compoundStmt ) override final;
    66         virtual void visit( ExprStmt *exprStmt ) override final;
    67         virtual void visit( AsmStmt *asmStmt ) override final;
    68         virtual void visit( IfStmt *ifStmt ) override final;
    69         virtual void visit( WhileStmt *whileStmt ) override final;
    70         virtual void visit( ForStmt *forStmt ) override final;
    71         virtual void visit( SwitchStmt *switchStmt ) override final;
    72         virtual void visit( CaseStmt *caseStmt ) override final;
    73         virtual void visit( BranchStmt *branchStmt ) override final;
    74         virtual void visit( ReturnStmt *returnStmt ) override final;
    75         virtual void visit( ThrowStmt *throwStmt ) override final;
    76         virtual void visit( TryStmt *tryStmt ) override final;
    77         virtual void visit( CatchStmt *catchStmt ) override final;
    78         virtual void visit( FinallyStmt *finallyStmt ) override final;
    79         virtual void visit( WaitForStmt *waitforStmt ) override final;
    80         virtual void visit( NullStmt *nullStmt ) override final;
    81         virtual void visit( DeclStmt *declStmt ) override final;
    82         virtual void visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) override final;
    83 
    84         virtual void visit( ApplicationExpr *applicationExpr ) override final;
    85         virtual void visit( UntypedExpr *untypedExpr ) override final;
    86         virtual void visit( NameExpr *nameExpr ) override final;
    87         virtual void visit( CastExpr *castExpr ) override final;
    88         virtual void visit( VirtualCastExpr *castExpr ) override final;
    89         virtual void visit( AddressExpr *addressExpr ) override final;
    90         virtual void visit( LabelAddressExpr *labAddressExpr ) override final;
    91         virtual void visit( UntypedMemberExpr *memberExpr ) override final;
    92         virtual void visit( MemberExpr *memberExpr ) override final;
    93         virtual void visit( VariableExpr *variableExpr ) override final;
    94         virtual void visit( ConstantExpr *constantExpr ) override final;
    95         virtual void visit( SizeofExpr *sizeofExpr ) override final;
    96         virtual void visit( AlignofExpr *alignofExpr ) override final;
    97         virtual void visit( UntypedOffsetofExpr *offsetofExpr ) override final;
    98         virtual void visit( OffsetofExpr *offsetofExpr ) override final;
    99         virtual void visit( OffsetPackExpr *offsetPackExpr ) override final;
    100         virtual void visit( AttrExpr *attrExpr ) override final;
    101         virtual void visit( LogicalExpr *logicalExpr ) override final;
    102         virtual void visit( ConditionalExpr *conditionalExpr ) override final;
    103         virtual void visit( CommaExpr *commaExpr ) override final;
    104         virtual void visit( TypeExpr *typeExpr ) override final;
    105         virtual void visit( AsmExpr *asmExpr ) override final;
    106         virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr ) override final;
    107         virtual void visit( ConstructorExpr * ctorExpr ) override final;
    108         virtual void visit( CompoundLiteralExpr *compLitExpr ) override final;
    109         virtual void visit( RangeExpr *rangeExpr ) override final;
    110         virtual void visit( UntypedTupleExpr *tupleExpr ) override final;
    111         virtual void visit( TupleExpr *tupleExpr ) override final;
    112         virtual void visit( TupleIndexExpr *tupleExpr ) override final;
    113         virtual void visit( TupleAssignExpr *assignExpr ) override final;
    114         virtual void visit( StmtExpr * stmtExpr ) override final;
    115         virtual void visit( UniqueExpr * uniqueExpr ) override final;
    116 
    117         virtual void visit( VoidType *basicType ) override final;
    118         virtual void visit( BasicType *basicType ) override final;
    119         virtual void visit( PointerType *pointerType ) override final;
    120         virtual void visit( ArrayType *arrayType ) override final;
    121         virtual void visit( ReferenceType *referenceType ) override final;
    122         virtual void visit( FunctionType *functionType ) override final;
    123         virtual void visit( StructInstType *aggregateUseType ) override final;
    124         virtual void visit( UnionInstType *aggregateUseType ) override final;
    125         virtual void visit( EnumInstType *aggregateUseType ) override final;
    126         virtual void visit( TraitInstType *aggregateUseType ) override final;
    127         virtual void visit( TypeInstType *aggregateUseType ) override final;
    128         virtual void visit( TupleType *tupleType ) override final;
    129         virtual void visit( TypeofType *typeofType ) override final;
    130         virtual void visit( AttrType *attrType ) override final;
    131         virtual void visit( VarArgsType *varArgsType ) override final;
    132         virtual void visit( ZeroType *zeroType ) override final;
    133         virtual void visit( OneType *oneType ) override final;
    134 
    135         virtual void visit( Designation *designation ) override final;
    136         virtual void visit( SingleInit *singleInit ) override final;
    137         virtual void visit( ListInit *listInit ) override final;
    138         virtual void visit( ConstructorInit *ctorInit ) override final;
    139 
    140         virtual void visit( Subrange *subrange ) override final;
    141 
    142         virtual void visit( Constant *constant ) override final;
    143 
    144         virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ) override final;
    145         virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ) override final;
    146         virtual Declaration* mutate( StructDecl *aggregateDecl ) override final;
    147         virtual Declaration* mutate( UnionDecl *aggregateDecl ) override final;
    148         virtual Declaration* mutate( EnumDecl *aggregateDecl ) override final;
    149         virtual Declaration* mutate( TraitDecl *aggregateDecl ) override final;
    150         virtual Declaration* mutate( TypeDecl *typeDecl ) override final;
    151         virtual Declaration* mutate( TypedefDecl *typeDecl ) override final;
    152         virtual AsmDecl* mutate( AsmDecl *asmDecl ) override final;
    153 
    154         virtual CompoundStmt* mutate( CompoundStmt *compoundStmt ) override final;
    155         virtual Statement* mutate( ExprStmt *exprStmt ) override final;
    156         virtual Statement* mutate( AsmStmt *asmStmt ) override final;
    157         virtual Statement* mutate( IfStmt *ifStmt ) override final;
    158         virtual Statement* mutate( WhileStmt *whileStmt ) override final;
    159         virtual Statement* mutate( ForStmt *forStmt ) override final;
    160         virtual Statement* mutate( SwitchStmt *switchStmt ) override final;
    161         virtual Statement* mutate( CaseStmt *caseStmt ) override final;
    162         virtual Statement* mutate( BranchStmt *branchStmt ) override final;
    163         virtual Statement* mutate( ReturnStmt *returnStmt ) override final;
    164         virtual Statement* mutate( ThrowStmt *throwStmt ) override final;
    165         virtual Statement* mutate( TryStmt *tryStmt ) override final;
    166         virtual Statement* mutate( CatchStmt *catchStmt ) override final;
    167         virtual Statement* mutate( FinallyStmt *finallyStmt ) override final;
    168         virtual Statement* mutate( WaitForStmt *waitforStmt ) override final;
    169         virtual NullStmt* mutate( NullStmt *nullStmt ) override final;
    170         virtual Statement* mutate( DeclStmt *declStmt ) override final;
    171         virtual Statement* mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) override final;
    172 
    173         virtual Expression* mutate( ApplicationExpr *applicationExpr ) override final;
    174         virtual Expression* mutate( UntypedExpr *untypedExpr ) override final;
    175         virtual Expression* mutate( NameExpr *nameExpr ) override final;
    176         virtual Expression* mutate( AddressExpr *castExpr ) override final;
    177         virtual Expression* mutate( LabelAddressExpr *labAddressExpr ) override final;
    178         virtual Expression* mutate( CastExpr *castExpr ) override final;
    179         virtual Expression* mutate( VirtualCastExpr *castExpr ) override final;
    180         virtual Expression* mutate( UntypedMemberExpr *memberExpr ) override final;
    181         virtual Expression* mutate( MemberExpr *memberExpr ) override final;
    182         virtual Expression* mutate( VariableExpr *variableExpr ) override final;
    183         virtual Expression* mutate( ConstantExpr *constantExpr ) override final;
    184         virtual Expression* mutate( SizeofExpr *sizeofExpr ) override final;
    185         virtual Expression* mutate( AlignofExpr *alignofExpr ) override final;
    186         virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr ) override final;
    187         virtual Expression* mutate( OffsetofExpr *offsetofExpr ) override final;
    188         virtual Expression* mutate( OffsetPackExpr *offsetPackExpr ) override final;
    189         virtual Expression* mutate( AttrExpr *attrExpr ) override final;
    190         virtual Expression* mutate( LogicalExpr *logicalExpr ) override final;
    191         virtual Expression* mutate( ConditionalExpr *conditionalExpr ) override final;
    192         virtual Expression* mutate( CommaExpr *commaExpr ) override final;
    193         virtual Expression* mutate( TypeExpr *typeExpr ) override final;
    194         virtual Expression* mutate( AsmExpr *asmExpr ) override final;
    195         virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) override final;
    196         virtual Expression* mutate( ConstructorExpr *ctorExpr ) override final;
    197         virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ) override final;
    198         virtual Expression* mutate( RangeExpr *rangeExpr ) override final;
    199         virtual Expression* mutate( UntypedTupleExpr *tupleExpr ) override final;
    200         virtual Expression* mutate( TupleExpr *tupleExpr ) override final;
    201         virtual Expression* mutate( TupleIndexExpr *tupleExpr ) override final;
    202         virtual Expression* mutate( TupleAssignExpr *assignExpr ) override final;
    203         virtual Expression* mutate( StmtExpr * stmtExpr ) override final;
    204         virtual Expression* mutate( UniqueExpr * uniqueExpr ) override final;
    205 
    206         virtual Type* mutate( VoidType *basicType ) override final;
    207         virtual Type* mutate( BasicType *basicType ) override final;
    208         virtual Type* mutate( PointerType *pointerType ) override final;
    209         virtual Type* mutate( ArrayType *arrayType ) override final;
    210         virtual Type* mutate( ReferenceType *referenceType ) override final;
    211         virtual Type* mutate( FunctionType *functionType ) override final;
    212         virtual Type* mutate( StructInstType *aggregateUseType ) override final;
    213         virtual Type* mutate( UnionInstType *aggregateUseType ) override final;
    214         virtual Type* mutate( EnumInstType *aggregateUseType ) override final;
    215         virtual Type* mutate( TraitInstType *aggregateUseType ) override final;
    216         virtual Type* mutate( TypeInstType *aggregateUseType ) override final;
    217         virtual Type* mutate( TupleType *tupleType ) override final;
    218         virtual Type* mutate( TypeofType *typeofType ) override final;
    219         virtual Type* mutate( AttrType *attrType ) override final;
    220         virtual Type* mutate( VarArgsType *varArgsType ) override final;
    221         virtual Type* mutate( ZeroType *zeroType ) override final;
    222         virtual Type* mutate( OneType *oneType ) override final;
    223 
    224         virtual Designation* mutate( Designation *designation ) override final;
    225         virtual Initializer* mutate( SingleInit *singleInit ) override final;
    226         virtual Initializer* mutate( ListInit *listInit ) override final;
    227         virtual Initializer* mutate( ConstructorInit *ctorInit ) override final;
    228 
    229         virtual Subrange *mutate( Subrange *subrange ) override final;
    230 
    231         virtual Constant *mutate( Constant *constant ) override final;
     56        virtual void visit( ObjectDecl * objectDecl ) override final;
     57        virtual void visit( FunctionDecl * functionDecl ) override final;
     58        virtual void visit( StructDecl * aggregateDecl ) override final;
     59        virtual void visit( UnionDecl * aggregateDecl ) override final;
     60        virtual void visit( EnumDecl * aggregateDecl ) override final;
     61        virtual void visit( TraitDecl * aggregateDecl ) override final;
     62        virtual void visit( TypeDecl * typeDecl ) override final;
     63        virtual void visit( TypedefDecl * typeDecl ) override final;
     64        virtual void visit( AsmDecl * asmDecl ) override final;
     65
     66        virtual void visit( CompoundStmt * compoundStmt ) override final;
     67        virtual void visit( ExprStmt * exprStmt ) override final;
     68        virtual void visit( AsmStmt * asmStmt ) override final;
     69        virtual void visit( IfStmt * ifStmt ) override final;
     70        virtual void visit( WhileStmt * whileStmt ) override final;
     71        virtual void visit( ForStmt * forStmt ) override final;
     72        virtual void visit( SwitchStmt * switchStmt ) override final;
     73        virtual void visit( CaseStmt * caseStmt ) override final;
     74        virtual void visit( BranchStmt * branchStmt ) override final;
     75        virtual void visit( ReturnStmt * returnStmt ) override final;
     76        virtual void visit( ThrowStmt * throwStmt ) override final;
     77        virtual void visit( TryStmt * tryStmt ) override final;
     78        virtual void visit( CatchStmt * catchStmt ) override final;
     79        virtual void visit( FinallyStmt * finallyStmt ) override final;
     80        virtual void visit( WaitForStmt * waitforStmt ) override final;
     81        virtual void visit( NullStmt * nullStmt ) override final;
     82        virtual void visit( DeclStmt * declStmt ) override final;
     83        virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) override final;
     84
     85        virtual void visit( ApplicationExpr * applicationExpr ) override final;
     86        virtual void visit( UntypedExpr * untypedExpr ) override final;
     87        virtual void visit( NameExpr * nameExpr ) override final;
     88        virtual void visit( CastExpr * castExpr ) override final;
     89        virtual void visit( VirtualCastExpr * castExpr ) override final;
     90        virtual void visit( AddressExpr * addressExpr ) override final;
     91        virtual void visit( LabelAddressExpr * labAddressExpr ) override final;
     92        virtual void visit( UntypedMemberExpr * memberExpr ) override final;
     93        virtual void visit( MemberExpr * memberExpr ) override final;
     94        virtual void visit( VariableExpr * variableExpr ) override final;
     95        virtual void visit( ConstantExpr * constantExpr ) override final;
     96        virtual void visit( SizeofExpr * sizeofExpr ) override final;
     97        virtual void visit( AlignofExpr * alignofExpr ) override final;
     98        virtual void visit( UntypedOffsetofExpr * offsetofExpr ) override final;
     99        virtual void visit( OffsetofExpr * offsetofExpr ) override final;
     100        virtual void visit( OffsetPackExpr * offsetPackExpr ) override final;
     101        virtual void visit( AttrExpr * attrExpr ) override final;
     102        virtual void visit( LogicalExpr * logicalExpr ) override final;
     103        virtual void visit( ConditionalExpr * conditionalExpr ) override final;
     104        virtual void visit( CommaExpr * commaExpr ) override final;
     105        virtual void visit( TypeExpr * typeExpr ) override final;
     106        virtual void visit( AsmExpr * asmExpr ) override final;
     107        virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override final;
     108        virtual void visit( ConstructorExpr *  ctorExpr ) override final;
     109        virtual void visit( CompoundLiteralExpr * compLitExpr ) override final;
     110        virtual void visit( RangeExpr * rangeExpr ) override final;
     111        virtual void visit( UntypedTupleExpr * tupleExpr ) override final;
     112        virtual void visit( TupleExpr * tupleExpr ) override final;
     113        virtual void visit( TupleIndexExpr * tupleExpr ) override final;
     114        virtual void visit( TupleAssignExpr * assignExpr ) override final;
     115        virtual void visit( StmtExpr *  stmtExpr ) override final;
     116        virtual void visit( UniqueExpr *  uniqueExpr ) override final;
     117
     118        virtual void visit( VoidType * basicType ) override final;
     119        virtual void visit( BasicType * basicType ) override final;
     120        virtual void visit( PointerType * pointerType ) override final;
     121        virtual void visit( ArrayType * arrayType ) override final;
     122        virtual void visit( ReferenceType * referenceType ) override final;
     123        virtual void visit( FunctionType * functionType ) override final;
     124        virtual void visit( StructInstType * aggregateUseType ) override final;
     125        virtual void visit( UnionInstType * aggregateUseType ) override final;
     126        virtual void visit( EnumInstType * aggregateUseType ) override final;
     127        virtual void visit( TraitInstType * aggregateUseType ) override final;
     128        virtual void visit( TypeInstType * aggregateUseType ) override final;
     129        virtual void visit( TupleType * tupleType ) override final;
     130        virtual void visit( TypeofType * typeofType ) override final;
     131        virtual void visit( AttrType * attrType ) override final;
     132        virtual void visit( VarArgsType * varArgsType ) override final;
     133        virtual void visit( ZeroType * zeroType ) override final;
     134        virtual void visit( OneType * oneType ) override final;
     135
     136        virtual void visit( Designation * designation ) override final;
     137        virtual void visit( SingleInit * singleInit ) override final;
     138        virtual void visit( ListInit * listInit ) override final;
     139        virtual void visit( ConstructorInit * ctorInit ) override final;
     140
     141        virtual void visit( Subrange * subrange ) override final;
     142
     143        virtual void visit( Constant * constant ) override final;
     144
     145        virtual void visit( Attribute * attribute ) override final;
     146
     147        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override final;
     148        virtual DeclarationWithType * mutate( FunctionDecl * functionDecl ) override final;
     149        virtual Declaration * mutate( StructDecl * aggregateDecl ) override final;
     150        virtual Declaration * mutate( UnionDecl * aggregateDecl ) override final;
     151        virtual Declaration * mutate( EnumDecl * aggregateDecl ) override final;
     152        virtual Declaration * mutate( TraitDecl * aggregateDecl ) override final;
     153        virtual Declaration * mutate( TypeDecl * typeDecl ) override final;
     154        virtual Declaration * mutate( TypedefDecl * typeDecl ) override final;
     155        virtual AsmDecl * mutate( AsmDecl * asmDecl ) override final;
     156
     157        virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override final;
     158        virtual Statement * mutate( ExprStmt * exprStmt ) override final;
     159        virtual Statement * mutate( AsmStmt * asmStmt ) override final;
     160        virtual Statement * mutate( IfStmt * ifStmt ) override final;
     161        virtual Statement * mutate( WhileStmt * whileStmt ) override final;
     162        virtual Statement * mutate( ForStmt * forStmt ) override final;
     163        virtual Statement * mutate( SwitchStmt * switchStmt ) override final;
     164        virtual Statement * mutate( CaseStmt * caseStmt ) override final;
     165        virtual Statement * mutate( BranchStmt * branchStmt ) override final;
     166        virtual Statement * mutate( ReturnStmt * returnStmt ) override final;
     167        virtual Statement * mutate( ThrowStmt * throwStmt ) override final;
     168        virtual Statement * mutate( TryStmt * tryStmt ) override final;
     169        virtual Statement * mutate( CatchStmt * catchStmt ) override final;
     170        virtual Statement * mutate( FinallyStmt * finallyStmt ) override final;
     171        virtual Statement * mutate( WaitForStmt * waitforStmt ) override final;
     172        virtual NullStmt * mutate( NullStmt * nullStmt ) override final;
     173        virtual Statement * mutate( DeclStmt * declStmt ) override final;
     174        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt ) override final;
     175
     176        virtual Expression * mutate( ApplicationExpr * applicationExpr ) override final;
     177        virtual Expression * mutate( UntypedExpr * untypedExpr ) override final;
     178        virtual Expression * mutate( NameExpr * nameExpr ) override final;
     179        virtual Expression * mutate( AddressExpr * castExpr ) override final;
     180        virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) override final;
     181        virtual Expression * mutate( CastExpr * castExpr ) override final;
     182        virtual Expression * mutate( VirtualCastExpr * castExpr ) override final;
     183        virtual Expression * mutate( UntypedMemberExpr * memberExpr ) override final;
     184        virtual Expression * mutate( MemberExpr * memberExpr ) override final;
     185        virtual Expression * mutate( VariableExpr * variableExpr ) override final;
     186        virtual Expression * mutate( ConstantExpr * constantExpr ) override final;
     187        virtual Expression * mutate( SizeofExpr * sizeofExpr ) override final;
     188        virtual Expression * mutate( AlignofExpr * alignofExpr ) override final;
     189        virtual Expression * mutate( UntypedOffsetofExpr * offsetofExpr ) override final;
     190        virtual Expression * mutate( OffsetofExpr * offsetofExpr ) override final;
     191        virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) override final;
     192        virtual Expression * mutate( AttrExpr * attrExpr ) override final;
     193        virtual Expression * mutate( LogicalExpr * logicalExpr ) override final;
     194        virtual Expression * mutate( ConditionalExpr * conditionalExpr ) override final;
     195        virtual Expression * mutate( CommaExpr * commaExpr ) override final;
     196        virtual Expression * mutate( TypeExpr * typeExpr ) override final;
     197        virtual Expression * mutate( AsmExpr * asmExpr ) override final;
     198        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override final;
     199        virtual Expression * mutate( ConstructorExpr * ctorExpr ) override final;
     200        virtual Expression * mutate( CompoundLiteralExpr * compLitExpr ) override final;
     201        virtual Expression * mutate( RangeExpr * rangeExpr ) override final;
     202        virtual Expression * mutate( UntypedTupleExpr * tupleExpr ) override final;
     203        virtual Expression * mutate( TupleExpr * tupleExpr ) override final;
     204        virtual Expression * mutate( TupleIndexExpr * tupleExpr ) override final;
     205        virtual Expression * mutate( TupleAssignExpr * assignExpr ) override final;
     206        virtual Expression * mutate( StmtExpr *  stmtExpr ) override final;
     207        virtual Expression * mutate( UniqueExpr *  uniqueExpr ) override final;
     208
     209        virtual Type * mutate( VoidType * basicType ) override final;
     210        virtual Type * mutate( BasicType * basicType ) override final;
     211        virtual Type * mutate( PointerType * pointerType ) override final;
     212        virtual Type * mutate( ArrayType * arrayType ) override final;
     213        virtual Type * mutate( ReferenceType * referenceType ) override final;
     214        virtual Type * mutate( FunctionType * functionType ) override final;
     215        virtual Type * mutate( StructInstType * aggregateUseType ) override final;
     216        virtual Type * mutate( UnionInstType * aggregateUseType ) override final;
     217        virtual Type * mutate( EnumInstType * aggregateUseType ) override final;
     218        virtual Type * mutate( TraitInstType * aggregateUseType ) override final;
     219        virtual Type * mutate( TypeInstType * aggregateUseType ) override final;
     220        virtual Type * mutate( TupleType * tupleType ) override final;
     221        virtual Type * mutate( TypeofType * typeofType ) override final;
     222        virtual Type * mutate( AttrType * attrType ) override final;
     223        virtual Type * mutate( VarArgsType * varArgsType ) override final;
     224        virtual Type * mutate( ZeroType * zeroType ) override final;
     225        virtual Type * mutate( OneType * oneType ) override final;
     226
     227        virtual Designation * mutate( Designation * designation ) override final;
     228        virtual Initializer * mutate( SingleInit * singleInit ) override final;
     229        virtual Initializer * mutate( ListInit * listInit ) override final;
     230        virtual Initializer * mutate( ConstructorInit * ctorInit ) override final;
     231
     232        virtual Subrange * mutate( Subrange * subrange ) override final;
     233
     234        virtual Constant * mutate( Constant * constant ) override final;
     235
     236        virtual Attribute * mutate( Attribute * attribute ) override final;
    232237
    233238private:
  • src/Common/PassVisitor.impl.h

    r12914e9 rea156ae  
    321321        maybeAccept        ( node->init         , *this );
    322322        maybeAccept        ( node->bitfieldWidth, *this );
     323        maybeAccept        ( node->attributes   , *this );
    323324
    324325        if ( node->name != "" ) {
     
    336337        maybeMutateRef     ( node->init         , *this );
    337338        maybeMutateRef     ( node->bitfieldWidth, *this );
     339        maybeMutateRef     ( node->attributes   , *this );
    338340
    339341        if ( node->name != "" ) {
     
    358360                maybeAccept( node->type, *this );
    359361                maybeAccept( node->statements, *this );
     362                maybeAccept( node->attributes, *this );
    360363        }
    361364
     
    375378                maybeMutateRef( node->type, *this );
    376379                maybeMutateRef( node->statements, *this );
     380                maybeMutateRef( node->attributes, *this );
    377381        }
    378382
     
    19841988}
    19851989
     1990template< typename pass_type >
     1991void PassVisitor< pass_type >::visit( Attribute * node ) {
     1992        VISIT_BODY( node );
     1993}
     1994
    19861995//---------------------------------------------------------------------------------------------------------------
    19871996template< typename pass_type >
     
    20692078        MUTATE_BODY( Constant, node );
    20702079}
     2080
     2081template< typename pass_type >
     2082Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
     2083        MUTATE_BODY( Attribute, node );
     2084}
  • src/InitTweak/FixInit.cc

    r12914e9 rea156ae  
    214214                        void emit( CodeLocation, const Params &... params );
    215215
    216                         FunctionDecl * function = 0;
     216                        FunctionDecl * function = nullptr;
    217217                        std::set< DeclarationWithType * > unhandled;
    218218                        std::map< DeclarationWithType *, CodeLocation > usedUninit;
    219                         ObjectDecl * thisParam = 0;
     219                        ObjectDecl * thisParam = nullptr;
    220220                        bool isCtor = false; // true if current function is a constructor
    221                         StructDecl * structDecl = 0;
     221                        StructDecl * structDecl = nullptr;
    222222                };
    223223
     
    624624                }
    625625
    626                 DeclarationWithType *FixInit::postmutate( ObjectDecl *objDecl ) {
     626                DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) {
    627627                        // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
    628628                        if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
     
    722722                                        } else {
    723723                                                ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * > ( ctor );
    724                                                 ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->get_callStmt() );
     724                                                ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->callStmt );
    725725                                                ApplicationExpr * ctorCall = nullptr;
    726                                                 if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->get_expr() )) && ctorCall->get_args().size() == 2 ) {
     726                                                if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->expr )) && ctorCall->get_args().size() == 2 ) {
    727727                                                        // clean up intrinsic copy constructor calls by making them into SingleInits
    728                                                         objDecl->set_init( new SingleInit( ctorCall->get_args().back() ) );
    729                                                         ctorCall->get_args().pop_back();
     728                                                        objDecl->init = new SingleInit( ctorCall->args.back() );
     729                                                        ctorCall->args.pop_back();
    730730                                                } else {
    731731                                                        stmtsToAddAfter.push_back( ctor );
    732                                                         objDecl->set_init( nullptr );
    733                                                         ctorInit->set_ctor( nullptr );
     732                                                        objDecl->init = nullptr;
     733                                                        ctorInit->ctor = nullptr;
    734734                                                }
    735735                                        } // if
    736                                 } else if ( Initializer * init = ctorInit->get_init() ) {
    737                                         objDecl->set_init( init );
    738                                         ctorInit->set_init( nullptr );
     736                                } else if ( Initializer * init = ctorInit->init ) {
     737                                        objDecl->init = init;
     738                                        ctorInit->init = nullptr;
    739739                                } else {
    740740                                        // no constructor and no initializer, which is okay
    741                                         objDecl->set_init( nullptr );
     741                                        objDecl->init = nullptr;
    742742                                } // if
    743743                                delete ctorInit;
     
    912912                }
    913913
     914                void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) {
     915                        for ( auto d : decls ) {
     916                                indexer.addId( d );
     917                        }
     918                }
     919
     920                void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) {
     921                        for ( auto td : tds ) {
     922                                indexer.addType( td );
     923                                addIds( indexer, td->assertions );
     924                        }
     925                }
     926
    914927                void GenStructMemberCalls::previsit( FunctionDecl * funcDecl ) {
    915                         GuardValue( funcDecl );
     928                        GuardValue( function );
    916929                        GuardValue( unhandled );
    917930                        GuardValue( usedUninit );
     
    946959                }
    947960
    948                 void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) {
    949                         for ( auto d : decls ) {
    950                                 indexer.addId( d );
    951                         }
    952                 }
    953 
    954                 void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) {
    955                         for ( auto td : tds ) {
    956                                 indexer.addType( td );
    957                                 addIds( indexer, td->assertions );
    958                         }
    959                 }
    960 
    961961                void GenStructMemberCalls::postvisit( FunctionDecl * funcDecl ) {
    962962                        // remove the unhandled objects from usedUninit, because a call is inserted
  • src/InitTweak/InitTweak.cc

    r12914e9 rea156ae  
    270270        }
    271271
     272        Type * getThisType( FunctionType * ftype ) {
     273                assertf( ftype, "getThisType: nullptr ftype" );
     274                ObjectDecl * thisParam = getThisParam( ftype );
     275                ReferenceType * refType = strict_dynamic_cast< ReferenceType * >( thisParam->type );
     276                return refType->base;
     277        }
     278
     279        ObjectDecl * getThisParam( FunctionType * ftype ) {
     280                assertf( ftype, "getThisParam: nullptr ftype" );
     281                auto & params = ftype->parameters;
     282                assertf( ! params.empty(), "getThisParam: ftype with 0 parameters: %s", toString( ftype ).c_str() );
     283                return strict_dynamic_cast< ObjectDecl * >( params.front() );
     284        }
     285
    272286        bool tryConstruct( DeclarationWithType * dwt ) {
    273287                ObjectDecl * objDecl = dynamic_cast< ObjectDecl * >( dwt );
  • src/InitTweak/InitTweak.h

    r12914e9 rea156ae  
    2929        FunctionDecl * isCopyConstructor( Declaration * decl );
    3030        FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname );
     31
     32        /// returns the base type of the first parameter to a constructor/destructor/assignment function
     33        Type * getThisType( FunctionType * ftype );
     34
     35        /// returns the first parameter of a constructor/destructor/assignment function
     36        ObjectDecl * getThisParam( FunctionType * ftype );
    3137
    3238        /// transform Initializer into an argument list that can be passed to a call expression
  • src/ResolvExpr/AlternativeFinder.cc

    r12914e9 rea156ae  
    174174        }
    175175
    176         void AlternativeFinder::find( Expression *expr, bool adjust, bool prune ) {
     176        void AlternativeFinder::find( Expression *expr, bool adjust, bool prune, bool failFast ) {
    177177                expr->accept( *this );
    178                 if ( alternatives.empty() ) {
     178                if ( failFast && alternatives.empty() ) {
    179179                        throw SemanticError( "No reasonable alternatives for expression ", expr );
    180180                }
     
    191191                        AltList::iterator oldBegin = alternatives.begin();
    192192                        pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) );
    193                         if ( alternatives.begin() == oldBegin ) {
     193                        if ( failFast && alternatives.begin() == oldBegin ) {
    194194                                std::ostringstream stream;
    195195                                AltList winners;
     
    214214        }
    215215
    216         void AlternativeFinder::findWithAdjustment( Expression *expr, bool prune ) {
    217                 find( expr, true, prune );
     216        void AlternativeFinder::findWithAdjustment( Expression *expr ) {
     217                find( expr, true );
     218        }
     219
     220        void AlternativeFinder::findWithoutPrune( Expression * expr ) {
     221                find( expr, true, false );
     222        }
     223
     224        void AlternativeFinder::maybeFind( Expression * expr ) {
     225                find( expr, true, true, false );
    218226        }
    219227
     
    714722
    715723                // find function operators
     724                static NameExpr *opExpr = new NameExpr( "?()" );
    716725                AlternativeFinder funcOpFinder( indexer, env );
    717                 NameExpr *opExpr = new NameExpr( "?()" );
    718                 try {
    719                         funcOpFinder.findWithAdjustment( opExpr );
    720                 } catch( SemanticError &e ) {
    721                         // it's ok if there aren't any defined function ops
    722                 }
     726                // it's ok if there aren't any defined function ops
     727                funcOpFinder.maybeFind( opExpr);
    723728                PRINT(
    724729                        std::cerr << "known function ops:" << std::endl;
     
    928933                AlternativeFinder finder( indexer, env );
    929934                // don't prune here, since it's guaranteed all alternatives will have the same type
    930                 // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
    931                 finder.findWithAdjustment( castExpr->get_arg(), false );
     935                finder.findWithoutPrune( castExpr->get_arg() );
    932936                for ( Alternative & alt : finder.alternatives ) {
    933937                        alternatives.push_back( Alternative(
     
    12261230                // don't prune here, since it's guaranteed all alternatives will have the same type
    12271231                // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
    1228                 finder.findWithAdjustment( ctorExpr->get_callExpr(), false );
     1232                finder.findWithoutPrune( ctorExpr->get_callExpr() );
    12291233                for ( Alternative & alt : finder.alternatives ) {
    12301234                        alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) );
  • src/ResolvExpr/AlternativeFinder.h

    r12914e9 rea156ae  
    3434          public:
    3535                AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env );
    36                 void find( Expression *expr, bool adjust = false, bool prune = true );
     36                void find( Expression *expr, bool adjust = false, bool prune = true, bool failFast = true );
    3737                /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types
    38                 void findWithAdjustment( Expression *expr, bool prune = true );
     38                void findWithAdjustment( Expression *expr );
     39                /// Calls find with the adjust flag set and prune flag unset; pruning ensures there is at most one alternative per result type
     40                void findWithoutPrune( Expression *expr );
     41                /// Calls find with the adjust and prune flags set, failFast flags unset; fail fast ensures that there is at least one resulting alternative
     42                void maybeFind( Expression *expr );
    3943                AltList &get_alternatives() { return alternatives; }
    4044
  • src/SymTab/Autogen.cc

    r12914e9 rea156ae  
    119119                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    120120                ftype->get_parameters().push_back( dstParam );
    121 
    122121                return ftype;
    123122        }
  • src/SymTab/Autogen.h

    r12914e9 rea156ae  
    4444        extern FunctionDecl * dereferenceOperator;
    4545
    46         // temporary
     46        // generate the type of an assignment function for paramType
    4747        FunctionType * genAssignType( Type * paramType );
     48
     49        // generate the type of a default constructor or destructor for paramType
     50        FunctionType * genDefaultType( Type * paramType );
     51
     52        // generate the type of a copy constructor for paramType
     53        FunctionType * genCopyType( Type * paramType );
    4854
    4955        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
  • src/SynTree/Attribute.h

    r12914e9 rea156ae  
    2020#include <string>  // for string, operator==
    2121
     22#include "BaseSyntaxNode.h"
     23#include "Mutator.h"
     24#include "Visitor.h"
     25
    2226class Expression;
    2327
    2428// GCC attribute
    2529// https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Attribute-Syntax.html#Attribute-Syntax
    26 class Attribute {
     30class Attribute : public BaseSyntaxNode {
    2731  public:
     32        std::string name;
     33        // to keep things nice and tight, use NameExpr for special identifier parameters
     34        std::list< Expression * > parameters;
     35
    2836        Attribute( std::string name = "", const std::list< Expression * > & parameters = std::list< Expression * >() ) : name( name ), parameters( parameters ) {}
    2937        Attribute( const Attribute &other );
     
    3543        bool empty() const { return name == ""; }
    3644
    37         Attribute * clone() const { return new Attribute( *this ); }
    38         void print( std:: ostream &os, int indent = 0 ) const;
    39   private:
    40         std::string name;
    41         // to keep things nice and tight, use NameExpr for special identifier parameters
    42         std::list< Expression * > parameters;
     45        Attribute * clone() const override { return new Attribute( *this ); }
     46        virtual void accept( Visitor & v ) override { v.visit( this ); }
     47        virtual Attribute * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     48        virtual void print( std::ostream & os, int indent = 0 ) const override;
    4349};
    4450
  • src/SynTree/BaseSyntaxNode.h

    r12914e9 rea156ae  
    1818#include "Common/CodeLocation.h"
    1919class Visitor;
     20class Mutator;
    2021
    2122class BaseSyntaxNode {
     
    2526        virtual ~BaseSyntaxNode() {}
    2627
     28        virtual BaseSyntaxNode * clone() const = 0;
    2729        virtual void accept( Visitor & v ) = 0;
    28         virtual void print( std::ostream & os, int indent = 0 ) const = 0;
     30        virtual BaseSyntaxNode * acceptMutator( Mutator & m ) = 0;
     31        virtual void print( std::ostream & os, int indent = 0 ) const = 0;
    2932};
    3033
  • src/SynTree/Declaration.h

    r12914e9 rea156ae  
    6161
    6262        void fixUniqueId( void );
    63         virtual Declaration *clone() const = 0;
     63        virtual Declaration *clone() const override = 0;
    6464        virtual void accept( Visitor &v ) override = 0;
    65         virtual Declaration *acceptMutator( Mutator &m ) = 0;
     65        virtual Declaration *acceptMutator( Mutator &m ) override = 0;
    6666        virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
    6767        virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
     
    164164        CompoundStmt *get_statements() const { return statements; }
    165165        void set_statements( CompoundStmt *newValue ) { statements = newValue; }
     166
     167        static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements );
    166168
    167169        virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
  • src/SynTree/Expression.h

    r12914e9 rea156ae  
    5555        Expression * set_extension( bool exten ) { extension = exten; return this; }
    5656
    57         virtual Expression * clone() const = 0;
    58         virtual void accept( Visitor & v ) = 0;
    59         virtual Expression * acceptMutator( Mutator & m ) = 0;
    60         virtual void print( std::ostream & os, int indent = 0 ) const;
     57        virtual Expression * clone() const override = 0;
     58        virtual void accept( Visitor & v ) override = 0;
     59        virtual Expression * acceptMutator( Mutator & m ) override = 0;
     60        virtual void print( std::ostream & os, int indent = 0 ) const override;
    6161};
    6262
  • src/SynTree/FunctionDecl.cc

    r12914e9 rea156ae  
    2626#include "Statement.h"           // for CompoundStmt
    2727#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
     28#include "VarExprReplacer.h"
    2829
    2930extern bool translation_unit_nomain;
     
    3940FunctionDecl::FunctionDecl( const FunctionDecl &other )
    4041                : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     42
     43        VarExprReplacer::DeclMap declMap;
     44        for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
     45                declMap[ std::get<0>(p) ] = std::get<1>(p);
     46        }
     47        for ( auto p : group_iterate( other.type->returnVals, type->returnVals ) ) {
     48                declMap[ std::get<0>(p) ] = std::get<1>(p);
     49        }
     50        if ( ! declMap.empty() ) {
     51                VarExprReplacer replacer( declMap );
     52                accept( replacer );
     53        }
    4154}
    4255
     
    4457        delete type;
    4558        delete statements;
     59}
     60
     61FunctionDecl * FunctionDecl::newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ) {
     62        return new FunctionDecl( name, Type::StorageClasses(), LinkageSpec::C, type, statements );
    4663}
    4764
  • src/SynTree/Initializer.h

    r12914e9 rea156ae  
    3737        std::list< Expression * > & get_designators() { return designators; }
    3838
    39         virtual Designation * clone() const { return new Designation( *this ); };
     39        virtual Designation * clone() const override { return new Designation( *this ); };
    4040        virtual void accept( Visitor &v ) override { v.visit( this ); }
    41         virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
     41        virtual Designation * acceptMutator( Mutator &m ) override { return m.mutate( this ); }
    4242        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4343};
     
    5454        bool get_maybeConstructed() { return maybeConstructed; }
    5555
    56         virtual Initializer *clone() const = 0;
     56        virtual Initializer *clone() const override = 0;
    5757        virtual void accept( Visitor &v ) override = 0;
    58         virtual Initializer *acceptMutator( Mutator &m ) = 0;
     58        virtual Initializer *acceptMutator( Mutator &m ) override = 0;
    5959        virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
    6060  private:
     
    117117        Statement * ctor;
    118118        Statement * dtor;
     119        // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
     120        // if an appropriate constructor definition is not found by the resolver
     121        Initializer * init;
    119122
    120123        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
     
    135138
    136139  private:
    137         // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
    138         // if an appropriate constructor definition is not found by the resolver
    139         Initializer * init;
    140140};
    141141
  • src/SynTree/Mutator.cc

    r12914e9 rea156ae  
    1717#include <list>                // for list
    1818
     19#include "Attribute.h"         // for Attribute
    1920#include "Declaration.h"       // for ObjectDecl, Declaration, DeclarationWi...
    2021#include "Expression.h"        // for Expression, ConstantExpr, ConditionalExpr
     
    3637        objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
    3738        objectDecl->set_bitfieldWidth( maybeMutate( objectDecl->get_bitfieldWidth(), *this ) );
     39        mutateAll( objectDecl->attributes, *this );
    3840        return objectDecl;
    3941}
     
    4244        functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
    4345        functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
     46        mutateAll( functionDecl->attributes, *this );
    4447        return functionDecl;
    4548}
     
    618621}
    619622
     623Attribute * Mutator::mutate( Attribute * attribute ) {
     624        mutateAll( attribute->parameters, *this );
     625        return attribute;
     626}
     627
    620628// Local Variables: //
    621629// tab-width: 4 //
  • src/SynTree/Mutator.h

    r12914e9 rea156ae  
    2525        virtual ~Mutator();
    2626  public:
    27         virtual DeclarationWithType* mutate( ObjectDecl *objectDecl );
    28         virtual DeclarationWithType* mutate( FunctionDecl *functionDecl );
    29         virtual Declaration* mutate( StructDecl *aggregateDecl );
    30         virtual Declaration* mutate( UnionDecl *aggregateDecl );
    31         virtual Declaration* mutate( EnumDecl *aggregateDecl );
    32         virtual Declaration* mutate( TraitDecl *aggregateDecl );
    33         virtual Declaration* mutate( TypeDecl *typeDecl );
    34         virtual Declaration* mutate( TypedefDecl *typeDecl );
    35         virtual AsmDecl* mutate( AsmDecl *asmDecl );
     27        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl );
     28        virtual DeclarationWithType * mutate( FunctionDecl * functionDecl );
     29        virtual Declaration * mutate( StructDecl * aggregateDecl );
     30        virtual Declaration * mutate( UnionDecl * aggregateDecl );
     31        virtual Declaration * mutate( EnumDecl * aggregateDecl );
     32        virtual Declaration * mutate( TraitDecl * aggregateDecl );
     33        virtual Declaration * mutate( TypeDecl * typeDecl );
     34        virtual Declaration * mutate( TypedefDecl * typeDecl );
     35        virtual AsmDecl * mutate( AsmDecl * asmDecl );
    3636
    37         virtual CompoundStmt* mutate( CompoundStmt *compoundStmt );
    38         virtual Statement* mutate( ExprStmt *exprStmt );
    39         virtual Statement* mutate( AsmStmt *asmStmt );
    40         virtual Statement* mutate( IfStmt *ifStmt );
    41         virtual Statement* mutate( WhileStmt *whileStmt );
    42         virtual Statement* mutate( ForStmt *forStmt );
    43         virtual Statement* mutate( SwitchStmt *switchStmt );
    44         virtual Statement* mutate( CaseStmt *caseStmt );
    45         virtual Statement* mutate( BranchStmt *branchStmt );
    46         virtual Statement* mutate( ReturnStmt *returnStmt );
    47         virtual Statement* mutate( ThrowStmt *throwStmt );
    48         virtual Statement* mutate( TryStmt *tryStmt );
    49         virtual Statement* mutate( CatchStmt *catchStmt );
    50         virtual Statement* mutate( FinallyStmt *catchStmt );
    51         virtual Statement* mutate( WaitForStmt *waitforStmt );
    52         virtual NullStmt* mutate( NullStmt *nullStmt );
    53         virtual Statement* mutate( DeclStmt *declStmt );
    54         virtual Statement* mutate( ImplicitCtorDtorStmt *impCtorDtorStmt );
     37        virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
     38        virtual Statement * mutate( ExprStmt * exprStmt );
     39        virtual Statement * mutate( AsmStmt * asmStmt );
     40        virtual Statement * mutate( IfStmt * ifStmt );
     41        virtual Statement * mutate( WhileStmt * whileStmt );
     42        virtual Statement * mutate( ForStmt * forStmt );
     43        virtual Statement * mutate( SwitchStmt * switchStmt );
     44        virtual Statement * mutate( CaseStmt * caseStmt );
     45        virtual Statement * mutate( BranchStmt * branchStmt );
     46        virtual Statement * mutate( ReturnStmt * returnStmt );
     47        virtual Statement * mutate( ThrowStmt * throwStmt );
     48        virtual Statement * mutate( TryStmt * tryStmt );
     49        virtual Statement * mutate( CatchStmt * catchStmt );
     50        virtual Statement * mutate( FinallyStmt * catchStmt );
     51        virtual Statement * mutate( WaitForStmt * waitforStmt );
     52        virtual NullStmt * mutate( NullStmt * nullStmt );
     53        virtual Statement * mutate( DeclStmt * declStmt );
     54        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt );
    5555
    56         virtual Expression* mutate( ApplicationExpr *applicationExpr );
    57         virtual Expression* mutate( UntypedExpr *untypedExpr );
    58         virtual Expression* mutate( NameExpr *nameExpr );
    59         virtual Expression* mutate( AddressExpr *castExpr );
    60         virtual Expression* mutate( LabelAddressExpr *labAddressExpr );
    61         virtual Expression* mutate( CastExpr *castExpr );
    62         virtual Expression* mutate( VirtualCastExpr *castExpr );
    63         virtual Expression* mutate( UntypedMemberExpr *memberExpr );
    64         virtual Expression* mutate( MemberExpr *memberExpr );
    65         virtual Expression* mutate( VariableExpr *variableExpr );
    66         virtual Expression* mutate( ConstantExpr *constantExpr );
    67         virtual Expression* mutate( SizeofExpr *sizeofExpr );
    68         virtual Expression* mutate( AlignofExpr *alignofExpr );
    69         virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr );
    70         virtual Expression* mutate( OffsetofExpr *offsetofExpr );
    71         virtual Expression* mutate( OffsetPackExpr *offsetPackExpr );
    72         virtual Expression* mutate( AttrExpr *attrExpr );
    73         virtual Expression* mutate( LogicalExpr *logicalExpr );
    74         virtual Expression* mutate( ConditionalExpr *conditionalExpr );
    75         virtual Expression* mutate( CommaExpr *commaExpr );
    76         virtual Expression* mutate( TypeExpr *typeExpr );
    77         virtual Expression* mutate( AsmExpr *asmExpr );
    78         virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr );
    79         virtual Expression* mutate( ConstructorExpr *ctorExpr );
    80         virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    81         virtual Expression* mutate( RangeExpr *rangeExpr );
    82         virtual Expression* mutate( UntypedTupleExpr *tupleExpr );
    83         virtual Expression* mutate( TupleExpr *tupleExpr );
    84         virtual Expression* mutate( TupleIndexExpr *tupleExpr );
    85         virtual Expression* mutate( TupleAssignExpr *assignExpr );
    86         virtual Expression* mutate( StmtExpr * stmtExpr );
    87         virtual Expression* mutate( UniqueExpr * uniqueExpr );
    88         virtual Expression* mutate( UntypedInitExpr * initExpr );
    89         virtual Expression* mutate( InitExpr * initExpr );
     56        virtual Expression* mutate( ApplicationExpr * applicationExpr );
     57        virtual Expression* mutate( UntypedExpr * untypedExpr );
     58        virtual Expression* mutate( NameExpr * nameExpr );
     59        virtual Expression* mutate( AddressExpr * castExpr );
     60        virtual Expression* mutate( LabelAddressExpr * labAddressExpr );
     61        virtual Expression* mutate( CastExpr * castExpr );
     62        virtual Expression* mutate( VirtualCastExpr * castExpr );
     63        virtual Expression* mutate( UntypedMemberExpr * memberExpr );
     64        virtual Expression* mutate( MemberExpr * memberExpr );
     65        virtual Expression* mutate( VariableExpr * variableExpr );
     66        virtual Expression* mutate( ConstantExpr * constantExpr );
     67        virtual Expression* mutate( SizeofExpr * sizeofExpr );
     68        virtual Expression* mutate( AlignofExpr * alignofExpr );
     69        virtual Expression* mutate( UntypedOffsetofExpr * offsetofExpr );
     70        virtual Expression* mutate( OffsetofExpr * offsetofExpr );
     71        virtual Expression* mutate( OffsetPackExpr * offsetPackExpr );
     72        virtual Expression* mutate( AttrExpr * attrExpr );
     73        virtual Expression* mutate( LogicalExpr * logicalExpr );
     74        virtual Expression* mutate( ConditionalExpr * conditionalExpr );
     75        virtual Expression* mutate( CommaExpr * commaExpr );
     76        virtual Expression* mutate( TypeExpr * typeExpr );
     77        virtual Expression* mutate( AsmExpr * asmExpr );
     78        virtual Expression* mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
     79        virtual Expression* mutate( ConstructorExpr * ctorExpr );
     80        virtual Expression* mutate( CompoundLiteralExpr * compLitExpr );
     81        virtual Expression* mutate( RangeExpr * rangeExpr );
     82        virtual Expression* mutate( UntypedTupleExpr * tupleExpr );
     83        virtual Expression* mutate( TupleExpr * tupleExpr );
     84        virtual Expression* mutate( TupleIndexExpr * tupleExpr );
     85        virtual Expression* mutate( TupleAssignExpr * assignExpr );
     86        virtual Expression* mutate( StmtExpr  * stmtExpr );
     87        virtual Expression* mutate( UniqueExpr  * uniqueExpr );
     88        virtual Expression* mutate( UntypedInitExpr  * initExpr );
     89        virtual Expression* mutate( InitExpr  * initExpr );
    9090
    91         virtual Type* mutate( VoidType *basicType );
    92         virtual Type* mutate( BasicType *basicType );
    93         virtual Type* mutate( PointerType *pointerType );
    94         virtual Type* mutate( ArrayType *arrayType );
    95         virtual Type* mutate( ReferenceType *refType );
    96         virtual Type* mutate( FunctionType *functionType );
    97         virtual Type* mutate( StructInstType *aggregateUseType );
    98         virtual Type* mutate( UnionInstType *aggregateUseType );
    99         virtual Type* mutate( EnumInstType *aggregateUseType );
    100         virtual Type* mutate( TraitInstType *aggregateUseType );
    101         virtual Type* mutate( TypeInstType *aggregateUseType );
    102         virtual Type* mutate( TupleType *tupleType );
    103         virtual Type* mutate( TypeofType *typeofType );
    104         virtual Type* mutate( AttrType *attrType );
    105         virtual Type* mutate( VarArgsType *varArgsType );
    106         virtual Type* mutate( ZeroType *zeroType );
    107         virtual Type* mutate( OneType *oneType );
     91        virtual Type * mutate( VoidType * basicType );
     92        virtual Type * mutate( BasicType * basicType );
     93        virtual Type * mutate( PointerType * pointerType );
     94        virtual Type * mutate( ArrayType * arrayType );
     95        virtual Type * mutate( ReferenceType * refType );
     96        virtual Type * mutate( FunctionType * functionType );
     97        virtual Type * mutate( StructInstType * aggregateUseType );
     98        virtual Type * mutate( UnionInstType * aggregateUseType );
     99        virtual Type * mutate( EnumInstType * aggregateUseType );
     100        virtual Type * mutate( TraitInstType * aggregateUseType );
     101        virtual Type * mutate( TypeInstType * aggregateUseType );
     102        virtual Type * mutate( TupleType * tupleType );
     103        virtual Type * mutate( TypeofType * typeofType );
     104        virtual Type * mutate( AttrType * attrType );
     105        virtual Type * mutate( VarArgsType * varArgsType );
     106        virtual Type * mutate( ZeroType * zeroType );
     107        virtual Type * mutate( OneType * oneType );
    108108
    109         virtual Designation* mutate( Designation *designation );
    110         virtual Initializer* mutate( SingleInit *singleInit );
    111         virtual Initializer* mutate( ListInit *listInit );
    112         virtual Initializer* mutate( ConstructorInit *ctorInit );
     109        virtual Designation * mutate( Designation * designation );
     110        virtual Initializer * mutate( SingleInit * singleInit );
     111        virtual Initializer * mutate( ListInit * listInit );
     112        virtual Initializer * mutate( ConstructorInit * ctorInit );
    113113
    114         virtual Subrange *mutate( Subrange *subrange );
     114        virtual Subrange * mutate( Subrange * subrange );
    115115
    116         virtual Constant *mutate( Constant *constant );
     116        virtual Constant * mutate( Constant * constant );
     117
     118        virtual Attribute * mutate( Attribute * attribute );
    117119  private:
    118         virtual Declaration* handleAggregateDecl(AggregateDecl *aggregateDecl );
    119         virtual Declaration* handleNamedTypeDecl(NamedTypeDecl *typeDecl );
    120         virtual Type* handleReferenceToType(ReferenceToType *aggregateUseType );
     120        virtual Declaration * handleAggregateDecl(AggregateDecl * aggregateDecl );
     121        virtual Declaration * handleNamedTypeDecl(NamedTypeDecl * typeDecl );
     122        virtual Type * handleReferenceToType(ReferenceToType * aggregateUseType );
    121123};
    122124
  • src/SynTree/Statement.h

    r12914e9 rea156ae  
    4343        const std::list<Label> & get_labels() const { return labels; }
    4444
    45         virtual Statement *clone() const = 0;
     45        virtual Statement *clone() const override = 0;
    4646        virtual void accept( Visitor &v ) override = 0;
    47         virtual Statement *acceptMutator( Mutator &m ) = 0;
     47        virtual Statement *acceptMutator( Mutator &m ) override = 0;
    4848        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4949};
  • src/SynTree/VarExprReplacer.h

    r12914e9 rea156ae  
    2929private:
    3030        const DeclMap & declMap;
    31   bool debug;
     31        bool debug;
    3232public:
    3333        VarExprReplacer( const DeclMap & declMap, bool debug = false );
     
    3535        // replace variable with new node from decl map
    3636        virtual void visit( VariableExpr * varExpr );
     37
     38        static void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false ) {
     39                VarExprReplacer replacer( declMap, debug );
     40                maybeAccept( node, replacer );
     41        }
    3742};
    3843
  • src/SynTree/Visitor.cc

    r12914e9 rea156ae  
    1717#include <list>           // for list
    1818
     19#include "Attribute.h"    // for Attribute
    1920#include "Constant.h"     // for Constant
    2021#include "Declaration.h"  // for DeclarationWithType, ObjectDecl, Declaration
     
    3536        maybeAccept( objectDecl->get_init(), *this );
    3637        maybeAccept( objectDecl->get_bitfieldWidth(), *this );
     38        acceptAll( objectDecl->attributes, *this );
    3739}
    3840
     
    4042        maybeAccept( functionDecl->get_functionType(), *this );
    4143        maybeAccept( functionDecl->get_statements(), *this );
     44        acceptAll( functionDecl->attributes, *this );
    4245}
    4346
     
    487490
    488491
    489 void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
    490 
    491 
    492 void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
     492void Visitor::visit( Subrange * ) {}
     493
     494
     495void Visitor::visit( Constant * ) {}
     496
     497void Visitor::visit( Attribute * attribute ) {
     498        acceptAll( attribute->parameters, *this );
     499}
     500
    493501// Local Variables: //
    494502// tab-width: 4 //
  • src/SynTree/Visitor.h

    r12914e9 rea156ae  
    2727        // of the given syntax node, but performs no other action.
    2828
    29         virtual void visit( ObjectDecl *objectDecl );
    30         virtual void visit( FunctionDecl *functionDecl );
    31         virtual void visit( StructDecl *aggregateDecl );
    32         virtual void visit( UnionDecl *aggregateDecl );
    33         virtual void visit( EnumDecl *aggregateDecl );
    34         virtual void visit( TraitDecl *aggregateDecl );
    35         virtual void visit( TypeDecl *typeDecl );
    36         virtual void visit( TypedefDecl *typeDecl );
    37         virtual void visit( AsmDecl *asmDecl );
     29        virtual void visit( ObjectDecl * objectDecl );
     30        virtual void visit( FunctionDecl * functionDecl );
     31        virtual void visit( StructDecl * aggregateDecl );
     32        virtual void visit( UnionDecl * aggregateDecl );
     33        virtual void visit( EnumDecl * aggregateDecl );
     34        virtual void visit( TraitDecl * aggregateDecl );
     35        virtual void visit( TypeDecl * typeDecl );
     36        virtual void visit( TypedefDecl * typeDecl );
     37        virtual void visit( AsmDecl * asmDecl );
    3838
    39         virtual void visit( CompoundStmt *compoundStmt );
    40         virtual void visit( ExprStmt *exprStmt );
    41         virtual void visit( AsmStmt *asmStmt );
    42         virtual void visit( IfStmt *ifStmt );
    43         virtual void visit( WhileStmt *whileStmt );
    44         virtual void visit( ForStmt *forStmt );
    45         virtual void visit( SwitchStmt *switchStmt );
    46         virtual void visit( CaseStmt *caseStmt );
    47         virtual void visit( BranchStmt *branchStmt );
    48         virtual void visit( ReturnStmt *returnStmt );
    49         virtual void visit( ThrowStmt *throwStmt );
    50         virtual void visit( TryStmt *tryStmt );
    51         virtual void visit( CatchStmt *catchStmt );
    52         virtual void visit( FinallyStmt *finallyStmt );
    53         virtual void visit( WaitForStmt *waitforStmt );
    54         virtual void visit( NullStmt *nullStmt );
    55         virtual void visit( DeclStmt *declStmt );
    56         virtual void visit( ImplicitCtorDtorStmt *impCtorDtorStmt );
     39        virtual void visit( CompoundStmt * compoundStmt );
     40        virtual void visit( ExprStmt * exprStmt );
     41        virtual void visit( AsmStmt * asmStmt );
     42        virtual void visit( IfStmt * ifStmt );
     43        virtual void visit( WhileStmt * whileStmt );
     44        virtual void visit( ForStmt * forStmt );
     45        virtual void visit( SwitchStmt * switchStmt );
     46        virtual void visit( CaseStmt * caseStmt );
     47        virtual void visit( BranchStmt * branchStmt );
     48        virtual void visit( ReturnStmt * returnStmt );
     49        virtual void visit( ThrowStmt * throwStmt );
     50        virtual void visit( TryStmt * tryStmt );
     51        virtual void visit( CatchStmt * catchStmt );
     52        virtual void visit( FinallyStmt * finallyStmt );
     53        virtual void visit( WaitForStmt * waitforStmt );
     54        virtual void visit( NullStmt * nullStmt );
     55        virtual void visit( DeclStmt * declStmt );
     56        virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );
    5757
    58         virtual void visit( ApplicationExpr *applicationExpr );
    59         virtual void visit( UntypedExpr *untypedExpr );
    60         virtual void visit( NameExpr *nameExpr );
    61         virtual void visit( CastExpr *castExpr );
    62         virtual void visit( VirtualCastExpr *castExpr );
    63         virtual void visit( AddressExpr *addressExpr );
    64         virtual void visit( LabelAddressExpr *labAddressExpr );
    65         virtual void visit( UntypedMemberExpr *memberExpr );
    66         virtual void visit( MemberExpr *memberExpr );
    67         virtual void visit( VariableExpr *variableExpr );
    68         virtual void visit( ConstantExpr *constantExpr );
    69         virtual void visit( SizeofExpr *sizeofExpr );
    70         virtual void visit( AlignofExpr *alignofExpr );
    71         virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    72         virtual void visit( OffsetofExpr *offsetofExpr );
    73         virtual void visit( OffsetPackExpr *offsetPackExpr );
    74         virtual void visit( AttrExpr *attrExpr );
    75         virtual void visit( LogicalExpr *logicalExpr );
    76         virtual void visit( ConditionalExpr *conditionalExpr );
    77         virtual void visit( CommaExpr *commaExpr );
    78         virtual void visit( TypeExpr *typeExpr );
    79         virtual void visit( AsmExpr *asmExpr );
    80         virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );
    81         virtual void visit( ConstructorExpr * ctorExpr );
    82         virtual void visit( CompoundLiteralExpr *compLitExpr );
    83         virtual void visit( RangeExpr *rangeExpr );
    84         virtual void visit( UntypedTupleExpr *tupleExpr );
    85         virtual void visit( TupleExpr *tupleExpr );
    86         virtual void visit( TupleIndexExpr *tupleExpr );
    87         virtual void visit( TupleAssignExpr *assignExpr );
    88         virtual void visit( StmtExpr * stmtExpr );
    89         virtual void visit( UniqueExpr * uniqueExpr );
    90         virtual void visit( UntypedInitExpr * initExpr );
    91         virtual void visit( InitExpr * initExpr );
     58        virtual void visit( ApplicationExpr * applicationExpr );
     59        virtual void visit( UntypedExpr * untypedExpr );
     60        virtual void visit( NameExpr * nameExpr );
     61        virtual void visit( CastExpr * castExpr );
     62        virtual void visit( VirtualCastExpr * castExpr );
     63        virtual void visit( AddressExpr * addressExpr );
     64        virtual void visit( LabelAddressExpr * labAddressExpr );
     65        virtual void visit( UntypedMemberExpr * memberExpr );
     66        virtual void visit( MemberExpr * memberExpr );
     67        virtual void visit( VariableExpr * variableExpr );
     68        virtual void visit( ConstantExpr * constantExpr );
     69        virtual void visit( SizeofExpr * sizeofExpr );
     70        virtual void visit( AlignofExpr * alignofExpr );
     71        virtual void visit( UntypedOffsetofExpr * offsetofExpr );
     72        virtual void visit( OffsetofExpr * offsetofExpr );
     73        virtual void visit( OffsetPackExpr * offsetPackExpr );
     74        virtual void visit( AttrExpr * attrExpr );
     75        virtual void visit( LogicalExpr * logicalExpr );
     76        virtual void visit( ConditionalExpr * conditionalExpr );
     77        virtual void visit( CommaExpr * commaExpr );
     78        virtual void visit( TypeExpr * typeExpr );
     79        virtual void visit( AsmExpr * asmExpr );
     80        virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
     81        virtual void visit( ConstructorExpr *  ctorExpr );
     82        virtual void visit( CompoundLiteralExpr * compLitExpr );
     83        virtual void visit( RangeExpr * rangeExpr );
     84        virtual void visit( UntypedTupleExpr * tupleExpr );
     85        virtual void visit( TupleExpr * tupleExpr );
     86        virtual void visit( TupleIndexExpr * tupleExpr );
     87        virtual void visit( TupleAssignExpr * assignExpr );
     88        virtual void visit( StmtExpr *  stmtExpr );
     89        virtual void visit( UniqueExpr *  uniqueExpr );
     90        virtual void visit( UntypedInitExpr *  initExpr );
     91        virtual void visit( InitExpr *  initExpr );
    9292
    93         virtual void visit( VoidType *basicType );
    94         virtual void visit( BasicType *basicType );
    95         virtual void visit( PointerType *pointerType );
    96         virtual void visit( ArrayType *arrayType );
    97         virtual void visit( ReferenceType *refType );
    98         virtual void visit( FunctionType *functionType );
    99         virtual void visit( StructInstType *aggregateUseType );
    100         virtual void visit( UnionInstType *aggregateUseType );
    101         virtual void visit( EnumInstType *aggregateUseType );
    102         virtual void visit( TraitInstType *aggregateUseType );
    103         virtual void visit( TypeInstType *aggregateUseType );
    104         virtual void visit( TupleType *tupleType );
    105         virtual void visit( TypeofType *typeofType );
    106         virtual void visit( AttrType *attrType );
    107         virtual void visit( VarArgsType *varArgsType );
    108         virtual void visit( ZeroType *zeroType );
    109         virtual void visit( OneType *oneType );
     93        virtual void visit( VoidType * basicType );
     94        virtual void visit( BasicType * basicType );
     95        virtual void visit( PointerType * pointerType );
     96        virtual void visit( ArrayType * arrayType );
     97        virtual void visit( ReferenceType * refType );
     98        virtual void visit( FunctionType * functionType );
     99        virtual void visit( StructInstType * aggregateUseType );
     100        virtual void visit( UnionInstType * aggregateUseType );
     101        virtual void visit( EnumInstType * aggregateUseType );
     102        virtual void visit( TraitInstType * aggregateUseType );
     103        virtual void visit( TypeInstType * aggregateUseType );
     104        virtual void visit( TupleType * tupleType );
     105        virtual void visit( TypeofType * typeofType );
     106        virtual void visit( AttrType * attrType );
     107        virtual void visit( VarArgsType * varArgsType );
     108        virtual void visit( ZeroType * zeroType );
     109        virtual void visit( OneType * oneType );
    110110
    111         virtual void visit( Designation *designation );
    112         virtual void visit( SingleInit *singleInit );
    113         virtual void visit( ListInit *listInit );
    114         virtual void visit( ConstructorInit *ctorInit );
     111        virtual void visit( Designation * designation );
     112        virtual void visit( SingleInit * singleInit );
     113        virtual void visit( ListInit * listInit );
     114        virtual void visit( ConstructorInit * ctorInit );
    115115
    116         virtual void visit( Subrange *subrange );
     116        virtual void visit( Subrange * subrange );
    117117
    118         virtual void visit( Constant *constant );
     118        virtual void visit( Constant * constant );
     119
     120        virtual void visit( Attribute * attribute );
    119121  private:
    120122        virtual void handleAggregateDecl( AggregateDecl *aggregateDecl );
Note: See TracChangeset for help on using the changeset viewer.