Ignore:
Timestamp:
May 16, 2019, 10:58:52 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f2e482cb
Parents:
89c2f7c9
Message:

Fixed FunctionType? cast, fixed maybe_accept, implemented statement visitation and fixed several nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r89c2f7c9 r8a5530c  
    6464
    6565                        std::transform(decls->begin(), decls->end(), it, [](const ast::Decl * decl) -> auto {
    66                                         return new DeclStmt( decl );
     66                                        return new DeclStmt( decl->location, decl );
    6767                                });
    6868                        decls->clear();
     
    119119        template< typename pass_t >
    120120        template< typename node_t >
    121         auto Pass< pass_t >::call_accept( const node_t * node ) -> decltype( node->accept(*this) ) {
     121        auto Pass< pass_t >::call_accept( const node_t * node )
     122                -> typename std::enable_if<
     123                                !std::is_base_of<ast::Expr, node_t>::value &&
     124                                !std::is_base_of<ast::Stmt, node_t>::value
     125                        , decltype( node->accept(*this) )
     126                >::type
     127
     128        {
    122129                __pedantic_pass_assert( __visit_children() );
    123130                __pedantic_pass_assert( expr );
     
    296303                child_t parent_t::*child
    297304        ) {
    298                 static_assert( std::is_base_of<parent_t, node_t>::value, "Error deductiing member object" );
     305                static_assert( std::is_base_of<parent_t, node_t>::value, "Error deducing member object" );
    299306
    300307                if(__pass::skip(parent->*child)) return;
     
    424431                                new ast::ArrayType(
    425432                                        new ast::BasicType( ast::BasicType::Char, ast::CV::Qualifiers( ast::CV::Const ) ),
    426                                         nullptr, true, false
     433                                        nullptr, VariableLen, DynamicDim
    427434                                )
    428435                        );
     
    434441                                ValueGuard< bool > oldInFunction( inFunction );
    435442                                inFunction = true;
    436                                 maybe_accept( node, &FunctionDecl::statements );
     443                                maybe_accept( node, &FunctionDecl::stmts );
    437444                                maybe_accept( node, &FunctionDecl::attributes );
    438445                        )
     
    537544
    538545        VISIT(
    539                 maybe_accept( node, &TypeDecl::assertions, *this );
     546                maybe_accept( node, &TypeDecl::assertions );
    540547
    541548                {
     
    614621}
    615622
     623//--------------------------------------------------------------------------
     624// ExprStmt
     625template< typename pass_t >
     626const ast::Stmt * ast::Pass< pass_t >::visit( const ExprStmt * node ) {
     627        VISIT_START( node );
     628
     629        VISIT(
     630                maybe_accept( node, &ExprStmt::expr );
     631        )
     632
     633        VISIT_END( Stmt, node );
     634}
     635
     636//--------------------------------------------------------------------------
     637// AsmStmt
     638template< typename pass_t >
     639const ast::Stmt * ast::Pass< pass_t >::visit( const ast::AsmStmt * node ) {
     640        VISIT_START( node )
     641
     642        VISIT(
     643                maybe_accept( node, &AsmStmt::instruction );
     644                maybe_accept( node, &AsmStmt::output      );
     645                maybe_accept( node, &AsmStmt::input       );
     646                maybe_accept( node, &AsmStmt::clobber     );
     647        )
     648
     649        VISIT_END( Stmt, node );
     650}
     651
     652//--------------------------------------------------------------------------
     653// DirectiveStmt
     654template< typename pass_t >
     655const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DirectiveStmt * node ) {
     656        VISIT_START( node )
     657
     658        VISIT_END( Stmt, node );
     659}
     660
     661//--------------------------------------------------------------------------
     662// IfStmt
     663template< typename pass_t >
     664const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) {
     665        VISIT_START( node );
     666        VISIT({
     667                // if statements introduce a level of scope (for the initialization)
     668                guard_indexer guard { *this };
     669                maybe_accept( node, &IfStmt::inits    );
     670                maybe_accept( node, &IfStmt::cond     );
     671                maybe_accept( node, &IfStmt::thenPart );
     672                maybe_accept( node, &IfStmt::elsePart );
     673        })
     674        VISIT_END( Stmt, node );
     675}
     676
     677//--------------------------------------------------------------------------
     678// WhileStmt
     679template< typename pass_t >
     680const ast::Stmt * ast::Pass< pass_t >::visit( const WhileStmt * node ) {
     681        VISIT_START( node );
     682
     683        VISIT({
     684                // while statements introduce a level of scope (for the initialization)
     685                guard_indexer guard { *this };
     686                maybe_accept( node, &WhileStmt::inits );
     687                maybe_accept( node, &WhileStmt::cond  );
     688                maybe_accept( node, &WhileStmt::body  );
     689        })
     690
     691        VISIT_END( Stmt, node );
     692}
    616693
    617694//--------------------------------------------------------------------------
     
    667744        )
    668745
    669         VISIT_END( Attribute *, node );
     746        VISIT_END( Attribute, node );
    670747}
    671748
Note: See TracChangeset for help on using the changeset viewer.