Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rdd6d7c6 r746ae82  
    265265                stmt->location = node->location;
    266266                stmt->labels = makeLabelL( stmt, node->labels );
    267                 cache.emplace( node, stmt );
    268267                this->node = stmt;
    269268                return nullptr;
     
    271270
    272271        const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final {
    273                 if ( inCache( node ) ) return nullptr;
    274272                auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) );
    275273                stmtPostamble( stmt, node );
     
    278276
    279277        const ast::Stmt * visit( const ast::ExprStmt * node ) override final {
    280                 if ( inCache( node ) ) return nullptr;
    281278                auto stmt = new ExprStmt( get<Expression>().accept1( node->expr ) );
    282279                return stmtPostamble( stmt, node );
     
    284281
    285282        const ast::Stmt * visit( const ast::AsmStmt * node ) override final {
    286                 if ( inCache( node ) ) return nullptr;
    287283                auto stmt = new AsmStmt(
    288284                        node->isVolatile,
     
    297293
    298294        const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final {
    299                 if ( inCache( node ) ) return nullptr;
    300295                auto stmt = new DirectiveStmt( node->directive );
    301296                return stmtPostamble( stmt, node );
     
    303298
    304299        const ast::Stmt * visit( const ast::IfStmt * node ) override final {
    305                 if ( inCache( node ) ) return nullptr;
    306300                auto stmt = new IfStmt(
    307301                        get<Expression>().accept1( node->cond ),
     
    314308
    315309        const ast::Stmt * visit( const ast::SwitchStmt * node ) override final {
    316                 if ( inCache( node ) ) return nullptr;
    317310                auto stmt = new SwitchStmt(
    318311                        get<Expression>().accept1( node->cond ),
     
    323316
    324317        const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
    325                 if ( inCache( node ) ) return nullptr;
    326318                auto stmt = new CaseStmt(
    327319                        get<Expression>().accept1( node->cond ),
     
    333325
    334326        const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
    335                 if ( inCache( node ) ) return nullptr;
    336327                auto inits = get<Statement>().acceptL( node->inits );
    337328                auto stmt = new WhileStmt(
     
    345336
    346337        const ast::Stmt * visit( const ast::ForStmt * node ) override final {
    347                 if ( inCache( node ) ) return nullptr;
    348338                auto stmt = new ForStmt(
    349339                        get<Statement>().acceptL( node->inits ),
     
    356346
    357347        const ast::Stmt * visit( const ast::BranchStmt * node ) override final {
    358                 if ( inCache( node ) ) return nullptr;
    359348                BranchStmt * stmt;
    360349                if (node->computedTarget) {
     
    386375
    387376        const ast::Stmt * visit( const ast::ReturnStmt * node ) override final {
    388                 if ( inCache( node ) ) return nullptr;
    389377                auto stmt = new ReturnStmt( get<Expression>().accept1( node->expr ) );
    390378                return stmtPostamble( stmt, node );
     
    392380
    393381        const ast::Stmt * visit( const ast::ThrowStmt * node ) override final {
    394                 if ( inCache( node ) ) return nullptr;
    395382                ThrowStmt::Kind kind;
    396383                switch (node->kind) {
     
    413400
    414401        const ast::Stmt * visit( const ast::TryStmt * node ) override final {
    415                 if ( inCache( node ) ) return nullptr;
    416402                auto handlers = get<CatchStmt>().acceptL( node->handlers );
    417403                auto stmt = new TryStmt(
     
    424410
    425411        const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
    426                 if ( inCache( node ) ) return nullptr;
    427412                CatchStmt::Kind kind;
    428413                switch (node->kind) {
     
    446431
    447432        const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
    448                 if ( inCache( node ) ) return nullptr;
    449433                auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) );
    450434                return stmtPostamble( stmt, node );
     
    452436
    453437        const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
    454                 if ( inCache( node ) ) return nullptr;
    455438                auto stmt = new WaitForStmt;
    456439                stmt->clauses.reserve( node->clauses.size() );
     
    477460
    478461        const ast::Stmt * visit( const ast::WithStmt * node ) override final {
    479                 if ( inCache( node ) ) return nullptr;
    480462                auto stmt = new WithStmt(
    481463                        get<Expression>().acceptL( node->exprs ),
     
    486468
    487469        const ast::NullStmt * visit( const ast::NullStmt * node ) override final {
    488                 if ( inCache( node ) ) return nullptr;
    489470                auto stmt = new NullStmt();
    490471                stmtPostamble( stmt, node );
     
    493474
    494475        const ast::Stmt * visit( const ast::DeclStmt * node ) override final {
    495                 if ( inCache( node ) ) return nullptr;
    496476                auto stmt = new DeclStmt( get<Declaration>().accept1( node->decl ) );
    497477                return stmtPostamble( stmt, node );
     
    499479
    500480        const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final {
    501                 if ( inCache( node ) ) return nullptr;
    502                 auto stmt = new ImplicitCtorDtorStmt{
    503                         get<Statement>().accept1( node->callStmt )
    504                 };
    505                 return stmtPostamble( stmt, node );
     481                (void)node;
     482                return nullptr;
    506483        }
    507484
     
    548525        }
    549526
    550         Expression * visitBaseExpr_skipResultType(const ast::Expr * src, Expression * tgt) {
    551 
    552                 tgt->location  = src->location;
    553                 tgt->env       = convertTypeSubstitution(src->env);
     527        Expression * visitBaseExpr(const ast::Expr * src, Expression * tgt) {
     528
     529                tgt->location = src->location;
     530
     531                tgt->result = get<Type>().accept1(src->result);
     532                tgt->env    = convertTypeSubstitution(src->env);
     533
    554534                tgt->extension = src->extension;
    555 
    556535                convertInferUnion(tgt->inferParams, tgt->resnSlots, src->inferred);
     536
    557537                return tgt;
    558         }
    559 
    560         Expression * visitBaseExpr(const ast::Expr * src, Expression * tgt) {
    561 
    562                 tgt->result = get<Type>().accept1(src->result);
    563                 return visitBaseExpr_skipResultType(src, tgt);
    564538        }
    565539
     
    597571
    598572        const ast::Expr * visit( const ast::AddressExpr * node ) override final {
    599                 auto expr = visitBaseExpr( node,
    600                         new AddressExpr(
    601                                 get<Expression>().accept1(node->arg)
    602                         )
    603                 );
    604                 this->node = expr;
     573                (void)node;
    605574                return nullptr;
    606575        }
    607576
    608577        const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final {
    609                 auto expr = visitBaseExpr( node,
    610                         new LabelAddressExpr(
    611                                 makeLabel(nullptr, node->arg)
    612                         )
    613                 );
    614                 this->node = expr;
     578                (void)node;
    615579                return nullptr;
    616580        }
    617581
    618582        const ast::Expr * visit( const ast::CastExpr * node ) override final {
    619                 auto expr = visitBaseExpr( node,
    620                         new CastExpr(
    621                                 get<Expression>().accept1(node->arg),
    622                                 (node->isGenerated == ast::GeneratedCast)
    623                         )
    624                 );
    625                 this->node = expr;
     583                (void)node;
    626584                return nullptr;
    627585        }
    628586
    629587        const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
    630                 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS;
    631                 switch (node->target) {
    632                         case ast::KeywordCastExpr::Coroutine:
    633                                 castTarget = KeywordCastExpr::Coroutine;
    634                                 break;
    635                         case ast::KeywordCastExpr::Thread:
    636                                 castTarget = KeywordCastExpr::Thread;
    637                                 break;
    638                         case ast::KeywordCastExpr::Monitor:
    639                                 castTarget = KeywordCastExpr::Monitor;
    640                                 break;
    641                         default:
    642                                 break;
    643                 }
    644                 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS );
    645                 auto expr = visitBaseExpr( node,
    646                         new KeywordCastExpr(
    647                                 get<Expression>().accept1(node->arg),
    648                                 castTarget
    649                         )
    650                 );
    651                 this->node = expr;
     588                (void)node;
    652589                return nullptr;
    653590        }
    654591
    655592        const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final {
    656                 auto expr = visitBaseExpr_skipResultType( node,
    657                         new VirtualCastExpr(
    658                                 get<Expression>().accept1(node->arg),
    659                                 get<Type>().accept1(node->result)
    660                         )
    661                 );
    662                 this->node = expr;
     593                (void)node;
    663594                return nullptr;
    664595        }
    665596
    666597        const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final {
    667                 auto expr = visitBaseExpr( node,
    668                         new UntypedMemberExpr(
    669                                 get<Expression>().accept1(node->member),
    670                                 get<Expression>().accept1(node->aggregate)
    671                         )
    672                 );
    673                 this->node = expr;
     598                (void)node;
    674599                return nullptr;
    675600        }
    676601
    677602        const ast::Expr * visit( const ast::MemberExpr * node ) override final {
    678                 auto expr = visitBaseExpr( node,
    679                         new MemberExpr(
    680                                 inCache(node->member) ?
    681                                         dynamic_cast<DeclarationWithType *>(this->node) :
    682                                         get<DeclarationWithType>().accept1(node->member),
    683                                 get<Expression>().accept1(node->aggregate)
    684                         )
    685                 );
    686                 this->node = expr;
     603                (void)node;
    687604                return nullptr;
    688605        }
    689606
    690607        const ast::Expr * visit( const ast::VariableExpr * node ) override final {
    691                 auto expr = visitBaseExpr( node,
    692                         new VariableExpr(
    693                                 inCache(node->var) ?
    694                                         dynamic_cast<DeclarationWithType *>(this->node) :
    695                                         get<DeclarationWithType>().accept1(node->var)
    696                         )
    697                 );
    698                 this->node = expr;
    699                 return nullptr;
    700         }
    701 
    702         bool isIntlikeConstantType(const ast::Type *t) {
    703                 if ( const ast::BasicType * basicType = dynamic_cast< const ast::BasicType * >( t ) ) {
    704                         if ( basicType->isInteger() ) {
    705                                 return true;
    706                         }
    707                 } else if ( dynamic_cast< const ast::OneType * >( t ) ) {
    708                         return true;
    709                 } else if ( dynamic_cast< const ast::ZeroType * >( t ) ) {
    710                         return true;
    711                 } else if ( dynamic_cast< const ast::PointerType * >( t ) ) {
    712                         // null pointer constants, with zero int-values
    713                         return true;
    714                 }
    715                 return false;
    716         }
    717 
    718         bool isFloatlikeConstantType(const ast::Type *t) {
    719                 if ( const ast::BasicType * bty = dynamic_cast< const ast::BasicType * >( t ) ) {
    720                         if ( ! bty->isInteger() ) {
    721                                 return true;
    722                         }
    723                 }
    724                 return false;
    725         }
    726 
    727         bool isStringlikeConstantType(const ast::Type *t) {
    728                 if ( const ast::ArrayType * aty = dynamic_cast< const ast::ArrayType * >( t ) ) {
    729                         if ( const ast::BasicType * bty = aty->base.as<ast::BasicType>() ) {
    730                            if ( bty->kind == ast::BasicType::Kind::Char ) {
    731                                    return true;
    732                            }
    733                         }
    734                 }
    735                 return false;
     608                (void)node;
     609                return nullptr;
    736610        }
    737611
    738612        const ast::Expr * visit( const ast::ConstantExpr * node ) override final {
    739                 ConstantExpr *rslt = nullptr;
    740                 if (isIntlikeConstantType(node->result)) {
    741                         rslt = new ConstantExpr(Constant(
    742                                 get<Type>().accept1(node->result),
    743                                 node->rep,
    744                                 (unsigned long long) node->intValue()
    745                         ));
    746                 } else if (isFloatlikeConstantType(node->result)) {
    747                         rslt = new ConstantExpr(Constant(
    748                                 get<Type>().accept1(node->result),
    749                                 node->rep,
    750                                 (double) node->floatValue()
    751                         ));
    752                 } else if (isStringlikeConstantType(node->result)) {
    753                         rslt = new ConstantExpr(Constant::from_string(
    754                                 node->rep
    755                         ));
    756                 }
    757                 assert(rslt);
    758                 auto expr = visitBaseExpr( node, rslt );
    759                 this->node = expr;
     613                (void)node;
    760614                return nullptr;
    761615        }
    762616
    763617        const ast::Expr * visit( const ast::SizeofExpr * node ) override final {
    764                 assert (node->expr || node->type);
    765                 assert (! (node->expr && node->type));
    766                 SizeofExpr *rslt;
    767                 if (node->expr) {
    768                         rslt = new SizeofExpr(
    769                                 get<Expression>().accept1(node->expr)
    770                         );
    771                         assert (!rslt->isType);
    772                 }
    773                 if (node->type) {
    774                         rslt = new SizeofExpr(
    775                                 get<Type>().accept1(node->type)
    776                         );
    777                         assert (rslt->isType);
    778                 }
    779                 auto expr = visitBaseExpr( node, rslt );
    780                 this->node = expr;
     618                (void)node;
    781619                return nullptr;
    782620        }
    783621
    784622        const ast::Expr * visit( const ast::AlignofExpr * node ) override final {
    785                 assert (node->expr || node->type);
    786                 assert (! (node->expr && node->type));
    787                 AlignofExpr *rslt;
    788                 if (node->expr) {
    789                         rslt = new AlignofExpr(
    790                                 get<Expression>().accept1(node->expr)
    791                         );
    792                         assert (!rslt->isType);
    793                 }
    794                 if (node->type) {
    795                         rslt = new AlignofExpr(
    796                                 get<Type>().accept1(node->type)
    797                         );
    798                         assert (rslt->isType);
    799                 }
    800                 auto expr = visitBaseExpr( node, rslt );
    801                 this->node = expr;
     623                (void)node;
    802624                return nullptr;
    803625        }
    804626
    805627        const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final {
    806                 auto expr = visitBaseExpr( node,
    807                         new UntypedOffsetofExpr(
    808                                 get<Type>().accept1(node->type),
    809                                 node->member
    810                         )
    811                 );
    812                 this->node = expr;
     628                (void)node;
    813629                return nullptr;
    814630        }
    815631
    816632        const ast::Expr * visit( const ast::OffsetofExpr * node ) override final {
    817                 auto expr = visitBaseExpr( node,
    818                         new OffsetofExpr(
    819                                 get<Type>().accept1(node->type),
    820                                 inCache(node->member) ?
    821                                         dynamic_cast<DeclarationWithType *>(this->node) :
    822                                         get<DeclarationWithType>().accept1(node->member)
    823                         )
    824                 );
    825                 this->node = expr;
     633                (void)node;
    826634                return nullptr;
    827635        }
    828636
    829637        const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final {
    830                 auto expr = visitBaseExpr( node,
    831                         new OffsetPackExpr(
    832                                 get<StructInstType>().accept1(node->type)
    833                         )
    834                 );
    835                 this->node = expr;
     638                (void)node;
    836639                return nullptr;
    837640        }
    838641
    839642        const ast::Expr * visit( const ast::LogicalExpr * node ) override final {
    840                 assert (node->isAnd == ast::LogicalFlag::AndExpr ||
    841                                 node->isAnd == ast::LogicalFlag::OrExpr );
    842                 auto expr = visitBaseExpr( node,
    843                         new LogicalExpr(
    844                                 get<Expression>().accept1(node->arg1),
    845                                 get<Expression>().accept1(node->arg2),
    846                                 (node->isAnd == ast::LogicalFlag::AndExpr)
    847                         )
    848                 );
    849                 this->node = expr;
     643                (void)node;
    850644                return nullptr;
    851645        }
    852646
    853647        const ast::Expr * visit( const ast::ConditionalExpr * node ) override final {
    854                 auto expr = visitBaseExpr( node,
    855                         new ConditionalExpr(
    856                                 get<Expression>().accept1(node->arg1),
    857                                 get<Expression>().accept1(node->arg2),
    858                                 get<Expression>().accept1(node->arg3)
    859                         )
    860                 );
    861                 this->node = expr;
     648                (void)node;
    862649                return nullptr;
    863650        }
    864651
    865652        const ast::Expr * visit( const ast::CommaExpr * node ) override final {
    866                 auto expr = visitBaseExpr( node,
    867                         new CommaExpr(
    868                                 get<Expression>().accept1(node->arg1),
    869                                 get<Expression>().accept1(node->arg2)
    870                         )
    871                 );
    872                 this->node = expr;
     653                (void)node;
    873654                return nullptr;
    874655        }
    875656
    876657        const ast::Expr * visit( const ast::TypeExpr * node ) override final {
    877                 auto expr = visitBaseExpr( node,
    878                         new TypeExpr(
    879                                 get<Type>().accept1(node->type)
    880                         )
    881                 );
    882                 this->node = expr;
     658                (void)node;
    883659                return nullptr;
    884660        }
    885661
    886662        const ast::Expr * visit( const ast::AsmExpr * node ) override final {
    887                 auto expr = visitBaseExpr( node,
    888                         new AsmExpr(
    889                                 get<Expression>().accept1(node->inout),
    890                                 get<Expression>().accept1(node->constraint),
    891                                 get<Expression>().accept1(node->operand)
    892                         )
    893                 );
    894                 this->node = expr;
     663                (void)node;
    895664                return nullptr;
    896665        }
    897666
    898667        const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final {
    899                 auto rslt = new ImplicitCopyCtorExpr(
    900                         get<ApplicationExpr>().accept1(node->callExpr)
    901                 );
    902 
    903                 rslt->tempDecls = get<ObjectDecl>().acceptL(node->tempDecls);
    904                 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls);
    905                 rslt->dtors = get<Expression>().acceptL(node->dtors);
    906 
    907                 auto expr = visitBaseExpr( node, rslt );
    908                 this->node = expr;
     668                (void)node;
    909669                return nullptr;
    910670        }
    911671
    912672        const ast::Expr * visit( const ast::ConstructorExpr * node ) override final {
    913                 auto expr = visitBaseExpr( node,
    914                         new ConstructorExpr(
    915                                 get<Expression>().accept1(node->callExpr)
    916                         )
    917                 );
    918                 this->node = expr;
     673                (void)node;
    919674                return nullptr;
    920675        }
    921676
    922677        const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final {
    923                 auto expr = visitBaseExpr_skipResultType( node,
    924                         new CompoundLiteralExpr(
    925                                 get<Type>().accept1(node->result),
    926                                 get<Initializer>().accept1(node->init)
    927                         )
    928                 );
    929                 this->node = expr;
     678                (void)node;
    930679                return nullptr;
    931680        }
    932681
    933682        const ast::Expr * visit( const ast::RangeExpr * node ) override final {
    934                 auto expr = visitBaseExpr( node,
    935                         new RangeExpr(
    936                                 get<Expression>().accept1(node->low),
    937                                 get<Expression>().accept1(node->high)
    938                         )
    939                 );
    940                 this->node = expr;
     683                (void)node;
    941684                return nullptr;
    942685        }
    943686
    944687        const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final {
    945                 auto expr = visitBaseExpr( node,
    946                         new UntypedTupleExpr(
    947                                 get<Expression>().acceptL(node->exprs)
    948                         )
    949                 );
    950                 this->node = expr;
     688                (void)node;
    951689                return nullptr;
    952690        }
    953691
    954692        const ast::Expr * visit( const ast::TupleExpr * node ) override final {
    955                 auto expr = visitBaseExpr( node,
    956                         new UntypedTupleExpr(
    957                                 get<Expression>().acceptL(node->exprs)
    958                         )
    959                 );
    960                 this->node = expr;
     693                (void)node;
    961694                return nullptr;
    962695        }
    963696
    964697        const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final {
    965                 auto expr = visitBaseExpr( node,
    966                         new TupleIndexExpr(
    967                                 get<Expression>().accept1(node->tuple),
    968                                 node->index
    969                         )
    970                 );
    971                 this->node = expr;
     698                (void)node;
    972699                return nullptr;
    973700        }
    974701
    975702        const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final {
    976                 auto expr = visitBaseExpr( node,
    977                         new TupleAssignExpr(
    978                                 get<StmtExpr>().accept1(node->stmtExpr)
    979                         )
    980                 );
    981                 this->node = expr;
     703                (void)node;
    982704                return nullptr;
    983705        }
    984706
    985707        const ast::Expr * visit( const ast::StmtExpr * node ) override final {
    986                 auto rslt = new StmtExpr(
    987                         get<CompoundStmt>().accept1(node->stmts)
    988                 );
    989 
    990                 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls);
    991                 rslt->dtors       = get<Expression>().acceptL(node->dtors);
    992 
    993                 auto expr = visitBaseExpr( node, rslt );
    994                 this->node = expr;
     708                (void)node;
    995709                return nullptr;
    996710        }
    997711
    998712        const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
    999                 auto rslt = new UniqueExpr(
    1000                         get<Expression>().accept1(node->expr)
    1001                 );
    1002 
    1003                 rslt->object = get<ObjectDecl>  ().accept1(node->object);
    1004                 rslt->var    = get<VariableExpr>().accept1(node->var);
    1005 
    1006                 auto expr = visitBaseExpr( node, rslt );
    1007                 this->node = expr;
     713                (void)node;
    1008714                return nullptr;
    1009715        }
    1010716
    1011717        const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final {
    1012                 std::list<InitAlternative> initAlts;
    1013                 for (auto ia : node->initAlts) {
    1014                         initAlts.push_back(InitAlternative(
    1015                                 get<Type>       ().accept1(ia.type),
    1016                                 get<Designation>().accept1(ia.designation)
    1017                         ));
    1018                 }
    1019                 auto expr = visitBaseExpr( node,
    1020                         new UntypedInitExpr(
    1021                                 get<Expression>().accept1(node->expr),
    1022                                 initAlts
    1023                         )
    1024                 );
    1025                 this->node = expr;
     718                (void)node;
    1026719                return nullptr;
    1027720        }
    1028721
    1029722        const ast::Expr * visit( const ast::InitExpr * node ) override final {
    1030                 auto expr = visitBaseExpr( node,
    1031                         new InitExpr(
    1032                                 get<Expression>().accept1(node->expr),
    1033                                 get<Designation>().accept1(node->designation)
    1034                         )
    1035                 );
    1036                 this->node = expr;
     723                (void)node;
    1037724                return nullptr;
    1038725        }
    1039726
    1040727        const ast::Expr * visit( const ast::DeletedExpr * node ) override final {
    1041                 auto expr = visitBaseExpr( node,
    1042                         new DeletedExpr(
    1043                                 get<Expression>().accept1(node->expr),
    1044                                 inCache(node->deleteStmt) ?
    1045                                         this->node :
    1046                                         get<BaseSyntaxNode>().accept1(node->deleteStmt)
    1047                         )
    1048                 );
    1049                 this->node = expr;
     728                (void)node;
    1050729                return nullptr;
    1051730        }
    1052731
    1053732        const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final {
    1054                 auto expr = visitBaseExpr( node,
    1055                         new DefaultArgExpr(
    1056                                 get<Expression>().accept1(node->expr)
    1057                         )
    1058                 );
    1059                 this->node = expr;
     733                (void)node;
    1060734                return nullptr;
    1061735        }
    1062736
    1063737        const ast::Expr * visit( const ast::GenericExpr * node ) override final {
    1064                 std::list<GenericExpr::Association> associations;
    1065                 for (auto association : node->associations) {
    1066                         associations.push_back(GenericExpr::Association(
    1067                                 get<Type>      ().accept1(association.type),
    1068                                 get<Expression>().accept1(association.expr)
    1069                         ));
    1070                 }
    1071                 auto expr = visitBaseExpr( node,
    1072                         new GenericExpr(
    1073                                 get<Expression>().accept1(node->control),
    1074                                 associations
    1075                         )
    1076                 );
    1077                 this->node = expr;
     738                (void)node;
    1078739                return nullptr;
    1079740        }
     
    1287948
    1288949        const ast::Designation * visit( const ast::Designation * node ) override final {
    1289                 auto designation = new Designation( get<Expression>().acceptL( node->designators ) );
    1290                 designation->location = node->location;
    1291                 this->node = designation;
     950                (void)node;
    1292951                return nullptr;
    1293952        }
    1294953
    1295954        const ast::Init * visit( const ast::SingleInit * node ) override final {
    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;
     955                (void)node;
    1302956                return nullptr;
    1303957        }
    1304958
    1305959        const ast::Init * visit( const ast::ListInit * node ) override final {
    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;
     960                (void)node;
    1313961                return nullptr;
    1314962        }
    1315963
    1316964        const ast::Init * visit( const ast::ConstructorInit * node ) override final {
    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;
     965                (void)node;
    1324966                return nullptr;
    1325967        }
    1326968
    1327969        const ast::Attribute * visit( const ast::Attribute * node ) override final {
    1328                 auto attr = new Attribute(
    1329                         node->name,
    1330                         get<Expression>().acceptL(node->parameters)
    1331                 );
    1332                 this->node = attr;
     970                (void)node;
    1333971                return nullptr;
    1334972        }
    1335973
    1336974        const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final {
    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 );
     975                (void)node;
    1340976                return nullptr;
    1341977        }
     
    14481084        virtual void visit( FunctionDecl * old ) override final {
    14491085                if ( inCache( old ) ) return;
    1450                 auto decl = new ast::FunctionDecl{
    1451                         old->location,
    1452                         old->name,
    1453                         GET_ACCEPT_1(type, FunctionType),
    1454                         GET_ACCEPT_1(statements, CompoundStmt),
    1455                         { old->storageClasses.val },
    1456                         { old->linkage.val },
    1457                         GET_ACCEPT_V(attributes, Attribute),
    1458                         { old->get_funcSpec().val }
    1459                 };
    1460                 decl->scopeLevel = old->scopeLevel;
    1461                 decl->mangleName = old->mangleName;
    1462                 decl->isDeleted  = old->isDeleted;
    1463                 decl->uniqueId   = old->uniqueId;
    1464                 decl->extension  = old->extension;
     1086                // TODO
     1087                auto decl = (ast::FunctionDecl *)nullptr;
    14651088                cache.emplace( old, decl );
    1466 
    1467                 this->node = decl;
    14681089        }
    14691090
     
    15501171
    15511172        virtual void visit( TypeDecl * old ) override final {
    1552                 if ( inCache( old ) ) return;   
    1553                 auto decl = new ast::TypeDecl{
    1554                         old->location,
    1555                         old->name,
    1556                         { old->storageClasses.val },
    1557                         GET_ACCEPT_1(base, Type),
    1558                         (ast::TypeVar::Kind)(unsigned)old->kind,
    1559                         old->sized,
    1560                         GET_ACCEPT_1(init, Type)
    1561                 };
    1562                 decl->assertions = GET_ACCEPT_V(assertions, DeclWithType);
    1563                 decl->params     = GET_ACCEPT_V(parameters, TypeDecl);
    1564                 decl->extension  = old->extension;
    1565                 decl->uniqueId   = old->uniqueId;
     1173                if ( inCache( old ) ) return;
     1174                // TODO
     1175                auto decl = (ast::TypeDecl *)nullptr;
    15661176                cache.emplace( old, decl );
    1567 
    1568                 this->node = decl;
    15691177        }
    15701178
     
    15861194        }
    15871195
    1588         virtual void visit( AsmDecl * old ) override final {
    1589                 auto decl = new ast::AsmDecl{
    1590                         old->location,
    1591                         GET_ACCEPT_1(stmt, AsmStmt)
    1592                 };
    1593                 decl->extension  = old->extension;
    1594                 decl->uniqueId   = old->uniqueId;
    1595                 decl->storage    = { old->storageClasses.val };
    1596 
    1597                 this->node = decl;
    1598         }
    1599 
    1600         virtual void visit( StaticAssertDecl * old ) override final {
    1601                 auto decl = new ast::StaticAssertDecl{
    1602                         old->location,
    1603                         GET_ACCEPT_1(condition, Expr),
    1604                         GET_ACCEPT_1(message, ConstantExpr)
    1605                 };
    1606                 decl->extension  = old->extension;
    1607                 decl->uniqueId   = old->uniqueId;
    1608                 decl->storage    = { old->storageClasses.val };
    1609 
    1610                 this->node = decl;
     1196        virtual void visit( AsmDecl * ) override final {
     1197
     1198        }
     1199
     1200        virtual void visit( StaticAssertDecl * ) override final {
     1201
    16111202        }
    16121203
    16131204        virtual void visit( CompoundStmt * old ) override final {
    1614                 if ( inCache( old ) ) return;
    16151205                auto stmt = new ast::CompoundStmt(
    16161206                        old->location,
     
    16201210
    16211211                this->node = stmt;
    1622                 cache.emplace( old, this->node );
    16231212        }
    16241213
    16251214        virtual void visit( ExprStmt * old ) override final {
    1626                 if ( inCache( old ) ) return;
    16271215                this->node = new ast::ExprStmt(
    16281216                        old->location,
     
    16301218                        GET_LABELS_V(old->labels)
    16311219                );
    1632                 cache.emplace( old, this->node );
    16331220        }
    16341221
    16351222        virtual void visit( AsmStmt * old ) override final {
    1636                 if ( inCache( old ) ) return;
    16371223                this->node = new ast::AsmStmt(
    16381224                        old->location,
     
    16451231                        GET_LABELS_V(old->labels)
    16461232                );
    1647                 cache.emplace( old, this->node );
    16481233        }
    16491234
    16501235        virtual void visit( DirectiveStmt * old ) override final {
    1651                 if ( inCache( old ) ) return;
    16521236                this->node = new ast::DirectiveStmt(
    16531237                        old->location,
     
    16551239                        GET_LABELS_V(old->labels)
    16561240                );
    1657                 cache.emplace( old, this->node );
    16581241        }
    16591242
    16601243        virtual void visit( IfStmt * old ) override final {
    1661                 if ( inCache( old ) ) return;
    16621244                this->node = new ast::IfStmt(
    16631245                        old->location,
     
    16681250                        GET_LABELS_V(old->labels)
    16691251                );
    1670                 cache.emplace( old, this->node );
    16711252        }
    16721253
    16731254        virtual void visit( SwitchStmt * old ) override final {
    1674                 if ( inCache( old ) ) return;
    16751255                this->node = new ast::SwitchStmt(
    16761256                        old->location,
     
    16791259                        GET_LABELS_V(old->labels)
    16801260                );
    1681                 cache.emplace( old, this->node );
    16821261        }
    16831262
    16841263        virtual void visit( CaseStmt * old ) override final {
    1685                 if ( inCache( old ) ) return;
    16861264                this->node = new ast::CaseStmt(
    16871265                        old->location,
     
    16901268                        GET_LABELS_V(old->labels)
    16911269                );
    1692                 cache.emplace( old, this->node );
    16931270        }
    16941271
    16951272        virtual void visit( WhileStmt * old ) override final {
    1696                 if ( inCache( old ) ) return;
    16971273                this->node = new ast::WhileStmt(
    16981274                        old->location,
     
    17031279                        GET_LABELS_V(old->labels)
    17041280                );
    1705                 cache.emplace( old, this->node );
    17061281        }
    17071282
    17081283        virtual void visit( ForStmt * old ) override final {
    1709                 if ( inCache( old ) ) return;
    17101284                this->node = new ast::ForStmt(
    17111285                        old->location,
     
    17161290                        GET_LABELS_V(old->labels)
    17171291                );
    1718                 cache.emplace( old, this->node );
    17191292        }
    17201293
    17211294        virtual void visit( BranchStmt * old ) override final {
    1722                 if ( inCache( old ) ) return;
    17231295                if (old->computedTarget) {
    17241296                        this->node = new ast::BranchStmt(
     
    17541326                        this->node = stmt;
    17551327                }
    1756                 cache.emplace( old, this->node );
    17571328        }
    17581329
    17591330        virtual void visit( ReturnStmt * old ) override final {
    1760                 if ( inCache( old ) ) return;
    17611331                this->node = new ast::ReturnStmt(
    17621332                        old->location,
     
    17641334                        GET_LABELS_V(old->labels)
    17651335                );
    1766                 cache.emplace( old, this->node );
    17671336        }
    17681337
    17691338        virtual void visit( ThrowStmt * old ) override final {
    1770                 if ( inCache( old ) ) return;
    17711339                ast::ThrowStmt::Kind kind;
    17721340                switch (old->kind) {
     
    17881356                        GET_LABELS_V(old->labels)
    17891357                );
    1790                 cache.emplace( old, this->node );
    17911358        }
    17921359
    17931360        virtual void visit( TryStmt * old ) override final {
    1794                 if ( inCache( old ) ) return;
    17951361                this->node = new ast::TryStmt(
    17961362                        old->location,
     
    18001366                        GET_LABELS_V(old->labels)
    18011367                );
    1802                 cache.emplace( old, this->node );
    18031368        }
    18041369
    18051370        virtual void visit( CatchStmt * old ) override final {
    1806                 if ( inCache( old ) ) return;
    18071371                ast::CatchStmt::Kind kind;
    18081372                switch (old->kind) {
     
    18251389                        GET_LABELS_V(old->labels)
    18261390                );
    1827                 cache.emplace( old, this->node );
    18281391        }
    18291392
    18301393        virtual void visit( FinallyStmt * old ) override final {
    1831                 if ( inCache( old ) ) return;
    18321394                this->node = new ast::FinallyStmt(
    18331395                        old->location,
     
    18351397                        GET_LABELS_V(old->labels)
    18361398                );
    1837                 cache.emplace( old, this->node );
    18381399        }
    18391400
    18401401        virtual void visit( WaitForStmt * old ) override final {
    1841                 if ( inCache( old ) ) return;
    18421402                ast::WaitForStmt * stmt = new ast::WaitForStmt(
    18431403                        old->location,
     
    18671427
    18681428                this->node = stmt;
    1869                 cache.emplace( old, this->node );
    18701429        }
    18711430
    18721431        virtual void visit( WithStmt * old ) override final {
    1873                 if ( inCache( old ) ) return;
    18741432                this->node = new ast::WithStmt(
    18751433                        old->location,
     
    18781436                        GET_LABELS_V(old->labels)
    18791437                );
    1880                 cache.emplace( old, this->node );
    18811438        }
    18821439
    18831440        virtual void visit( NullStmt * old ) override final {
    1884                 if ( inCache( old ) ) return;
    18851441                this->node = new ast::NullStmt(
    18861442                        old->location,
    18871443                        GET_LABELS_V(old->labels)
    18881444                );
    1889                 cache.emplace( old, this->node );
    18901445        }
    18911446
    18921447        virtual void visit( DeclStmt * old ) override final {
    1893                 if ( inCache( old ) ) return;
    18941448                this->node = new ast::DeclStmt(
    18951449                        old->location,
     
    18971451                        GET_LABELS_V(old->labels)
    18981452                );
    1899                 cache.emplace( old, this->node );
    19001453        }
    19011454
    19021455        virtual void visit( ImplicitCtorDtorStmt * old ) override final {
    1903                 if ( inCache( old ) ) return;
    19041456                this->node = new ast::ImplicitCtorDtorStmt(
    19051457                        old->location,
     
    19071459                        GET_LABELS_V(old->labels)
    19081460                );
    1909                 cache.emplace( old, this->node );
    19101461        }
    19111462
     
    19521503        }
    19531504
    1954         ast::Expr * visitBaseExpr_SkipResultType(Expression * old, ast::Expr * nw) {
    1955 
     1505        ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) {
     1506
     1507                nw->result = GET_ACCEPT_1(result, Type);
    19561508                nw->env    = convertTypeSubstitution(old->env);
    19571509
     
    19601512
    19611513                return nw;
    1962         }
    1963 
    1964         ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) {
    1965 
    1966                 nw->result = GET_ACCEPT_1(result, Type);
    1967                 return visitBaseExpr_SkipResultType(old, nw);;
    19681514        }
    19691515
     
    20011547                        new ast::CastExpr(
    20021548                                old->location,
    2003                                 GET_ACCEPT_1(arg, Expr),
     1549                                nullptr, // cast's "to" type is expr's result type; converted in visitBaseExpr
    20041550                                old->isGenerated ? ast::GeneratedCast : ast::ExplicitCast
    20051551                        )
     
    20071553        }
    20081554
    2009         virtual void visit( KeywordCastExpr * old) override final {
    2010                 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS;
    2011                 switch (old->target) {
    2012                         case KeywordCastExpr::Coroutine:
    2013                                 castTarget = ast::KeywordCastExpr::Coroutine;
    2014                                 break;
    2015                         case KeywordCastExpr::Thread:
    2016                                 castTarget = ast::KeywordCastExpr::Thread;
    2017                                 break;
    2018                         case KeywordCastExpr::Monitor:
    2019                                 castTarget = ast::KeywordCastExpr::Monitor;
    2020                                 break;
    2021                         default:
    2022                                 break;
    2023                 }
    2024                 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS );
    2025                 this->node = visitBaseExpr( old,
    2026                         new ast::KeywordCastExpr(
    2027                                 old->location,
    2028                                 GET_ACCEPT_1(arg, Expr),
    2029                                 castTarget
    2030                         )
    2031                 );
    2032         }
    2033 
    2034         virtual void visit( VirtualCastExpr * old ) override final {
    2035                 this->node = visitBaseExpr_SkipResultType( old,
    2036                         new ast::VirtualCastExpr(
    2037                                 old->location,
    2038                                 GET_ACCEPT_1(arg, Expr),
    2039                                 GET_ACCEPT_1(result, Type)
    2040                         )
    2041                 );
    2042         }
    2043 
    2044         virtual void visit( AddressExpr * old ) override final {
    2045                 this->node = visitBaseExpr( old,
    2046                         new ast::AddressExpr(
    2047                                 old->location,
    2048                                 GET_ACCEPT_1(arg, Expr)
    2049                         )
    2050                 );
    2051         }
    2052 
    2053         virtual void visit( LabelAddressExpr * old ) override final {
    2054                 this->node = visitBaseExpr( old,
    2055                         new ast::LabelAddressExpr(
    2056                                 old->location,
    2057                                 make_label(&old->arg)
    2058                         )
    2059                 );
    2060         }
    2061 
    2062         virtual void visit( UntypedMemberExpr * old ) override final {
    2063                 this->node = visitBaseExpr( old,
    2064                         new ast::UntypedMemberExpr(
    2065                                 old->location,
    2066                                 GET_ACCEPT_1(member, Expr),
    2067                                 GET_ACCEPT_1(aggregate, Expr)
    2068                         )
    2069                 );
    2070         }
    2071 
    2072         virtual void visit( MemberExpr * old ) override final {
    2073                 this->node = visitBaseExpr( old,
    2074                         new ast::MemberExpr(
    2075                                 old->location,
    2076                                 inCache(old->member) ?
    2077                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2078                                         GET_ACCEPT_1(member, DeclWithType),
    2079                                 GET_ACCEPT_1(aggregate, Expr)
    2080                         )
    2081                 );
    2082         }
    2083 
    2084         virtual void visit( VariableExpr * old ) override final {
    2085                 this->node = visitBaseExpr( old,
    2086                         new ast::VariableExpr(
    2087                                 old->location,
    2088                                 inCache(old->var) ?
    2089                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2090                                         GET_ACCEPT_1(var, DeclWithType)
    2091                         )
    2092                 );
    2093         }
    2094 
    2095         bool isIntlikeConstantType(const Type *t) {
    2096                 if ( const BasicType * basicType = dynamic_cast< const BasicType * >( t ) ) {
    2097                         if ( basicType->isInteger() ) {
    2098                                 return true;
    2099                         }
    2100                 } else if ( dynamic_cast< const OneType * >( t ) ) {
    2101                         return true;
    2102                 } else if ( dynamic_cast< const ZeroType * >( t ) ) {
    2103                         return true;
    2104                 } else if ( dynamic_cast< const PointerType * >( t ) ) {
    2105                         // null pointer constants, with zero int-values
    2106                         return true;
    2107                 }
    2108                 return false;
    2109         }
    2110 
    2111         int isFloatlikeConstantType(const Type *t) {
    2112                 if ( const BasicType * bty = dynamic_cast< const BasicType * >( t ) ) {
    2113                         if ( ! bty->isInteger() ) {
    2114                                 return true;
    2115                         }
    2116                 }
    2117                 return false;
    2118         }
    2119 
    2120         int isStringlikeConstantType(const Type *t) {
    2121                 if ( const ArrayType * aty = dynamic_cast< const ArrayType * >( t ) ) {
    2122                         if ( const BasicType * bty = dynamic_cast< const BasicType * >( aty->base ) ) {
    2123                            if ( bty->kind == BasicType::Kind::Char ) {
    2124                                    return true;
    2125                            }
    2126                         }
    2127                 }
    2128                 return false;
    2129         }
    2130 
    2131         virtual void visit( ConstantExpr * old ) override final {
    2132                 ast::ConstantExpr *rslt = nullptr;
    2133                 if (isIntlikeConstantType(old->result)) {
    2134                         rslt = new ast::ConstantExpr(
    2135                                 old->location,
    2136                                 GET_ACCEPT_1(result, Type),
    2137                                 old->constant.get_value(),
    2138                                 (unsigned long long) old->intValue()
    2139                         );
    2140                 } else if (isFloatlikeConstantType(old->result)) {
    2141                         rslt = new ast::ConstantExpr(
    2142                                 old->location,
    2143                                 GET_ACCEPT_1(result, Type),
    2144                                 old->constant.get_value(),
    2145                                 (double) old->constant.get_dval()
    2146                         );
    2147                 } else if (isStringlikeConstantType(old->result)) {
    2148                         rslt = ast::ConstantExpr::from_string(
    2149                                 old->location,
    2150                                 old->constant.get_value()
    2151                         );
    2152                 }
    2153                 assert(rslt);
    2154                 this->node = visitBaseExpr( old, rslt );
    2155         }
    2156 
    2157         virtual void visit( SizeofExpr * old ) override final {
    2158                 assert (old->expr || old->type);
    2159                 assert (! (old->expr && old->type));
    2160                 ast::SizeofExpr *rslt;
    2161                 if (old->expr) {
    2162                         assert(!old->isType);
    2163                         rslt = new ast::SizeofExpr(
    2164                                 old->location,
    2165                                 GET_ACCEPT_1(expr, Expr)
    2166                         );
    2167                 }
    2168                 if (old->type) {
    2169                         assert(old->isType);
    2170                         rslt = new ast::SizeofExpr(
    2171                                 old->location,
    2172                                 GET_ACCEPT_1(type, Type)
    2173                         );
    2174                 }
    2175                 this->node = visitBaseExpr( old, rslt );
    2176         }
    2177 
    2178         virtual void visit( AlignofExpr * old ) override final {
    2179                 assert (old->expr || old->type);
    2180                 assert (! (old->expr && old->type));
    2181                 ast::AlignofExpr *rslt;
    2182                 if (old->expr) {
    2183                         assert(!old->isType);
    2184                         rslt = new ast::AlignofExpr(
    2185                                 old->location,
    2186                                 GET_ACCEPT_1(expr, Expr)
    2187                         );
    2188                 }
    2189                 if (old->type) {
    2190                         assert(old->isType);
    2191                         rslt = new ast::AlignofExpr(
    2192                                 old->location,
    2193                                 GET_ACCEPT_1(type, Type)
    2194                         );
    2195                 }
    2196                 this->node = visitBaseExpr( old, rslt );
    2197         }
    2198 
    2199         virtual void visit( UntypedOffsetofExpr * old ) override final {
    2200                 this->node = visitBaseExpr( old,
    2201                         new ast::UntypedOffsetofExpr(
    2202                                 old->location,
    2203                                 GET_ACCEPT_1(type, Type),
    2204                                 old->member
    2205                         )
    2206                 );
    2207         }
    2208 
    2209         virtual void visit( OffsetofExpr * old ) override final {
    2210                 this->node = visitBaseExpr( old,
    2211                         new ast::OffsetofExpr(
    2212                                 old->location,
    2213                                 GET_ACCEPT_1(type, Type),
    2214                                 inCache(old->member) ?
    2215                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2216                                         GET_ACCEPT_1(member, DeclWithType)
    2217                         )
    2218                 );
    2219         }
    2220 
    2221         virtual void visit( OffsetPackExpr * old ) override final {
    2222                 this->node = visitBaseExpr( old,
    2223                         new ast::OffsetPackExpr(
    2224                                 old->location,
    2225                                 GET_ACCEPT_1(type, StructInstType)
    2226                         )
    2227                 );
    2228         }
    2229 
    2230         virtual void visit( LogicalExpr * old ) override final {
    2231                 this->node = visitBaseExpr( old,
    2232                         new ast::LogicalExpr(
    2233                                 old->location,
    2234                                 GET_ACCEPT_1(arg1, Expr),
    2235                                 GET_ACCEPT_1(arg2, Expr),
    2236                                 old->get_isAnd() ?
    2237                                         ast::LogicalFlag::AndExpr :
    2238                                         ast::LogicalFlag::OrExpr
    2239                         )
    2240                 );
    2241         }
    2242 
    2243         virtual void visit( ConditionalExpr * old ) override final {
    2244                 this->node = visitBaseExpr( old,
    2245                         new ast::ConditionalExpr(
    2246                                 old->location,
    2247                                 GET_ACCEPT_1(arg1, Expr),
    2248                                 GET_ACCEPT_1(arg2, Expr),
    2249                                 GET_ACCEPT_1(arg3, Expr)
    2250                         )
    2251                 );
    2252         }
    2253 
    2254         virtual void visit( CommaExpr * old ) override final {
    2255                 this->node = visitBaseExpr( old,
    2256                         new ast::CommaExpr(
    2257                                 old->location,
    2258                                 GET_ACCEPT_1(arg1, Expr),
    2259                                 GET_ACCEPT_1(arg2, Expr)
    2260                         )
    2261                 );
    2262         }
    2263 
    2264         virtual void visit( TypeExpr * old ) override final {
    2265                 this->node = visitBaseExpr( old,
    2266                         new ast::TypeExpr(
    2267                                 old->location,
    2268                                 GET_ACCEPT_1(type, Type)
    2269                         )
    2270                 );
    2271         }
    2272 
    2273         virtual void visit( AsmExpr * old ) override final {
    2274                 this->node = visitBaseExpr( old,
    2275                         new ast::AsmExpr(
    2276                                 old->location,
    2277                                 GET_ACCEPT_1(inout, Expr),
    2278                                 GET_ACCEPT_1(constraint, Expr),
    2279                                 GET_ACCEPT_1(operand, Expr)
    2280                         )
    2281                 );
    2282         }
    2283 
    2284         virtual void visit( ImplicitCopyCtorExpr * old ) override final {
    2285                 auto rslt = new ast::ImplicitCopyCtorExpr(
    2286                         old->location,
    2287                         GET_ACCEPT_1(callExpr, ApplicationExpr)
    2288                 );
    2289 
    2290                 rslt->tempDecls = GET_ACCEPT_V(tempDecls, ObjectDecl);
    2291                 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl);
    2292                 rslt->dtors = GET_ACCEPT_V(dtors, Expr);
    2293 
    2294                 this->node = visitBaseExpr( old, rslt );
    2295         }
    2296 
    2297         virtual void visit( ConstructorExpr * old ) override final {
    2298                 this->node = visitBaseExpr( old,
    2299                         new ast::ConstructorExpr(
    2300                                 old->location,
    2301                                 GET_ACCEPT_1(callExpr, Expr)
    2302                         )
    2303                 );
    2304         }
    2305 
    2306         virtual void visit( CompoundLiteralExpr * old ) override final {
    2307                 this->node = visitBaseExpr_SkipResultType( old,
    2308                         new ast::CompoundLiteralExpr(
    2309                                 old->location,
    2310                                 GET_ACCEPT_1(result, Type),
    2311                                 GET_ACCEPT_1(initializer, Init)
    2312                         )
    2313                 );
    2314         }
    2315 
    2316         virtual void visit( RangeExpr * old ) override final {
    2317                 this->node = visitBaseExpr( old,
    2318                         new ast::RangeExpr(
    2319                                 old->location,
    2320                                 GET_ACCEPT_1(low, Expr),
    2321                                 GET_ACCEPT_1(high, Expr)
    2322                         )
    2323                 );
    2324         }
    2325 
    2326         virtual void visit( UntypedTupleExpr * old ) override final {
    2327                 this->node = visitBaseExpr( old,
    2328                         new ast::UntypedTupleExpr(
    2329                                 old->location,
    2330                                 GET_ACCEPT_V(exprs, Expr)
    2331                         )
    2332                 );
    2333         }
    2334 
    2335         virtual void visit( TupleExpr * old ) override final {
    2336                 this->node = visitBaseExpr( old,
    2337                         new ast::TupleExpr(
    2338                                 old->location,
    2339                                 GET_ACCEPT_V(exprs, Expr)
    2340                         )
    2341                 );
    2342         }
    2343 
    2344         virtual void visit( TupleIndexExpr * old ) override final {
    2345                 this->node = visitBaseExpr( old,
    2346                         new ast::TupleIndexExpr(
    2347                                 old->location,
    2348                                 GET_ACCEPT_1(tuple, Expr),
    2349                                 old->index
    2350                         )
    2351                 );
    2352         }
    2353 
    2354         virtual void visit( TupleAssignExpr * old ) override final {
    2355                 this->node = visitBaseExpr_SkipResultType( old,
    2356                         new ast::TupleAssignExpr(
    2357                                 old->location,
    2358                                 GET_ACCEPT_1(result, Type),
    2359                                 GET_ACCEPT_1(stmtExpr, StmtExpr)
    2360                         )
    2361                 );
    2362         }
    2363 
    2364         virtual void visit( StmtExpr * old ) override final {
    2365                 auto rslt = new ast::StmtExpr(
    2366                         old->location,
    2367                         GET_ACCEPT_1(statements, CompoundStmt)
    2368                 );
    2369                 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl);
    2370                 rslt->dtors       = GET_ACCEPT_V(dtors      , Expr);
    2371 
    2372                 this->node = visitBaseExpr_SkipResultType( old, rslt );
    2373         }
    2374 
    2375         virtual void visit( UniqueExpr * old ) override final {
    2376                 auto rslt = new ast::UniqueExpr(
    2377                         old->location,
    2378                         GET_ACCEPT_1(expr, Expr)
    2379                 );
    2380                 rslt->object = GET_ACCEPT_1(object, ObjectDecl);
    2381                 rslt->var    = GET_ACCEPT_1(var   , VariableExpr);
    2382 
    2383                 this->node = visitBaseExpr( old, rslt );
    2384         }
    2385 
    2386         virtual void visit( UntypedInitExpr * old ) override final {
    2387                 std::vector<ast::InitAlternative> initAlts;
    2388                 for (auto ia : old->initAlts) {
    2389                         initAlts.push_back(ast::InitAlternative(
    2390                                 getAccept1< ast::Type, Type * >( ia.type ),
    2391                                 getAccept1< ast::Designation, Designation * >( ia.designation )
    2392                         ));
    2393                 }
    2394                 this->node = visitBaseExpr( old,
    2395                         new ast::UntypedInitExpr(
    2396                                 old->location,
    2397                                 GET_ACCEPT_1(expr, Expr),
    2398                                 std::move(initAlts)
    2399                         )
    2400                 );
    2401         }
    2402 
    2403         virtual void visit( InitExpr * old ) override final {
    2404                 this->node = visitBaseExpr( old,
    2405                         new ast::InitExpr(
    2406                                 old->location,
    2407                                 GET_ACCEPT_1(expr, Expr),
    2408                                 GET_ACCEPT_1(designation, Designation)
    2409                         )
    2410                 );
    2411         }
    2412 
    2413         virtual void visit( DeletedExpr * old ) override final {
    2414                 this->node = visitBaseExpr( old,
    2415                         new ast::DeletedExpr(
    2416                                 old->location,
    2417                                 GET_ACCEPT_1(expr, Expr),
    2418                                 inCache(old->deleteStmt) ?
    2419                                         this->node :
    2420                                         GET_ACCEPT_1(deleteStmt, Node)
    2421                         )
    2422                 );
    2423         }
    2424 
    2425         virtual void visit( DefaultArgExpr * old ) override final {
    2426                 this->node = visitBaseExpr( old,
    2427                         new ast::DefaultArgExpr(
    2428                                 old->location,
    2429                                 GET_ACCEPT_1(expr, Expr)
    2430                         )
    2431                 );
    2432         }
    2433 
    2434         virtual void visit( GenericExpr * old ) override final {
    2435                 std::vector<ast::GenericExpr::Association> associations;
    2436                 for (auto association : old->associations) {
    2437                         associations.push_back(ast::GenericExpr::Association(
    2438                                 getAccept1< ast::Type, Type * >( association.type ),
    2439                                 getAccept1< ast::Expr, Expression * >( association.expr )
    2440                         ));
    2441                 }
    2442                 this->node = visitBaseExpr( old,
    2443                         new ast::GenericExpr(
    2444                                 old->location,
    2445                                 GET_ACCEPT_1(control, Expr),
    2446                                 std::move(associations)
    2447                         )
    2448                 );
     1555        virtual void visit( KeywordCastExpr * ) override final {
     1556
     1557        }
     1558
     1559        virtual void visit( VirtualCastExpr * ) override final {
     1560
     1561        }
     1562
     1563        virtual void visit( AddressExpr * ) override final {
     1564
     1565        }
     1566
     1567        virtual void visit( LabelAddressExpr * ) override final {
     1568
     1569        }
     1570
     1571        virtual void visit( UntypedMemberExpr * ) override final {
     1572
     1573        }
     1574
     1575        virtual void visit( MemberExpr * ) override final {
     1576
     1577        }
     1578
     1579        virtual void visit( VariableExpr * ) override final {
     1580
     1581        }
     1582
     1583        virtual void visit( ConstantExpr * ) override final {
     1584
     1585        }
     1586
     1587        virtual void visit( SizeofExpr * ) override final {
     1588
     1589        }
     1590
     1591        virtual void visit( AlignofExpr * ) override final {
     1592
     1593        }
     1594
     1595        virtual void visit( UntypedOffsetofExpr * ) override final {
     1596
     1597        }
     1598
     1599        virtual void visit( OffsetofExpr * ) override final {
     1600
     1601        }
     1602
     1603        virtual void visit( OffsetPackExpr * ) override final {
     1604
     1605        }
     1606
     1607        virtual void visit( LogicalExpr * ) override final {
     1608
     1609        }
     1610
     1611        virtual void visit( ConditionalExpr * ) override final {
     1612
     1613        }
     1614
     1615        virtual void visit( CommaExpr * ) override final {
     1616
     1617        }
     1618
     1619        virtual void visit( TypeExpr * ) override final {
     1620
     1621        }
     1622
     1623        virtual void visit( AsmExpr * ) override final {
     1624
     1625        }
     1626
     1627        virtual void visit( ImplicitCopyCtorExpr * ) override final {
     1628
     1629        }
     1630
     1631        virtual void visit( ConstructorExpr *  ) override final {
     1632
     1633        }
     1634
     1635        virtual void visit( CompoundLiteralExpr * ) override final {
     1636
     1637        }
     1638
     1639        virtual void visit( RangeExpr * ) override final {
     1640
     1641        }
     1642
     1643        virtual void visit( UntypedTupleExpr * ) override final {
     1644
     1645        }
     1646
     1647        virtual void visit( TupleExpr * ) override final {
     1648
     1649        }
     1650
     1651        virtual void visit( TupleIndexExpr * ) override final {
     1652
     1653        }
     1654
     1655        virtual void visit( TupleAssignExpr * ) override final {
     1656
     1657        }
     1658
     1659        virtual void visit( StmtExpr *  ) override final {
     1660
     1661        }
     1662
     1663        virtual void visit( UniqueExpr *  ) override final {
     1664
     1665        }
     1666
     1667        virtual void visit( UntypedInitExpr *  ) override final {
     1668
     1669        }
     1670
     1671        virtual void visit( InitExpr *  ) override final {
     1672
     1673        }
     1674
     1675        virtual void visit( DeletedExpr * ) override final {
     1676
     1677        }
     1678
     1679        virtual void visit( DefaultArgExpr * ) override final {
     1680
     1681        }
     1682
     1683        virtual void visit( GenericExpr * ) override final {
     1684
    24491685        }
    24501686
     
    26421878        }
    26431879
    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                 );
     1880        virtual void visit( Designation * ) override final {
     1881
     1882        }
     1883
     1884        virtual void visit( SingleInit * ) override final {
     1885
     1886        }
     1887
     1888        virtual void visit( ListInit * ) override final {
     1889
     1890        }
     1891
     1892        virtual void visit( ConstructorInit * ) override final {
     1893
    26751894        }
    26761895
    26771896        virtual void visit( Constant * ) override final {
    2678                 // Handled in visit( ConstantEpxr * ).
    2679                 // In the new tree, Constant fields are inlined into containing ConstantExpression.
     1897
     1898        }
     1899
     1900        virtual void visit( Attribute * ) override final {
     1901
     1902        }
     1903
     1904        virtual void visit( AttrExpr * ) override final {
     1905
    26801906                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                 );
    2688         }
    2689 
    2690         virtual void visit( AttrExpr * ) override final {
    2691                 assertf( false, "AttrExpr deprecated in new AST." );
    26921907        }
    26931908};
Note: See TracChangeset for help on using the changeset viewer.