Changes in / [4c530a5:3c79ea9]


Ignore:
Location:
src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r4c530a5 r3c79ea9  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 20 13:58:00 2022
    13 // Update Count     : 43
     12// Last Modified On : Wed Mar 16 15:01:00 2022
     13// Update Count     : 42
    1414//
    1515
     
    562562                for ( auto clause : node->clauses ) {
    563563                        stmt->clauses.push_back({{
    564                                         get<Expression>().accept1( clause->target_func ),
    565                                         get<Expression>().acceptL( clause->target_args ),
     564                                        get<Expression>().accept1( clause.target.func ),
     565                                        get<Expression>().acceptL( clause.target.args ),
    566566                                },
    567                                 get<Statement>().accept1( clause->stmt ),
    568                                 get<Expression>().accept1( clause->cond ),
     567                                get<Statement>().accept1( clause.stmt ),
     568                                get<Expression>().accept1( clause.cond ),
    569569                        });
    570570                }
    571571                stmt->timeout = {
    572                         get<Expression>().accept1( node->timeout_time ),
    573                         get<Statement>().accept1( node->timeout_stmt ),
    574                         get<Expression>().accept1( node->timeout_cond ),
     572                        get<Expression>().accept1( node->timeout.time ),
     573                        get<Statement>().accept1( node->timeout.stmt ),
     574                        get<Expression>().accept1( node->timeout.cond ),
    575575                };
    576576                stmt->orelse = {
    577                         get<Statement>().accept1( node->else_stmt ),
    578                         get<Expression>().accept1( node->else_cond ),
     577                        get<Statement>().accept1( node->orElse.stmt ),
     578                        get<Expression>().accept1( node->orElse.cond ),
    579579                };
    580580                return stmtPostamble( stmt, node );
    581         }
    582 
    583         const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final {
    584                 // There is no old-AST WaitForClause, so this should never be called.
    585                 assert( !node );
    586                 return nullptr;
    587581        }
    588582
     
    21022096                stmt->clauses.reserve( old->clauses.size() );
    21032097                for (size_t i = 0 ; i < old->clauses.size() ; ++i) {
    2104                         auto clause = new ast::WaitForClause( old->location );
    2105 
    2106                         clause->target_func = GET_ACCEPT_1(clauses[i].target.function, Expr);
    2107                         clause->target_args = GET_ACCEPT_V(clauses[i].target.arguments, Expr);
    2108                         clause->stmt = GET_ACCEPT_1(clauses[i].statement, Stmt);
    2109                         clause->cond = GET_ACCEPT_1(clauses[i].condition, Expr);
    2110 
    2111                         stmt->clauses.push_back( clause );
    2112                 }
    2113                 stmt->timeout_time = GET_ACCEPT_1(timeout.time, Expr);
    2114                 stmt->timeout_stmt = GET_ACCEPT_1(timeout.statement, Stmt);
    2115                 stmt->timeout_cond = GET_ACCEPT_1(timeout.condition, Expr);
    2116                 stmt->else_stmt = GET_ACCEPT_1(orelse.statement, Stmt);
    2117                 stmt->else_cond = GET_ACCEPT_1(orelse.condition, Expr);
     2098                        stmt->clauses.push_back({
     2099                                ast::WaitForStmt::Target{
     2100                                        GET_ACCEPT_1(clauses[i].target.function, Expr),
     2101                                        GET_ACCEPT_V(clauses[i].target.arguments, Expr)
     2102                                },
     2103                                GET_ACCEPT_1(clauses[i].statement, Stmt),
     2104                                GET_ACCEPT_1(clauses[i].condition, Expr)
     2105                        });
     2106                }
     2107                stmt->timeout = {
     2108                        GET_ACCEPT_1(timeout.time, Expr),
     2109                        GET_ACCEPT_1(timeout.statement, Stmt),
     2110                        GET_ACCEPT_1(timeout.condition, Expr),
     2111                };
     2112                stmt->orElse = {
     2113                        GET_ACCEPT_1(orelse.statement, Stmt),
     2114                        GET_ACCEPT_1(orelse.condition, Expr),
     2115                };
    21182116
    21192117                this->node = stmt;
     
    27772775        }
    27782776
    2779         virtual void visit( const EnumInstType * old ) override final {
     2777        virtual void visit( const EnumInstType * old ) override final { // Here is visiting the EnumInst Decl not the usage.
    27802778                ast::EnumInstType * ty;
    27812779                if ( old->baseEnum ) {
    2782                         ty = new ast::EnumInstType{
     2780                        ty = new ast::EnumInstType{ // Probably here: missing the specification of the base
    27832781                                GET_ACCEPT_1( baseEnum, EnumDecl ),
    27842782                                cv( old ),
  • src/AST/Fwd.hpp

    r4c530a5 r3c79ea9  
    5656class SuspendStmt;
    5757class WaitForStmt;
    58 class WaitForClause;
    5958class WithStmt;
    6059class DeclStmt;
  • src/AST/Node.cpp

    r4c530a5 r3c79ea9  
    176176template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::weak >;
    177177template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::strong >;
    178 template class ast::ptr_base< ast::WaitForClause, ast::Node::ref_type::weak >;
    179 template class ast::ptr_base< ast::WaitForClause, ast::Node::ref_type::strong >;
    180178template class ast::ptr_base< ast::WithStmt, ast::Node::ref_type::weak >;
    181179template class ast::ptr_base< ast::WithStmt, ast::Node::ref_type::strong >;
  • src/AST/Pass.hpp

    r4c530a5 r3c79ea9  
    158158        const ast::Stmt *             visit( const ast::SuspendStmt          * ) override final;
    159159        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
    160         const ast::WaitForClause *    visit( const ast::WaitForClause        * ) override final;
    161160        const ast::Decl *             visit( const ast::WithStmt             * ) override final;
    162161        const ast::NullStmt *         visit( const ast::NullStmt             * ) override final;
  • src/AST/Pass.impl.hpp

    r4c530a5 r3c79ea9  
    10101010const ast::Stmt * ast::Pass< core_t >::visit( const ast::WaitForStmt * node ) {
    10111011        VISIT_START( node );
    1012 
    1013         if ( __visit_children() ) {
    1014                 maybe_accept( node, &WaitForStmt::clauses );
    1015                 maybe_accept( node, &WaitForStmt::timeout_time );
    1016                 maybe_accept( node, &WaitForStmt::timeout_stmt );
    1017                 maybe_accept( node, &WaitForStmt::timeout_cond );
    1018                 maybe_accept( node, &WaitForStmt::else_stmt );
    1019                 maybe_accept( node, &WaitForStmt::else_cond );
    1020         }
     1012                // for( auto & clause : node->clauses ) {
     1013                //      maybeAccept_impl( clause.target.function, *this );
     1014                //      maybeAccept_impl( clause.target.arguments, *this );
     1015
     1016                //      maybeAccept_impl( clause.statement, *this );
     1017                //      maybeAccept_impl( clause.condition, *this );
     1018                // }
     1019
     1020        if ( __visit_children() ) {
     1021                std::vector<WaitForStmt::Clause> new_clauses;
     1022                new_clauses.reserve( node->clauses.size() );
     1023                bool mutated = false;
     1024                for( const auto & clause : node->clauses ) {
     1025
     1026                        const Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr;
     1027                        if(func != clause.target.func) mutated = true;
     1028                        else func = nullptr;
     1029
     1030                        std::vector<ptr<Expr>> new_args;
     1031                        new_args.reserve(clause.target.args.size());
     1032                        for( const auto & arg : clause.target.args ) {
     1033                                auto a = arg->accept(*this);
     1034                                if( a != arg ) {
     1035                                        mutated = true;
     1036                                        new_args.push_back( a );
     1037                                } else
     1038                                        new_args.push_back( nullptr );
     1039                        }
     1040
     1041                        const Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
     1042                        if(stmt != clause.stmt) mutated = true;
     1043                        else stmt = nullptr;
     1044
     1045                        const Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
     1046                        if(cond != clause.cond) mutated = true;
     1047                        else cond = nullptr;
     1048
     1049                        new_clauses.push_back( WaitForStmt::Clause{ {func, std::move(new_args) }, stmt, cond } );
     1050                }
     1051
     1052                if(mutated) {
     1053                        auto n = __pass::mutate<core_t>(node);
     1054                        for(size_t i = 0; i < new_clauses.size(); i++) {
     1055                                if(new_clauses.at(i).target.func != nullptr) swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func);
     1056
     1057                                for(size_t j = 0; j < new_clauses.at(i).target.args.size(); j++) {
     1058                                        if(new_clauses.at(i).target.args.at(j) != nullptr) swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j));
     1059                                }
     1060
     1061                                if(new_clauses.at(i).stmt != nullptr) swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt);
     1062                                if(new_clauses.at(i).cond != nullptr) swap(n->clauses.at(i).cond, new_clauses.at(i).cond);
     1063                        }
     1064                        node = n;
     1065                }
     1066        }
     1067
     1068        #define maybe_accept(field) \
     1069                if(node->field) { \
     1070                        auto nval = call_accept( node->field ); \
     1071                        if(nval.differs ) { \
     1072                                auto nparent = __pass::mutate<core_t>(node); \
     1073                                nparent->field = nval.value; \
     1074                                node = nparent; \
     1075                        } \
     1076                }
     1077
     1078        if ( __visit_children() ) {
     1079                maybe_accept( timeout.time );
     1080                maybe_accept( timeout.stmt );
     1081                maybe_accept( timeout.cond );
     1082                maybe_accept( orElse.stmt  );
     1083                maybe_accept( orElse.cond  );
     1084        }
     1085
     1086        #undef maybe_accept
    10211087
    10221088        VISIT_END( Stmt, node );
    1023 }
    1024 
    1025 //--------------------------------------------------------------------------
    1026 // WaitForClause
    1027 template< typename core_t >
    1028 const ast::WaitForClause * ast::Pass< core_t >::visit( const ast::WaitForClause * node ) {
    1029         VISIT_START( node );
    1030 
    1031         if ( __visit_children() ) {
    1032                 maybe_accept( node, &WaitForClause::target_func );
    1033                 maybe_accept( node, &WaitForClause::target_args );
    1034                 maybe_accept( node, &WaitForClause::stmt );
    1035                 maybe_accept( node, &WaitForClause::cond );
    1036         }
    1037 
    1038         VISIT_END( WaitForClause, node );
    10391089}
    10401090
  • src/AST/Print.cpp

    r4c530a5 r3c79ea9  
    760760                indent += 2;
    761761                for( const auto & clause : node->clauses ) {
    762                         clause->accept( *this );
    763                 }
    764 
    765                 if ( node->timeout_time ) {
     762                        os << indent-1 << "target function: ";
     763                        safe_print( clause.target.func );
     764
     765                        if ( ! clause.target.args.empty() ) {
     766                                os << endl << indent-1 << "... with arguments:" << endl;
     767                                for( const ast::Expr * arg : clause.target.args ) {
     768                                        arg->accept( *this );
     769                                }
     770                        }
     771
     772                        if ( clause.stmt ) {
     773                                os << indent-1 << "... with statment:" << endl;
     774                                clause.stmt->accept( *this );
     775                        }
     776
     777                        if ( clause.cond ) {
     778                                os << indent-1 << "... with condition:" << endl;
     779                                clause.cond->accept( *this );
     780                        }
     781                }
     782
     783                if ( node->timeout.time ) {
    766784                        os << indent-1 << "timeout of:" << endl;
    767                         node->timeout_time->accept( *this );
    768 
    769                         if ( node->timeout_stmt ) {
     785                        node->timeout.time->accept( *this );
     786
     787                        if ( node->timeout.stmt ) {
    770788                                os << indent-1 << "... with statment:" << endl;
    771                                 node->timeout_stmt->accept( *this );
    772                         }
    773 
    774                         if ( node->timeout_cond ) {
     789                                node->timeout.stmt->accept( *this );
     790                        }
     791
     792                        if ( node->timeout.cond ) {
    775793                                os << indent-1 << "... with condition:" << endl;
    776                                 node->timeout_cond->accept( *this );
    777                         }
    778                 }
    779 
    780                 if ( node->else_stmt ) {
     794                                node->timeout.cond->accept( *this );
     795                        }
     796                }
     797
     798                if ( node->orElse.stmt ) {
    781799                        os << indent-1 << "else:" << endl;
    782                         node->else_stmt->accept( *this );
    783 
    784                         if ( node->else_cond ) {
     800                        node->orElse.stmt->accept( *this );
     801
     802                        if ( node->orElse.cond ) {
    785803                                os << indent-1 << "... with condition:" << endl;
    786                                 node->else_cond->accept( *this );
    787                         }
    788                 }
    789 
    790                 return node;
    791         }
    792 
    793         virtual const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final {
    794                 os << indent-1 << "target function: ";
    795                 safe_print( node->target_func );
    796 
    797                 if ( !node->target_args.empty() ) {
    798                         os << endl << indent-1 << "... with arguments:" << endl;
    799                         for( const ast::Expr * arg : node->target_args ) {
    800                                 arg->accept( *this );
    801                         }
    802                 }
    803 
    804                 if ( node->stmt ) {
    805                         os << indent-1 << "... with statment:" << endl;
    806                         node->stmt->accept( *this );
    807                 }
    808 
    809                 if ( node->cond ) {
    810                         os << indent-1 << "... with condition:" << endl;
    811                         node->cond->accept( *this );
    812                 }
     804                                node->orElse.cond->accept( *this );
     805                        }
     806                }
     807                indent -= 2;
    813808
    814809                return node;
  • src/AST/Stmt.hpp

    r4c530a5 r3c79ea9  
    1010// Created On       : Wed May  8 13:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 20 14:34:00 2022
    13 // Update Count     : 36
     12// Last Modified On : Mon Mar 28  9:50:00 2022
     13// Update Count     : 35
    1414//
    1515
     
    378378class WaitForStmt final : public Stmt {
    379379  public:
    380         std::vector<ptr<WaitForClause>> clauses;
    381         ptr<Expr> timeout_time;
    382         ptr<Stmt> timeout_stmt;
    383         ptr<Expr> timeout_cond;
    384         ptr<Stmt> else_stmt;
    385         ptr<Expr> else_cond;
     380        struct Target {
     381                ptr<Expr> func;
     382                std::vector<ptr<Expr>> args;
     383        };
     384
     385        struct Clause {
     386                Target target;
     387                ptr<Stmt> stmt;
     388                ptr<Expr> cond;
     389        };
     390
     391        struct Timeout {
     392                ptr<Expr> time;
     393                ptr<Stmt> stmt;
     394                ptr<Expr> cond;
     395        };
     396
     397        struct OrElse {
     398                ptr<Stmt> stmt;
     399                ptr<Expr> cond;
     400        };
     401
     402        std::vector<Clause> clauses;
     403        Timeout timeout;
     404        OrElse orElse;
    386405
    387406        WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     
    392411        WaitForStmt * clone() const override { return new WaitForStmt{ *this }; }
    393412        MUTATE_FRIEND
    394 };
    395 
    396 class WaitForClause final : public StmtClause {
    397   public:
    398     ptr<Expr> target_func;
    399     std::vector<ptr<Expr>> target_args;
    400     ptr<Stmt> stmt;
    401     ptr<Expr> cond;
    402 
    403     WaitForClause( const CodeLocation & loc )
    404                 : StmtClause( loc ) {}
    405 
    406         const WaitForClause * accept( Visitor & v ) const override { return v.visit( this ); }
    407   private:
    408     WaitForClause * clone() const override { return new WaitForClause{ *this }; }
    409     MUTATE_FRIEND
    410413};
    411414
  • src/AST/Visitor.hpp

    r4c530a5 r3c79ea9  
    5050    virtual const ast::Stmt *             visit( const ast::SuspendStmt          * ) = 0;
    5151    virtual const ast::Stmt *             visit( const ast::WaitForStmt          * ) = 0;
    52     virtual const ast::WaitForClause *    visit( const ast::WaitForClause        * ) = 0;
    5352    virtual const ast::Decl *             visit( const ast::WithStmt             * ) = 0;
    5453    virtual const ast::NullStmt *         visit( const ast::NullStmt             * ) = 0;
  • src/Common/CodeLocationTools.cpp

    r4c530a5 r3c79ea9  
    121121    macro(SuspendStmt, Stmt) \
    122122    macro(WaitForStmt, Stmt) \
    123     macro(WaitForClause, WaitForClause) \
    124123    macro(WithStmt, Decl) \
    125124    macro(NullStmt, NullStmt) \
  • src/Parser/DeclarationNode.cc

    r4c530a5 r3c79ea9  
    253253} // DeclarationNode::newAggregate
    254254
    255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body) {
     255DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed) {
    256256        DeclarationNode * newnode = new DeclarationNode;
    257257        newnode->type = new TypeData( TypeData::Enum );
     
    272272} // DeclarationNode::newName
    273273
    274 DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) {
     274DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) { // Marker
    275275        DeclarationNode * newnode = newName( name );
    276276        newnode->enumeratorValue.reset( constant );
    277277        return newnode;
    278278} // DeclarationNode::newEnumConstant
    279 
    280 DeclarationNode * DeclarationNode::newEnumValueGeneric( const string * name, InitializerNode * init ) {
    281         if ( init ) { // list init {} or a singleInit
    282                 if ( init->get_expression() ) { // singleInit
    283                         return newEnumConstant( name, init->get_expression() );
    284                 } else { // TODO: listInit
    285                         DeclarationNode * newnode = newName( name );
    286                         newnode->initializer = init;
    287                         return newnode;
    288                 } // if
    289         } else {
    290                 return newName( name ); // Not explicitly inited enum value;
    291         } // if
    292 } // DeclarationNode::newEnumGeneric
    293279
    294280DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) {
  • src/Parser/InitializerNode.cc

    r4c530a5 r3c79ea9  
    101101        } else {
    102102                if ( get_expression() ) {
    103                         assertf( get_expression()->expr, "The expression of initializer must have value" );
    104103                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
    105104                } // if
  • src/Parser/ParseNode.h

    r4c530a5 r3c79ea9  
    235235        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    236236        static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    237         static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );
     237        static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed );
    238238        static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant );
    239         static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init );
    240239        static DeclarationNode * newName( const std::string * );
    241240        static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params );
  • src/Parser/parser.yy

    r4c530a5 r3c79ea9  
    380380
    381381%type<decl> enumerator_list enum_type enum_type_nobody
    382 %type<in> enumerator_value_opt
     382%type<en> enumerator_value_opt
    383383
    384384%type<decl> external_definition external_definition_list external_definition_list_opt
     
    23052305enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed );                                                                                         // enum
    23062306        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    2307                 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
     2307                { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); }
    23082308        | ENUM attribute_list_opt identifier
    23092309                { typedefTable.makeTypedef( *$3 ); }
    23102310          '{' enumerator_list comma_opt '}'
    2311                 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
     2311                { $$ = DeclarationNode::newEnum( $3, $6, true, false )->addQualifiers( $2 ); }
    23122312        | ENUM attribute_list_opt typedef_name                          // unqualified type name
    23132313          '{' enumerator_list comma_opt '}'
    2314                 { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }
     2314                { $$ = DeclarationNode::newEnum( $3->name, $5, true, false )->addQualifiers( $2 ); }
    23152315        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    23162316                {
    23172317                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 )
    23182318                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    2319 
    2320                         $$ = DeclarationNode::newEnum( nullptr, $7, true ) ->addQualifiers( $5 )  -> addEnumBase( $3 );
     2319                        // SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2320
     2321                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 )  -> addEnumBase( $3 );
     2322                        // $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 );
    23212323                }
    23222324        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier
     
    23272329          '{' enumerator_list comma_opt '}'
    23282330                {
    2329                         $$ = DeclarationNode::newEnum( $6, $10, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2331                        $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2332                        // $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
    23302333                }
    23312334        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     
    23332336                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23342337                        typedefTable.makeTypedef( *$6->name );
    2335                         $$ = DeclarationNode::newEnum( $6->name, $9, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2338                        $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2339                        // $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
    23362340                }
    23372341        | enum_type_nobody
     
    23402344enum_type_nobody:                                                                               // enum - {...}
    23412345        ENUM attribute_list_opt identifier
    2342                 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); }
     2346                { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }
    23432347        | ENUM attribute_list_opt type_name                                     // qualified type name
    2344                 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); }
     2348                { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }
    23452349        ;
    23462350
    23472351enumerator_list:
    23482352        identifier_or_type_name enumerator_value_opt
    2349                 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); }
     2353                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    23502354        | INLINE type_name
    2351                 { $$ = DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ); }
     2355                { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); }
    23522356        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    2353                 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); }
     2357                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    23542358        | enumerator_list ',' INLINE type_name enumerator_value_opt
    2355                 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); }
     2359                { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); }
    23562360        ;
    23572361
     
    23622366        //      { $$ = $2; }
    23632367        | simple_assignment_operator initializer
    2364                 { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); }
     2368                { $$ = $2->get_expression(); }                                  // FIX ME: enum only deals with constant_expression
    23652369        ;
    23662370
  • src/ResolvExpr/Resolver.cc

    r4c530a5 r3c79ea9  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 20 10:41:00 2022
    13 // Update Count     : 248
     12// Last Modified On : Fri Mar 18 10:41:00 2022
     13// Update Count     : 247
    1414//
    1515
     
    17381738                // Resolve all clauses first
    17391739                for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) {
    1740                         const ast::WaitForClause & clause = *stmt->clauses[i];
     1740                        const ast::WaitForStmt::Clause & clause = stmt->clauses[i];
    17411741
    17421742                        ast::TypeEnvironment env;
     
    17441744
    17451745                        // Find all candidates for a function in canonical form
    1746                         funcFinder.find( clause.target_func, ResolvMode::withAdjustment() );
     1746                        funcFinder.find( clause.target.func, ResolvMode::withAdjustment() );
    17471747
    17481748                        if ( funcFinder.candidates.empty() ) {
    17491749                                stringstream ss;
    17501750                                ss << "Use of undeclared indentifier '";
    1751                                 ss << clause.target_func.strict_as< ast::NameExpr >()->name;
     1751                                ss << clause.target.func.strict_as< ast::NameExpr >()->name;
    17521752                                ss << "' in call to waitfor";
    17531753                                SemanticError( stmt->location, ss.str() );
    17541754                        }
    17551755
    1756                         if ( clause.target_args.empty() ) {
     1756                        if ( clause.target.args.empty() ) {
    17571757                                SemanticError( stmt->location,
    17581758                                        "Waitfor clause must have at least one mutex parameter");
     
    17611761                        // Find all alternatives for all arguments in canonical form
    17621762                        std::vector< CandidateFinder > argFinders =
    1763                                 funcFinder.findSubExprs( clause.target_args );
     1763                                funcFinder.findSubExprs( clause.target.args );
    17641764
    17651765                        // List all combinations of arguments
     
    19341934
    19351935                        // build new clause
    1936                         auto clause2 = new ast::WaitForClause( clause.location );
    1937 
    1938                         clause2->target_func = funcCandidates.front()->expr;
    1939 
    1940                         clause2->target_args.reserve( clause.target_args.size() );
     1936                        ast::WaitForStmt::Clause clause2;
     1937
     1938                        clause2.target.func = funcCandidates.front()->expr;
     1939
     1940                        clause2.target.args.reserve( clause.target.args.size() );
    19411941                        const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" );
    19421942                        for ( auto arg : argsCandidates.front() ) {
     
    19551955                                );
    19561956
    1957                                 clause2->target_args.emplace_back( findSingleExpression( init, context ) );
     1957                                clause2.target.args.emplace_back( findSingleExpression( init, context ) );
    19581958                        }
    19591959
    19601960                        // Resolve the conditions as if it were an IfStmt, statements normally
    1961                         clause2->cond = findSingleExpression( clause.cond, context );
    1962                         clause2->stmt = clause.stmt->accept( *visitor );
     1961                        clause2.cond = findSingleExpression( clause.cond, context );
     1962                        clause2.stmt = clause.stmt->accept( *visitor );
    19631963
    19641964                        // set results into stmt
    19651965                        auto n = mutate( stmt );
    1966                         n->clauses[i] = clause2;
     1966                        n->clauses[i] = std::move( clause2 );
    19671967                        stmt = n;
    19681968                }
    19691969
    1970                 if ( stmt->timeout_stmt ) {
     1970                if ( stmt->timeout.stmt ) {
    19711971                        // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
     1972                        ast::WaitForStmt::Timeout timeout2;
     1973
    19721974                        ast::ptr< ast::Type > target =
    19731975                                new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
    1974                         auto timeout_time = findSingleExpression( stmt->timeout_time, target, context );
    1975                         auto timeout_cond = findSingleExpression( stmt->timeout_cond, context );
    1976                         auto timeout_stmt = stmt->timeout_stmt->accept( *visitor );
     1976                        timeout2.time = findSingleExpression( stmt->timeout.time, target, context );
     1977                        timeout2.cond = findSingleExpression( stmt->timeout.cond, context );
     1978                        timeout2.stmt = stmt->timeout.stmt->accept( *visitor );
    19771979
    19781980                        // set results into stmt
    19791981                        auto n = mutate( stmt );
    1980                         n->timeout_time = std::move( timeout_time );
    1981                         n->timeout_cond = std::move( timeout_cond );
    1982                         n->timeout_stmt = std::move( timeout_stmt );
     1982                        n->timeout = std::move( timeout2 );
    19831983                        stmt = n;
    19841984                }
    19851985
    1986                 if ( stmt->else_stmt ) {
     1986                if ( stmt->orElse.stmt ) {
    19871987                        // resolve the condition like IfStmt, stmts normally
    1988                         auto else_cond = findSingleExpression( stmt->else_cond, context );
    1989                         auto else_stmt = stmt->else_stmt->accept( *visitor );
     1988                        ast::WaitForStmt::OrElse orElse2;
     1989
     1990                        orElse2.cond = findSingleExpression( stmt->orElse.cond, context );
     1991                        orElse2.stmt = stmt->orElse.stmt->accept( *visitor );
    19901992
    19911993                        // set results into stmt
    19921994                        auto n = mutate( stmt );
    1993                         n->else_cond = std::move( else_cond );
    1994                         n->else_stmt = std::move( else_stmt );
     1995                        n->orElse = std::move( orElse2 );
    19951996                        stmt = n;
    19961997                }
  • src/SynTree/Visitor.h

    r4c530a5 r3c79ea9  
    3535        virtual void visit( UnionDecl * node ) { visit( const_cast<const UnionDecl *>(node) ); }
    3636        virtual void visit( const UnionDecl * aggregateDecl ) = 0;
    37         virtual void visit( EnumDecl * node ) { visit( const_cast<const EnumDecl *>(node) ); }
     37        virtual void visit( EnumDecl * node ) { visit( const_cast<const EnumDecl *>(node) ); } // Marker 1
    3838        virtual void visit( const EnumDecl * aggregateDecl ) = 0;
    3939        virtual void visit( TraitDecl * node ) { visit( const_cast<const TraitDecl *>(node) ); }
     
    190190        virtual void visit( UnionInstType * node ) { visit( const_cast<const UnionInstType *>(node) ); }
    191191        virtual void visit( const UnionInstType * aggregateUseType ) = 0;
    192         virtual void visit( EnumInstType * node ) { visit( const_cast<const EnumInstType *>(node) ); }
     192        virtual void visit( EnumInstType * node ) { visit( const_cast<const EnumInstType *>(node) ); } // Marker 2
    193193        virtual void visit( const EnumInstType * aggregateUseType ) = 0;
    194194        virtual void visit( TraitInstType * node ) { visit( const_cast<const TraitInstType *>(node) ); }
Note: See TracChangeset for help on using the changeset viewer.