Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r4073b16 rdd6d7c6  
    12871287
    12881288        const ast::Designation * visit( const ast::Designation * node ) override final {
    1289                 (void)node;
     1289                auto designation = new Designation( get<Expression>().acceptL( node->designators ) );
     1290                designation->location = node->location;
     1291                this->node = designation;
    12901292                return nullptr;
    12911293        }
    12921294
    12931295        const ast::Init * visit( const ast::SingleInit * node ) override final {
    1294                 (void)node;
     1296                auto init = new SingleInit(
     1297                        get<Expression>().accept1( node->value ),
     1298                        ast::MaybeConstruct == node->maybeConstructed
     1299                );
     1300                init->location = node->location;
     1301                this->node = init;
    12951302                return nullptr;
    12961303        }
    12971304
    12981305        const ast::Init * visit( const ast::ListInit * node ) override final {
    1299                 (void)node;
     1306                auto init = new ListInit(
     1307                        get<Initializer>().acceptL( node->initializers ),
     1308                        get<Designation>().acceptL( node->designations ),
     1309                        ast::MaybeConstruct == node->maybeConstructed
     1310                );
     1311                init->location = node->location;
     1312                this->node = init;
    13001313                return nullptr;
    13011314        }
    13021315
    13031316        const ast::Init * visit( const ast::ConstructorInit * node ) override final {
    1304                 (void)node;
     1317                auto init = new ConstructorInit(
     1318                        get<Statement>().accept1( node->ctor ),
     1319                        get<Statement>().accept1( node->dtor ),
     1320                        get<Initializer>().accept1( node->init )
     1321                );
     1322                init->location = node->location;
     1323                this->node = init;
    13051324                return nullptr;
    13061325        }
    13071326
    13081327        const ast::Attribute * visit( const ast::Attribute * node ) override final {
    1309                 (void)node;
     1328                auto attr = new Attribute(
     1329                        node->name,
     1330                        get<Expression>().acceptL(node->parameters)
     1331                );
     1332                this->node = attr;
    13101333                return nullptr;
    13111334        }
    13121335
    13131336        const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final {
    1314                 (void)node;
     1337                // Handled by convertTypeSubstitution helper instead.
     1338                // TypeSubstitution is not a node in the old model, so the conversion result wouldn't fit in this->node.
     1339                assert( 0 );
    13151340                return nullptr;
    13161341        }
     
    26172642        }
    26182643
    2619         virtual void visit( Designation * ) override final {
    2620 
    2621         }
    2622 
    2623         virtual void visit( SingleInit * ) override final {
    2624 
    2625         }
    2626 
    2627         virtual void visit( ListInit * ) override final {
    2628 
    2629         }
    2630 
    2631         virtual void visit( ConstructorInit * ) override final {
    2632 
     2644        virtual void visit( Designation * old ) override final {
     2645                this->node = new ast::Designation(
     2646                        old->location,
     2647                        GET_ACCEPT_V(designators, Expr)
     2648                );
     2649        }
     2650
     2651        virtual void visit( SingleInit * old ) override final {
     2652                this->node = new ast::SingleInit(
     2653                        old->location,
     2654                        GET_ACCEPT_1(value, Expr),
     2655                        (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct
     2656                );
     2657        }
     2658
     2659        virtual void visit( ListInit * old ) override final {
     2660                this->node = new ast::ListInit(
     2661                        old->location,
     2662                        GET_ACCEPT_V(initializers, Init),
     2663                        GET_ACCEPT_V(designations, Designation),
     2664                        (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct
     2665                );
     2666        }
     2667
     2668        virtual void visit( ConstructorInit * old ) override final {
     2669                this->node = new ast::ConstructorInit(
     2670                        old->location,
     2671                        GET_ACCEPT_1(ctor, Stmt),
     2672                        GET_ACCEPT_1(dtor, Stmt),
     2673                        GET_ACCEPT_1(init, Init)
     2674                );
    26332675        }
    26342676
    26352677        virtual void visit( Constant * ) override final {
    2636 
    2637         }
    2638 
    2639         virtual void visit( Attribute * ) override final {
    2640 
     2678                // Handled in visit( ConstantEpxr * ).
     2679                // In the new tree, Constant fields are inlined into containing ConstantExpression.
     2680                assert( 0 );
     2681        }
     2682
     2683        virtual void visit( Attribute * old ) override final {
     2684                this->node = new ast::Attribute(
     2685                        old->name,
     2686                        GET_ACCEPT_V( parameters, Expr )
     2687                );
    26412688        }
    26422689
    26432690        virtual void visit( AttrExpr * ) override final {
    2644 
    2645                 assert( 0 );
     2691                assertf( false, "AttrExpr deprecated in new AST." );
    26462692        }
    26472693};
Note: See TracChangeset for help on using the changeset viewer.