Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1ae47de r1e5dedc4  
    993993        const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
    994994                auto rslt = new UniqueExpr(
    995                         get<Expression>().accept1(node->expr),
    996                         node->id
     995                        get<Expression>().accept1(node->expr)
    997996                );
    998997
     
    10751074        }
    10761075
    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 
    10861076        const ast::Type * visit( const ast::VoidType * node ) override final {
    1087                 return visitType( node, new VoidType{ cv( node ) } );
     1077                this->node = new VoidType{ cv( node ) };
     1078                return nullptr;
    10881079        }
    10891080
     
    10941085                        Validate::SizeType = type;
    10951086                }
    1096                 return visitType( node, type );
     1087                this->node = type;
     1088                return nullptr;
    10971089        }
    10981090
    10991091        const ast::Type * visit( const ast::PointerType * node ) override final {
    1100                 return visitType( node, new PointerType{
     1092                this->node = new PointerType{
    11011093                        cv( node ),
    11021094                        get<Type>().accept1( node->base ),
     
    11041096                        (bool)node->isVarLen,
    11051097                        (bool)node->isStatic
    1106                 } );
     1098                };
     1099                return nullptr;
    11071100        }
    11081101
    11091102        const ast::Type * visit( const ast::ArrayType * node ) override final {
    1110                 return visitType( node, new ArrayType{
     1103                this->node = new ArrayType{
    11111104                        cv( node ),
    11121105                        get<Type>().accept1( node->base ),
     
    11141107                        (bool)node->isVarLen,
    11151108                        (bool)node->isStatic
    1116                 } );
     1109                };
     1110                return nullptr;
    11171111        }
    11181112
    11191113        const ast::Type * visit( const ast::ReferenceType * node ) override final {
    1120                 return visitType( node, new ReferenceType{
     1114                this->node = new ReferenceType{
    11211115                        cv( node ),
    11221116                        get<Type>().accept1( node->base )
    1123                 } );
     1117                };
     1118                return nullptr;
    11241119        }
    11251120
    11261121        const ast::Type * visit( const ast::QualifiedType * node ) override final {
    1127                 return visitType( node, new QualifiedType{
     1122                this->node = new QualifiedType{
    11281123                        cv( node ),
    11291124                        get<Type>().accept1( node->parent ),
    11301125                        get<Type>().accept1( node->child )
    1131                 } );
     1126                };
     1127                return nullptr;
    11321128        }
    11331129
     
    11401136                ty->parameters = get<DeclarationWithType>().acceptL( node->params );
    11411137                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 ) {
     1138                this->node = ty;
     1139                return nullptr;
     1140        }
     1141
     1142        void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
    11461143                ty->forall = get<TypeDecl>().acceptL( old->forall );
    11471144                ty->parameters = get<Expression>().acceptL( old->params );
    11481145                ty->hoistType = old->hoistType;
    1149                 return visitType( old, ty );
    11501146        }
    11511147
     
    11651161                        };
    11661162                }
    1167                 return postvisit( node, ty );
     1163                postvisit( node, ty );
     1164                this->node = ty;
     1165                return nullptr;
    11681166        }
    11691167
     
    11831181                        };
    11841182                }
    1185                 return postvisit( node, ty );
     1183                postvisit( node, ty );
     1184                this->node = ty;
     1185                return nullptr;
    11861186        }
    11871187
     
    12011201                        };
    12021202                }
    1203                 return postvisit( node, ty );
     1203                postvisit( node, ty );
     1204                this->node = ty;
     1205                return nullptr;
    12041206        }
    12051207
     
    12191221                        };
    12201222                }
    1221                 return postvisit( node, ty );
     1223                postvisit( node, ty );
     1224                this->node = ty;
     1225                return nullptr;
    12221226        }
    12231227
     
    12391243                        };
    12401244                }
    1241                 return postvisit( node, ty );
     1245                postvisit( node, ty );
     1246                this->node = ty;
     1247                return nullptr;
    12421248        }
    12431249
    12441250        const ast::Type * visit( const ast::TupleType * node ) override final {
    1245                 return visitType( node, new TupleType{
     1251                this->node = new TupleType{
    12461252                        cv( node ),
    12471253                        get<Type>().acceptL( node->types )
    12481254                        // members generated by TupleType c'tor
    1249                 } );
     1255                };
     1256                return nullptr;
    12501257        }
    12511258
    12521259        const ast::Type * visit( const ast::TypeofType * node ) override final {
    1253                 return visitType( node, new TypeofType{
     1260                this->node = new TypeofType{
    12541261                        cv( node ),
    12551262                        get<Expression>().accept1( node->expr ),
    12561263                        (bool)node->kind
    1257                 } );
     1264                };
     1265                return nullptr;
    12581266        }
    12591267
    12601268        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    1261                 return visitType( node, new VarArgsType{ cv( node ) } );
     1269                this->node = new VarArgsType{ cv( node ) };
     1270                return nullptr;
    12621271        }
    12631272
    12641273        const ast::Type * visit( const ast::ZeroType * node ) override final {
    1265                 return visitType( node, new ZeroType{ cv( node ) } );
     1274                this->node = new ZeroType{ cv( node ) };
     1275                return nullptr;
    12661276        }
    12671277
    12681278        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{} );
     1279                this->node = new OneType{ cv( node ) };
     1280                return nullptr;
     1281        }
     1282
     1283        const ast::Type * visit( const ast::GlobalScopeType * ) override final {
     1284                this->node = new GlobalScopeType{};
     1285                return nullptr;
    12741286        }
    12751287
     
    18951907                };
    18961908                stmt->orElse = {
    1897                         GET_ACCEPT_1(timeout.statement, Stmt),
    1898                         GET_ACCEPT_1(timeout.condition, Expr),
     1909                        GET_ACCEPT_1(orelse.statement, Stmt),
     1910                        GET_ACCEPT_1(orelse.condition, Expr),
    18991911                };
    19001912
     
    23552367                auto rslt = new ast::UniqueExpr(
    23562368                        old->location,
    2357                         GET_ACCEPT_1(expr, Expr),
    2358                         old->get_id()
     2369                        GET_ACCEPT_1(expr, Expr)
    23592370                );
    23602371                rslt->object = GET_ACCEPT_1(object, ObjectDecl);
     
    24292440        }
    24302441
    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 
    24392442        virtual void visit( VoidType * old ) override final {
    2440                 visitType( old, new ast::VoidType{ cv( old ) } );
     2443                this->node = new ast::VoidType{ cv( old ) };
    24412444        }
    24422445
     
    24472450                        sizeType = type;
    24482451                }
    2449                 visitType( old, type );
     2452                this->node = type;
    24502453        }
    24512454
    24522455        virtual void visit( PointerType * old ) override final {
    2453                 visitType( old, new ast::PointerType{
     2456                this->node = new ast::PointerType{
    24542457                        GET_ACCEPT_1( base, Type ),
    24552458                        GET_ACCEPT_1( dimension, Expr ),
     
    24572460                        (ast::DimensionFlag)old->isStatic,
    24582461                        cv( old )
    2459                 } );
     2462                };
    24602463        }
    24612464
    24622465        virtual void visit( ArrayType * old ) override final {
    2463                 visitType( old, new ast::ArrayType{
     2466                this->node = new ast::ArrayType{
    24642467                        GET_ACCEPT_1( base, Type ),
    24652468                        GET_ACCEPT_1( dimension, Expr ),
     
    24672470                        (ast::DimensionFlag)old->isStatic,
    24682471                        cv( old )
    2469                 } );
     2472                };
    24702473        }
    24712474
    24722475        virtual void visit( ReferenceType * old ) override final {
    2473                 visitType( old, new ast::ReferenceType{
     2476                this->node = new ast::ReferenceType{
    24742477                        GET_ACCEPT_1( base, Type ),
    24752478                        cv( old )
    2476                 } );
     2479                };
    24772480        }
    24782481
    24792482        virtual void visit( QualifiedType * old ) override final {
    2480                 visitType( old, new ast::QualifiedType{
     2483                this->node = new ast::QualifiedType{
    24812484                        GET_ACCEPT_1( parent, Type ),
    24822485                        GET_ACCEPT_1( child, Type ),
    24832486                        cv( old )
    2484                 } );
     2487                };
    24852488        }
    24862489
     
    24932496                ty->params = GET_ACCEPT_V( parameters, DeclWithType );
    24942497                ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    2495                 visitType( old, ty );
     2498                this->node = ty;
    24962499        }
    24972500
     
    25002503                ty->params = GET_ACCEPT_V( parameters, Expr );
    25012504                ty->hoistType = old->hoistType;
    2502                 visitType( old, ty );
    25032505        }
    25042506
     
    25192521                }
    25202522                postvisit( old, ty );
     2523                this->node = ty;
    25212524        }
    25222525
     
    25372540                }
    25382541                postvisit( old, ty );
     2542                this->node = ty;
    25392543        }
    25402544
     
    25552559                }
    25562560                postvisit( old, ty );
     2561                this->node = ty;
    25572562        }
    25582563
     
    25732578                }
    25742579                postvisit( old, ty );
     2580                this->node = ty;
    25752581        }
    25762582
     
    25932599                }
    25942600                postvisit( old, ty );
     2601                this->node = ty;
    25952602        }
    25962603
    25972604        virtual void visit( TupleType * old ) override final {
    2598                 visitType( old, new ast::TupleType{
     2605                this->node = new ast::TupleType{
    25992606                        GET_ACCEPT_V( types, Type ),
    26002607                        // members generated by TupleType c'tor
    26012608                        cv( old )
    2602                 } );
     2609                };
    26032610        }
    26042611
    26052612        virtual void visit( TypeofType * old ) override final {
    2606                 visitType( old, new ast::TypeofType{
     2613                this->node = new ast::TypeofType{
    26072614                        GET_ACCEPT_1( expr, Expr ),
    26082615                        (ast::TypeofType::Kind)old->is_basetypeof,
    26092616                        cv( old )
    2610                 } );
     2617                };
    26112618        }
    26122619
     
    26162623
    26172624        virtual void visit( VarArgsType * old ) override final {
    2618                 visitType( old, new ast::VarArgsType{ cv( old ) } );
     2625                this->node = new ast::VarArgsType{ cv( old ) };
    26192626        }
    26202627
    26212628        virtual void visit( ZeroType * old ) override final {
    2622                 visitType( old, new ast::ZeroType{ cv( old ) } );
     2629                this->node = new ast::ZeroType{ cv( old ) };
    26232630        }
    26242631
    26252632        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{} );
     2633                this->node = new ast::OneType{ cv( old ) };
     2634        }
     2635
     2636        virtual void visit( GlobalScopeType * ) override final {
     2637                this->node = new ast::GlobalScopeType{};
    26312638        }
    26322639
Note: See TracChangeset for help on using the changeset viewer.