Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1ae47de ra2a85658  
    10751075        }
    10761076
    1077         const ast::Type * visitType( const ast::Type * node, Type * type ) {
    1078                 // Some types do this in their constructor so add a check.
    1079                 if ( !node->attributes.empty() && type->attributes.empty() ) {
    1080                         type->attributes = get<Attribute>().acceptL( node->attributes );
    1081                 }
    1082                 this->node = type;
    1083                 return nullptr;
    1084         }
    1085 
    10861077        const ast::Type * visit( const ast::VoidType * node ) override final {
    1087                 return visitType( node, new VoidType{ cv( node ) } );
     1078                this->node = new VoidType{ cv( node ) };
     1079                return nullptr;
    10881080        }
    10891081
     
    10941086                        Validate::SizeType = type;
    10951087                }
    1096                 return visitType( node, type );
     1088                this->node = type;
     1089                return nullptr;
    10971090        }
    10981091
    10991092        const ast::Type * visit( const ast::PointerType * node ) override final {
    1100                 return visitType( node, new PointerType{
     1093                this->node = new PointerType{
    11011094                        cv( node ),
    11021095                        get<Type>().accept1( node->base ),
     
    11041097                        (bool)node->isVarLen,
    11051098                        (bool)node->isStatic
    1106                 } );
     1099                };
     1100                return nullptr;
    11071101        }
    11081102
    11091103        const ast::Type * visit( const ast::ArrayType * node ) override final {
    1110                 return visitType( node, new ArrayType{
     1104                this->node = new ArrayType{
    11111105                        cv( node ),
    11121106                        get<Type>().accept1( node->base ),
     
    11141108                        (bool)node->isVarLen,
    11151109                        (bool)node->isStatic
    1116                 } );
     1110                };
     1111                return nullptr;
    11171112        }
    11181113
    11191114        const ast::Type * visit( const ast::ReferenceType * node ) override final {
    1120                 return visitType( node, new ReferenceType{
     1115                this->node = new ReferenceType{
    11211116                        cv( node ),
    11221117                        get<Type>().accept1( node->base )
    1123                 } );
     1118                };
     1119                return nullptr;
    11241120        }
    11251121
    11261122        const ast::Type * visit( const ast::QualifiedType * node ) override final {
    1127                 return visitType( node, new QualifiedType{
     1123                this->node = new QualifiedType{
    11281124                        cv( node ),
    11291125                        get<Type>().accept1( node->parent ),
    11301126                        get<Type>().accept1( node->child )
    1131                 } );
     1127                };
     1128                return nullptr;
    11321129        }
    11331130
     
    11401137                ty->parameters = get<DeclarationWithType>().acceptL( node->params );
    11411138                ty->forall = get<TypeDecl>().acceptL( node->forall );
    1142                 return visitType( node, ty );
    1143         }
    1144 
    1145         const ast::Type * postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
     1139                this->node = ty;
     1140                return nullptr;
     1141        }
     1142
     1143        void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
    11461144                ty->forall = get<TypeDecl>().acceptL( old->forall );
    11471145                ty->parameters = get<Expression>().acceptL( old->params );
    11481146                ty->hoistType = old->hoistType;
    1149                 return visitType( old, ty );
    11501147        }
    11511148
     
    11651162                        };
    11661163                }
    1167                 return postvisit( node, ty );
     1164                postvisit( node, ty );
     1165                this->node = ty;
     1166                return nullptr;
    11681167        }
    11691168
     
    11831182                        };
    11841183                }
    1185                 return postvisit( node, ty );
     1184                postvisit( node, ty );
     1185                this->node = ty;
     1186                return nullptr;
    11861187        }
    11871188
     
    12011202                        };
    12021203                }
    1203                 return postvisit( node, ty );
     1204                postvisit( node, ty );
     1205                this->node = ty;
     1206                return nullptr;
    12041207        }
    12051208
     
    12191222                        };
    12201223                }
    1221                 return postvisit( node, ty );
     1224                postvisit( node, ty );
     1225                this->node = ty;
     1226                return nullptr;
    12221227        }
    12231228
     
    12391244                        };
    12401245                }
    1241                 return postvisit( node, ty );
     1246                postvisit( node, ty );
     1247                this->node = ty;
     1248                return nullptr;
    12421249        }
    12431250
    12441251        const ast::Type * visit( const ast::TupleType * node ) override final {
    1245                 return visitType( node, new TupleType{
     1252                this->node = new TupleType{
    12461253                        cv( node ),
    12471254                        get<Type>().acceptL( node->types )
    12481255                        // members generated by TupleType c'tor
    1249                 } );
     1256                };
     1257                return nullptr;
    12501258        }
    12511259
    12521260        const ast::Type * visit( const ast::TypeofType * node ) override final {
    1253                 return visitType( node, new TypeofType{
     1261                this->node = new TypeofType{
    12541262                        cv( node ),
    12551263                        get<Expression>().accept1( node->expr ),
    12561264                        (bool)node->kind
    1257                 } );
     1265                };
     1266                return nullptr;
    12581267        }
    12591268
    12601269        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    1261                 return visitType( node, new VarArgsType{ cv( node ) } );
     1270                this->node = new VarArgsType{ cv( node ) };
     1271                return nullptr;
    12621272        }
    12631273
    12641274        const ast::Type * visit( const ast::ZeroType * node ) override final {
    1265                 return visitType( node, new ZeroType{ cv( node ) } );
     1275                this->node = new ZeroType{ cv( node ) };
     1276                return nullptr;
    12661277        }
    12671278
    12681279        const ast::Type * visit( const ast::OneType * node ) override final {
    1269                 return visitType( node, new OneType{ cv( node ) } );
    1270         }
    1271 
    1272         const ast::Type * visit( const ast::GlobalScopeType * node ) override final {
    1273                 return visitType( node, new GlobalScopeType{} );
     1280                this->node = new OneType{ cv( node ) };
     1281                return nullptr;
     1282        }
     1283
     1284        const ast::Type * visit( const ast::GlobalScopeType * ) override final {
     1285                this->node = new GlobalScopeType{};
     1286                return nullptr;
    12741287        }
    12751288
     
    24292442        }
    24302443
    2431         void visitType( Type * old, ast::Type * type ) {
    2432                 // Some types do this in their constructor so add a check.
    2433                 if ( !old->attributes.empty() && type->attributes.empty() ) {
    2434                         type->attributes = GET_ACCEPT_V(attributes, Attribute);
    2435                 }
    2436                 this->node = type;
    2437         }
    2438 
    24392444        virtual void visit( VoidType * old ) override final {
    2440                 visitType( old, new ast::VoidType{ cv( old ) } );
     2445                this->node = new ast::VoidType{ cv( old ) };
    24412446        }
    24422447
     
    24472452                        sizeType = type;
    24482453                }
    2449                 visitType( old, type );
     2454                this->node = type;
    24502455        }
    24512456
    24522457        virtual void visit( PointerType * old ) override final {
    2453                 visitType( old, new ast::PointerType{
     2458                this->node = new ast::PointerType{
    24542459                        GET_ACCEPT_1( base, Type ),
    24552460                        GET_ACCEPT_1( dimension, Expr ),
     
    24572462                        (ast::DimensionFlag)old->isStatic,
    24582463                        cv( old )
    2459                 } );
     2464                };
    24602465        }
    24612466
    24622467        virtual void visit( ArrayType * old ) override final {
    2463                 visitType( old, new ast::ArrayType{
     2468                this->node = new ast::ArrayType{
    24642469                        GET_ACCEPT_1( base, Type ),
    24652470                        GET_ACCEPT_1( dimension, Expr ),
     
    24672472                        (ast::DimensionFlag)old->isStatic,
    24682473                        cv( old )
    2469                 } );
     2474                };
    24702475        }
    24712476
    24722477        virtual void visit( ReferenceType * old ) override final {
    2473                 visitType( old, new ast::ReferenceType{
     2478                this->node = new ast::ReferenceType{
    24742479                        GET_ACCEPT_1( base, Type ),
    24752480                        cv( old )
    2476                 } );
     2481                };
    24772482        }
    24782483
    24792484        virtual void visit( QualifiedType * old ) override final {
    2480                 visitType( old, new ast::QualifiedType{
     2485                this->node = new ast::QualifiedType{
    24812486                        GET_ACCEPT_1( parent, Type ),
    24822487                        GET_ACCEPT_1( child, Type ),
    24832488                        cv( old )
    2484                 } );
     2489                };
    24852490        }
    24862491
     
    24932498                ty->params = GET_ACCEPT_V( parameters, DeclWithType );
    24942499                ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    2495                 visitType( old, ty );
     2500                this->node = ty;
    24962501        }
    24972502
     
    25002505                ty->params = GET_ACCEPT_V( parameters, Expr );
    25012506                ty->hoistType = old->hoistType;
    2502                 visitType( old, ty );
    25032507        }
    25042508
     
    25192523                }
    25202524                postvisit( old, ty );
     2525                this->node = ty;
    25212526        }
    25222527
     
    25372542                }
    25382543                postvisit( old, ty );
     2544                this->node = ty;
    25392545        }
    25402546
     
    25552561                }
    25562562                postvisit( old, ty );
     2563                this->node = ty;
    25572564        }
    25582565
     
    25732580                }
    25742581                postvisit( old, ty );
     2582                this->node = ty;
    25752583        }
    25762584
     
    25932601                }
    25942602                postvisit( old, ty );
     2603                this->node = ty;
    25952604        }
    25962605
    25972606        virtual void visit( TupleType * old ) override final {
    2598                 visitType( old, new ast::TupleType{
     2607                this->node = new ast::TupleType{
    25992608                        GET_ACCEPT_V( types, Type ),
    26002609                        // members generated by TupleType c'tor
    26012610                        cv( old )
    2602                 } );
     2611                };
    26032612        }
    26042613
    26052614        virtual void visit( TypeofType * old ) override final {
    2606                 visitType( old, new ast::TypeofType{
     2615                this->node = new ast::TypeofType{
    26072616                        GET_ACCEPT_1( expr, Expr ),
    26082617                        (ast::TypeofType::Kind)old->is_basetypeof,
    26092618                        cv( old )
    2610                 } );
     2619                };
    26112620        }
    26122621
     
    26162625
    26172626        virtual void visit( VarArgsType * old ) override final {
    2618                 visitType( old, new ast::VarArgsType{ cv( old ) } );
     2627                this->node = new ast::VarArgsType{ cv( old ) };
    26192628        }
    26202629
    26212630        virtual void visit( ZeroType * old ) override final {
    2622                 visitType( old, new ast::ZeroType{ cv( old ) } );
     2631                this->node = new ast::ZeroType{ cv( old ) };
    26232632        }
    26242633
    26252634        virtual void visit( OneType * old ) override final {
    2626                 visitType( old, new ast::OneType{ cv( old ) } );
    2627         }
    2628 
    2629         virtual void visit( GlobalScopeType * old ) override final {
    2630                 visitType( old, new ast::GlobalScopeType{} );
     2635                this->node = new ast::OneType{ cv( old ) };
     2636        }
     2637
     2638        virtual void visit( GlobalScopeType * ) override final {
     2639                this->node = new ast::GlobalScopeType{};
    26312640        }
    26322641
Note: See TracChangeset for help on using the changeset viewer.