Changes in / [f265042:1755226]


Ignore:
Location:
src
Files:
3 deleted
40 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rf265042 r1755226  
    879879
    880880        void CodeGenerator::postvisit( CaseStmt * caseStmt ) {
    881                 updateLocation( caseStmt );
    882                 output << indent;
    883881                if ( caseStmt->isDefault()) {
    884882                        output << "default";
     
    10221020} // namespace CodeGen
    10231021
    1024 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
    1025         if ( node ) {
    1026                 node->print( out );
    1027         } else {
    1028                 out << "nullptr";
    1029         }
    1030         return out;
    1031 }
    1032 
    10331022// Local Variables: //
    10341023// tab-width: 4 //
  • src/Concurrency/Keywords.cc

    rf265042 r1755226  
    528528                DeclarationWithType * param = decl->get_functionType()->get_parameters().front();
    529529                auto type  = dynamic_cast< StructInstType * >( InitTweak::getPointerBase( param->get_type() ) );
     530                // if( type ) std::cerr << "FRED2" << std::endl;
    530531                if( type && type->get_baseStruct()->is_thread() ) {
    531532                        addStartStatement( decl, param );
  • src/Concurrency/Waitfor.cc

    rf265042 r1755226  
    2727#include "InitTweak/InitTweak.h"   // for getPointerBase
    2828#include "Parser/LinkageSpec.h"    // for Cforall
    29 #include "ResolvExpr/Resolver.h"   // for findVoidExpression
     29#include "SymTab/AddVisit.h"       // for acceptAndAdd
    3030#include "SynTree/Constant.h"      // for Constant
    3131#include "SynTree/Declaration.h"   // for StructDecl, FunctionDecl, ObjectDecl
     
    112112        //=============================================================================================
    113113
    114         class GenerateWaitForPass final : public WithIndexer {
     114        class GenerateWaitForPass final : public WithStmtsToAdd {
    115115          public:
    116116
     
    126126
    127127                ObjectDecl * declare( unsigned long count, CompoundStmt * stmt );
    128                 ObjectDecl * declareFlag( CompoundStmt * stmt );
    129                 Statement  * makeSetter( ObjectDecl * flag );
    130128                ObjectDecl * declMon( WaitForStmt::Clause & clause, CompoundStmt * stmt );
    131                 void         init( ObjectDecl * acceptables, int index, WaitForStmt::Clause & clause, Statement * settter, CompoundStmt * stmt );
    132                 Expression * init_timeout( Expression *& time, Expression *& time_cond, bool has_else, Expression *& else_cond, Statement * settter, CompoundStmt * stmt );
    133                 Expression * call(size_t count, ObjectDecl * acceptables, Expression * timeout, CompoundStmt * stmt);
    134                 void         choose( WaitForStmt * waitfor, Expression  * result, CompoundStmt * stmt );
     129                void         init( ObjectDecl * acceptables, int index, WaitForStmt::Clause & clause, CompoundStmt * stmt );
     130                Expression * init_timeout( Expression *& time, Expression *& time_cond, bool has_else, Expression *& else_cond, CompoundStmt * stmt );
     131                Expression * call();
     132                void choose();
    135133
    136134                static void implement( std::list< Declaration * > & translationUnit ) {
     
    142140          private:
    143141                FunctionDecl        * decl_waitfor    = nullptr;
    144                 StructDecl          * decl_mask       = nullptr;
    145142                StructDecl          * decl_acceptable = nullptr;
    146143                StructDecl          * decl_monitor    = nullptr;
     144                DeclarationWithType * decl_m_func     = nullptr;
     145                DeclarationWithType * decl_m_count    = nullptr;
     146                DeclarationWithType * decl_m_monitors = nullptr;
     147                DeclarationWithType * decl_m_isdtor   = nullptr;
    147148
    148149                static std::unique_ptr< Type > generic_func;
    149150
     151                UniqueName namer_mon = "__monitors_"s;
    150152                UniqueName namer_acc = "__acceptables_"s;
    151                 UniqueName namer_idx = "__index_"s;
    152                 UniqueName namer_flg = "__do_run_"s;
    153                 UniqueName namer_msk = "__mask_"s;
    154                 UniqueName namer_mon = "__monitors_"s;
    155153                UniqueName namer_tim = "__timeout_"s;
    156154        };
     
    169167        namespace {
    170168                Expression * makeOpIndex( DeclarationWithType * array, unsigned long index ) {
    171                         return new UntypedExpr(
     169                        return new ApplicationExpr(
    172170                                new NameExpr( "?[?]" ),
    173171                                {
     
    179177
    180178                Expression * makeOpAssign( Expression * lhs, Expression * rhs ) {
    181                         return new UntypedExpr(
     179                        return new ApplicationExpr(
    182180                                        new NameExpr( "?=?" ),
    183181                                        { lhs, rhs }
     
    185183                }
    186184
    187                 Expression * makeOpMember( Expression * sue, const std::string & mem ) {
    188                         return new UntypedMemberExpr( new NameExpr( mem ), sue );
    189                 }
    190 
    191                 Statement * makeAccStatement( DeclarationWithType * object, unsigned long index, const std::string & member, Expression * value, const SymTab::Indexer & indexer ) {
    192                         std::unique_ptr< Expression > expr( makeOpAssign(
    193                                 makeOpMember(
    194                                         makeOpIndex(
    195                                                 object,
    196                                                 index
     185                Expression * makeOpMember( Expression * sue, DeclarationWithType * mem ) {
     186                        return new MemberExpr( mem, sue );
     187                }
     188
     189                Statement * makeAccStatement( DeclarationWithType * object, unsigned long index, DeclarationWithType * member, Expression * value ) {
     190                        return new ExprStmt(
     191                                noLabels,
     192                                makeOpAssign(
     193                                        makeOpMember(
     194                                                makeOpIndex(
     195                                                        object,
     196                                                        index
     197                                                ),
     198                                                member
    197199                                        ),
    198                                         member
    199                                 ),
    200                                 value
    201                         ) );
    202 
    203                         return new ExprStmt( noLabels, ResolvExpr::findVoidExpression( expr.get(), indexer ) );
     200                                        value
     201                                )
     202                        );
    204203                }
    205204
     
    209208                        return new ConstantExpr( Constant::from_bool( ifnull ) );
    210209                }
    211 
    212                 VariableExpr * extractVariable( Expression * func ) {
    213                         if( VariableExpr * var = dynamic_cast< VariableExpr * >( func ) ) {
    214                                 return var;
    215                         }
    216 
    217                         CastExpr * cast = strict_dynamic_cast< CastExpr * >( func );
    218                         return strict_dynamic_cast< VariableExpr * >( cast->arg );
    219                 }
    220 
    221                 Expression * detectIsDtor( Expression * func ) {
    222                         VariableExpr * typed_func = extractVariable( func );
    223                         bool is_dtor = InitTweak::isDestructor( typed_func->var );
    224                         return new ConstantExpr( Constant::from_bool( is_dtor ) );
    225                 }
    226210        };
    227211
     
    232216
    233217        void GenerateWaitForPass::premutate( FunctionDecl * decl) {
    234                 if( decl->name != "__waitfor_internal" ) return;
     218                if( decl->name != "__accept_internal" ) return;
    235219
    236220                decl_waitfor = decl;
     
    243227                        assert( !decl_acceptable );
    244228                        decl_acceptable = decl;
    245                 }
    246                 else if( decl->name == "__waitfor_mask_t" ) {
    247                         assert( !decl_mask );
    248                         decl_mask = decl;
     229                        for( Declaration * field : decl_acceptable->members ) {
     230                                     if( field->name == "func"    ) decl_m_func     = strict_dynamic_cast< DeclarationWithType * >( field );
     231                                else if( field->name == "count"   ) decl_m_count    = strict_dynamic_cast< DeclarationWithType * >( field );
     232                                else if( field->name == "monitor" ) decl_m_monitors = strict_dynamic_cast< DeclarationWithType * >( field );
     233                                else if( field->name == "is_dtor" ) decl_m_isdtor   = strict_dynamic_cast< DeclarationWithType * >( field );
     234                        }
     235
    249236                }
    250237                else if( decl->name == "monitor_desc" ) {
     
    255242
    256243        Statement * GenerateWaitForPass::postmutate( WaitForStmt * waitfor ) {
    257                 if( !decl_monitor || !decl_acceptable || !decl_mask ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor );
     244                return waitfor;
     245
     246                if( !decl_monitor || !decl_acceptable ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor );
    258247
    259248                CompoundStmt * stmt = new CompoundStmt( noLabels );
    260249
    261250                ObjectDecl * acceptables = declare( waitfor->clauses.size(), stmt );
    262                 ObjectDecl * flag        = declareFlag( stmt );
    263                 Statement  * setter      = makeSetter( flag );
    264251
    265252                int index = 0;
    266253                for( auto & clause : waitfor->clauses ) {
    267                         init( acceptables, index, clause, setter, stmt );
     254                        init( acceptables, index, clause, stmt );
    268255
    269256                        index++;
     
    275262                        waitfor->orelse .statement,
    276263                        waitfor->orelse .condition,
    277                         setter,
    278264                        stmt
    279265                );
    280266
    281                 CompoundStmt * compound = new CompoundStmt( noLabels );
    282                 stmt->push_back( new IfStmt(
    283                         noLabels,
    284                         safeCond( new VariableExpr( flag ) ),
    285                         compound,
    286                         nullptr
    287                 ));
    288 
    289                 Expression * result = call( waitfor->clauses.size(), acceptables, timeout, compound );
    290 
    291                 choose( waitfor, result, compound );
     267                // Expression * result  = call( acceptables, timeout, orelse, stmt );
     268
     269                // choose( waitfor, result );
    292270
    293271                return stmt;
     
    296274        ObjectDecl * GenerateWaitForPass::declare( unsigned long count, CompoundStmt * stmt )
    297275        {
    298                 ObjectDecl * acceptables = ObjectDecl::newObject(
     276                ObjectDecl * acceptables = new ObjectDecl(
    299277                        namer_acc.newName(),
     278                        noStorage,
     279                        LinkageSpec::Cforall,
     280                        nullptr,
    300281                        new ArrayType(
    301282                                noQualifiers,
     
    313294                stmt->push_back( new DeclStmt( noLabels, acceptables) );
    314295
    315                 UntypedExpr * set = new UntypedExpr(
    316                         new NameExpr( "__builtin_memset" ),
    317                         {
    318                                 new VariableExpr( acceptables ),
    319                                 new ConstantExpr( Constant::from_int( 0 ) ),
    320                                 new SizeofExpr( new VariableExpr( acceptables ) )
    321                         }
    322                 );
    323 
    324                 Expression * resolved_set = ResolvExpr::findVoidExpression( set, indexer );
    325                 delete set;
    326 
    327                 stmt->push_back( new ExprStmt( noLabels, resolved_set ) );
    328 
    329296                return acceptables;
    330297        }
    331298
    332         ObjectDecl * GenerateWaitForPass::declareFlag( CompoundStmt * stmt ) {
    333                 ObjectDecl * flag = ObjectDecl::newObject(
    334                         namer_flg.newName(),
    335                         new BasicType(
    336                                 noQualifiers,
    337                                 BasicType::Bool
    338                         ),
    339                         new SingleInit( new ConstantExpr( Constant::from_ulong( 0 ) ) )
    340                 );
    341 
    342                 stmt->push_back( new DeclStmt( noLabels, flag) );
    343 
    344                 return flag;
    345         }
    346 
    347         Statement * GenerateWaitForPass::makeSetter( ObjectDecl * flag ) {
    348                 Expression * untyped = new UntypedExpr(
    349                         new NameExpr( "?=?" ),
    350                         {
    351                                 new VariableExpr( flag ),
    352                                 new ConstantExpr( Constant::from_ulong( 1 ) )
    353                         }
    354                 );
    355 
    356                 Expression * expr = ResolvExpr::findVoidExpression( untyped, indexer );
    357                 delete untyped;
    358 
    359                 return new ExprStmt( noLabels, expr );
    360         }
    361 
    362299        ObjectDecl * GenerateWaitForPass::declMon( WaitForStmt::Clause & clause, CompoundStmt * stmt ) {
    363300
    364                 ObjectDecl * mon = ObjectDecl::newObject(
     301                ObjectDecl * mon = new ObjectDecl(
    365302                        namer_mon.newName(),
     303                        noStorage,
     304                        LinkageSpec::Cforall,
     305                        nullptr,
    366306                        new ArrayType(
    367307                                noQualifiers,
    368                                 new PointerType(
     308                                new StructInstType(
    369309                                        noQualifiers,
    370                                         new StructInstType(
    371                                                 noQualifiers,
    372                                                 decl_monitor
    373                                         )
     310                                        decl_monitor
    374311                                ),
    375312                                new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ),
     
    379316                        new ListInit(
    380317                                map_range < std::list<Initializer*> > ( clause.target.arguments, [this](Expression * expr ){
    381                                         Expression * untyped = new CastExpr(
    382                                                 new UntypedExpr(
    383                                                         new NameExpr( "get_monitor" ),
    384                                                         { expr }
    385                                                 ),
    386                                                 new PointerType(
    387                                                         noQualifiers,
    388                                                         new StructInstType(
    389                                                                 noQualifiers,
    390                                                                 decl_monitor
    391                                                         )
    392                                                 )
    393                                         );
    394 
    395                                         Expression * init = ResolvExpr::findSingleExpression( untyped, indexer );
    396                                         delete untyped;
    397                                         return new SingleInit( init );
     318                                        return new SingleInit( expr );
    398319                                })
    399320                        )
     
    405326        }
    406327
    407         void GenerateWaitForPass::init( ObjectDecl * acceptables, int index, WaitForStmt::Clause & clause, Statement * setter, CompoundStmt * stmt ) {
     328        void GenerateWaitForPass::init( ObjectDecl * acceptables, int index, WaitForStmt::Clause & clause, CompoundStmt * stmt ) {
    408329
    409330                ObjectDecl * monitors = declMon( clause, stmt );
    410331
    411                 Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
     332                CompoundStmt * compound = new CompoundStmt( noLabels );
     333                compound->push_back( makeAccStatement( acceptables, index, decl_m_func    , clause.target.function ) );
     334                compound->push_back( makeAccStatement( acceptables, index, decl_m_count   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ) ) );
     335                compound->push_back( makeAccStatement( acceptables, index, decl_m_monitors, new VariableExpr( monitors ) ) );
     336                compound->push_back( makeAccStatement( acceptables, index, decl_m_isdtor  , new ConstantExpr( Constant::from_bool( true ) ) ) );
    412337
    413338                stmt->push_back( new IfStmt(
    414339                        noLabels,
    415340                        safeCond( clause.condition ),
    416                         new CompoundStmt({
    417                                 makeAccStatement( acceptables, index, "is_dtor", detectIsDtor( clause.target.function )                                    , indexer ),
    418                                 makeAccStatement( acceptables, index, "func"   , new CastExpr( clause.target.function, fptr_t )                            , indexer ),
    419                                 makeAccStatement( acceptables, index, "list"   , new VariableExpr( monitors )                                              , indexer ),
    420                                 makeAccStatement( acceptables, index, "size"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ),
    421                                 setter->clone()
    422                         }),
     341                        compound,
    423342                        nullptr
    424343                ));
     
    434353                bool has_else,
    435354                Expression *& else_cond,
    436                 Statement * setter,
    437355                CompoundStmt * stmt
    438356        ) {
    439                 ObjectDecl * timeout = ObjectDecl::newObject(
     357                ObjectDecl * timeout = new ObjectDecl(
    440358                        namer_tim.newName(),
     359                        noStorage,
     360                        LinkageSpec::Cforall,
     361                        nullptr,
    441362                        new BasicType(
    442363                                noQualifiers,
     
    453374                        stmt->push_back( new IfStmt(
    454375                                noLabels,
    455                                 safeCond( time_cond ),
    456                                 new CompoundStmt({
    457                                         new ExprStmt(
    458                                                 noLabels,
    459                                                 makeOpAssign(
    460                                                         new VariableExpr( timeout ),
    461                                                         time
    462                                                 )
    463                                         ),
    464                                         setter->clone()
    465                                 }),
     376                                safeCond( else_cond ),
     377                                new ExprStmt(
     378                                        noLabels,
     379                                        makeOpAssign(
     380                                                new VariableExpr( timeout ),
     381                                                time
     382                                        )
     383                                ),
    466384                                nullptr
    467385                        ));
     
    474392                                noLabels,
    475393                                safeCond( else_cond ),
    476                                 new CompoundStmt({
    477                                         new ExprStmt(
    478                                                 noLabels,
    479                                                 makeOpAssign(
    480                                                         new VariableExpr( timeout ),
    481                                                         new ConstantExpr( Constant::from_ulong( 0 ) )
    482                                                 )
    483                                         ),
    484                                         setter->clone()
    485                                 }),
     394                                new ExprStmt(
     395                                        noLabels,
     396                                        makeOpAssign(
     397                                                new VariableExpr( timeout ),
     398                                                new ConstantExpr( Constant::from_ulong( 0 ) )
     399                                        )
     400                                ),
    486401                                nullptr
    487402                        ));
     
    490405                }
    491406
    492                 delete setter;
    493 
    494407                return new VariableExpr( timeout );
    495         }
    496 
    497         Expression * GenerateWaitForPass::call(
    498                 size_t count,
    499                 ObjectDecl * acceptables,
    500                 Expression * timeout,
    501                 CompoundStmt * stmt
    502         ) {
    503                 ObjectDecl * index = ObjectDecl::newObject(
    504                         namer_idx.newName(),
    505                         new BasicType(
    506                                 noQualifiers,
    507                                 BasicType::ShortSignedInt
    508                         ),
    509                         new SingleInit(
    510                                 new ConstantExpr( Constant::from_int( -1 ) )
    511                         )
    512                 );
    513 
    514                 stmt->push_back( new DeclStmt( noLabels, index ) );
    515 
    516                 ObjectDecl * mask = ObjectDecl::newObject(
    517                         namer_msk.newName(),
    518                         new StructInstType(
    519                                 noQualifiers,
    520                                 decl_mask
    521                         ),
    522                         new ListInit({
    523                                 new SingleInit( new AddressExpr( new VariableExpr( index ) ) ),
    524                                 new SingleInit( new VariableExpr( acceptables ) ),
    525                                 new SingleInit( new ConstantExpr( Constant::from_ulong( count ) ) )
    526                         })
    527                 );
    528 
    529                 stmt->push_back( new DeclStmt( noLabels, mask ) );
    530 
    531                 stmt->push_back( new ExprStmt(
    532                         noLabels,
    533                         new ApplicationExpr(
    534                                 VariableExpr::functionPointer( decl_waitfor ),
    535                                 {
    536                                         new CastExpr(
    537                                                 new VariableExpr( mask ),
    538                                                 new ReferenceType(
    539                                                         noQualifiers,
    540                                                         new StructInstType(
    541                                                                 noQualifiers,
    542                                                                 decl_mask
    543                                                         )
    544                                                 )
    545                                         ),
    546                                         timeout
    547                                 }
    548                         )
    549                 ));
    550 
    551                 return new VariableExpr( index );
    552         }
    553 
    554         void GenerateWaitForPass::choose(
    555                 WaitForStmt * waitfor,
    556                 Expression  * result,
    557                 CompoundStmt * stmt
    558         ) {
    559                 SwitchStmt * swtch = new SwitchStmt(
    560                         noLabels,
    561                         result,
    562                         std::list<Statement *>()
    563                 );
    564 
    565                 unsigned long i = 0;
    566                 for( auto & clause : waitfor->clauses ) {
    567                         swtch->statements.push_back(
    568                                 new CaseStmt(
    569                                         noLabels,
    570                                         new ConstantExpr( Constant::from_ulong( i++ ) ),
    571                                         {
    572                                                 clause.statement,
    573                                                 new BranchStmt(
    574                                                         noLabels,
    575                                                         "",
    576                                                         BranchStmt::Break
    577                                                 )
    578                                         }
    579                                 )
    580                         );
    581                 }
    582 
    583                 if(waitfor->timeout.statement) {
    584                         swtch->statements.push_back(
    585                                 new CaseStmt(
    586                                         noLabels,
    587                                         new ConstantExpr( Constant::from_int( -2 ) ),
    588                                         {
    589                                                 waitfor->timeout.statement,
    590                                                 new BranchStmt(
    591                                                         noLabels,
    592                                                         "",
    593                                                         BranchStmt::Break
    594                                                 )
    595                                         }
    596                                 )
    597                         );
    598                 }
    599 
    600                 if(waitfor->orelse.statement) {
    601                         swtch->statements.push_back(
    602                                 new CaseStmt(
    603                                         noLabels,
    604                                         new ConstantExpr( Constant::from_int( -1 ) ),
    605                                         {
    606                                                 waitfor->orelse.statement,
    607                                                 new BranchStmt(
    608                                                         noLabels,
    609                                                         "",
    610                                                         BranchStmt::Break
    611                                                 )
    612                                         }
    613                                 )
    614                         );
    615                 }
    616 
    617                 stmt->push_back( swtch );
    618408        }
    619409};
  • src/Parser/StatementNode.cc

    rf265042 r1755226  
    234234                target,
    235235                maybeMoveBuild<Statement >( stmt ),
    236                 notZeroExpr( maybeMoveBuild<Expression>( when ) )
     236                maybeMoveBuild<Expression>( when )
    237237        });
    238238
     
    250250        delete targetExpr;
    251251
    252         node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{
     252        node->clauses.push_back( WaitForStmt::Clause{
    253253                std::move( target ),
    254254                maybeMoveBuild<Statement >( stmt ),
    255                 notZeroExpr( maybeMoveBuild<Expression>( when ) )
     255                maybeMoveBuild<Expression>( when )
    256256        });
    257257
     
    265265                node->timeout.time      = maybeMoveBuild<Expression>( timeout );
    266266                node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
    267                 node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
     267                node->timeout.condition = maybeMoveBuild<Expression>( when    );
    268268        }
    269269        else {
    270                 node->orelse.statement  = maybeMoveBuild<Statement >( stmt );
    271                 node->orelse.condition  = notZeroExpr( maybeMoveBuild<Expression>( when ) );
     270                node->orelse.statement  = maybeMoveBuild<Statement >( stmt    );
     271                node->orelse.condition  = maybeMoveBuild<Expression>( when    );
    272272        }
    273273
     
    280280        node->timeout.time      = maybeMoveBuild<Expression>( timeout );
    281281        node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
    282         node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
     282        node->timeout.condition = maybeMoveBuild<Expression>( when    );
    283283
    284284        node->orelse.statement = maybeMoveBuild<Statement >( else_stmt );
    285         node->orelse.condition  = notZeroExpr( maybeMoveBuild<Expression>( else_when ) );
     285        node->orelse.condition = maybeMoveBuild<Expression>( else_when );
    286286
    287287        return node;
    288288}
     289
     290// WaitForStmt::Target build_waitfor( const std::string * name, ExpressionNode * arguments ) {
     291//       return WaitForStmt::Clause{
     292
     293//       };
     294// }
    289295
    290296Statement *build_compound( StatementNode *first ) {
  • src/Parser/parserutility.cc

    rf265042 r1755226  
    2929
    3030Expression *notZeroExpr( Expression *orig ) {
    31         if( !orig ) return nullptr;
    3231        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    3332        comparison->get_args().push_back( orig );
  • src/ResolvExpr/AlternativeFinder.cc

    rf265042 r1755226  
    144144                        expr->get_result()->accept( global_renamer );
    145145                }
     146
     147                void referenceToRvalueConversion( Expression *& expr ) {
     148                        if ( dynamic_cast< ReferenceType * >( expr->get_result() ) ) {
     149                                // cast away reference from expr
     150                                expr = new CastExpr( expr, expr->get_result()->stripReferences()->clone() );
     151                        }
     152                }
    146153        } // namespace
    147 
    148         void referenceToRvalueConversion( Expression *& expr ) {
    149                 if ( dynamic_cast< ReferenceType * >( expr->get_result() ) ) {
    150                         // cast away reference from expr
    151                         expr = new CastExpr( expr, expr->get_result()->stripReferences()->clone() );
    152                 }
    153         }
    154154
    155155        template< typename InputIterator, typename OutputIterator >
  • src/ResolvExpr/AlternativeFinder.h

    rf265042 r1755226  
    5050                const SymTab::Indexer &get_indexer() const { return indexer; }
    5151                const TypeEnvironment &get_environ() const { return env; }
    52 
    53                 /// Runs a new alternative finder on each element in [begin, end)
    54                 /// and writes each alternative finder to out.
    55                 template< typename InputIterator, typename OutputIterator >
    56                 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    5752          private:
    5853                virtual void visit( ApplicationExpr *applicationExpr );
     
    8681                virtual void visit( StmtExpr *stmtExpr );
    8782                virtual void visit( UntypedInitExpr *initExpr );
     83                /// Runs a new alternative finder on each element in [begin, end)
     84                /// and writes each alternative finder to out.
     85                template< typename InputIterator, typename OutputIterator >
     86                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    8887
    8988                /// Adds alternatives for anonymous members
     
    109108
    110109        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
    111         void referenceToRvalueConversion( Expression *& expr );
    112110
    113111        template< typename InputIterator, typename OutputIterator >
  • src/ResolvExpr/Resolver.cc

    rf265042 r1755226  
    4040#include "SynTree/Visitor.h"             // for acceptAll, maybeAccept
    4141#include "typeops.h"                     // for extractResultType
    42 #include "Unify.h"                       // for unify
    4342
    4443using namespace std;
     
    7271                void previsit( ThrowStmt *throwStmt );
    7372                void previsit( CatchStmt *catchStmt );
    74                 void previsit( WaitForStmt * stmt );
    7573
    7674                void previsit( SingleInit *singleInit );
     
    123121        }
    124122
    125         Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
    126                 TypeEnvironment env;
    127                 AlternativeFinder finder( indexer, env );
    128                 finder.find( untyped );
    129                 #if 0
    130                 if ( finder.get_alternatives().size() != 1 ) {
    131                         std::cout << "untyped expr is ";
    132                         untyped->print( std::cout );
    133                         std::cout << std::endl << "alternatives are:";
    134                         for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    135                                 i->print( std::cout );
    136                         } // for
    137                 } // if
    138                 #endif
    139                 assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." );
    140                 Alternative &choice = finder.get_alternatives().front();
    141                 Expression *newExpr = choice.expr->clone();
    142                 finishExpr( newExpr, choice.env );
    143                 return newExpr;
    144         }
    145 
    146123        namespace {
     124                Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
     125                        TypeEnvironment env;
     126                        AlternativeFinder finder( indexer, env );
     127                        finder.find( untyped );
     128#if 0
     129                        if ( finder.get_alternatives().size() != 1 ) {
     130                                std::cout << "untyped expr is ";
     131                                untyped->print( std::cout );
     132                                std::cout << std::endl << "alternatives are:";
     133                                for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
     134                                        i->print( std::cout );
     135                                } // for
     136                        } // if
     137#endif
     138                        assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." );
     139                        Alternative &choice = finder.get_alternatives().front();
     140                        Expression *newExpr = choice.expr->clone();
     141                        finishExpr( newExpr, choice.env );
     142                        return newExpr;
     143                }
     144
    147145                bool isIntegralType( Type *type ) {
    148146                        if ( dynamic_cast< EnumInstType * >( type ) ) {
     
    398396        }
    399397
    400         inline void resolveAsIf( Expression *& expr, SymTab::Indexer & indexer ) {
    401                 if( !expr ) return;
    402                 Expression * newExpr = findSingleExpression( expr, indexer );
    403                 delete expr;
    404                 expr = newExpr;
    405         }
    406 
    407         inline void resolveAsType( Expression *& expr, Type * type, SymTab::Indexer & indexer ) {
    408                 if( !expr ) return;
    409                 Expression * newExpr = findSingleExpression( new CastExpr( expr, type ), indexer );
    410                 delete expr;
    411                 expr = newExpr;
    412         }
    413 
    414         template< typename iterator_t >
    415         inline bool advance_to_mutex( iterator_t & it, const iterator_t & end ) {
    416                 while( it != end && !(*it)->get_type()->get_mutex() ) {
    417                         it++;
    418                 }
    419 
    420                 return it != end;
    421         }
    422 
    423         void Resolver::previsit( WaitForStmt * stmt ) {
    424                 visit_children = false;
    425 
    426                 // Resolve all clauses first
    427                 for( auto& clause : stmt->clauses ) {
    428 
    429                         TypeEnvironment env;
    430                         AlternativeFinder funcFinder( indexer, env );
    431 
    432                         // Find all alternatives for a function in canonical form
    433                         funcFinder.findWithAdjustment( clause.target.function );
    434 
    435                         if ( funcFinder.get_alternatives().empty() ) {
    436                                 stringstream ss;
    437                                 ss << "Use of undeclared indentifier '";
    438                                 ss << strict_dynamic_cast<NameExpr*>( clause.target.function )->name;
    439                                 ss << "' in call to waitfor";
    440                                 throw SemanticError( ss.str() );
    441                         }
    442 
    443                         // Find all alternatives for all arguments in canonical form
    444                         std::list< AlternativeFinder > argAlternatives;
    445                         funcFinder.findSubExprs( clause.target.arguments.begin(), clause.target.arguments.end(), back_inserter( argAlternatives ) );
    446 
    447                         // List all combinations of arguments
    448                         std::list< AltList > possibilities;
    449                         combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) );
    450 
    451                         AltList                func_candidates;
    452                         std::vector< AltList > args_candidates;
    453 
    454                         // For every possible function :
    455                         //      try matching the arguments to the parameters
    456                         //      not the other way around because we have more arguments than parameters
    457                         SemanticError errors;
    458                         for ( Alternative & func : funcFinder.get_alternatives() ) {
    459                                 try {
    460                                         PointerType * pointer = dynamic_cast< PointerType* >( func.expr->get_result()->stripReferences() );
    461                                         if( !pointer ) {
    462                                                 throw SemanticError( "candidate not viable: not a pointer type\n", func.expr->get_result() );
    463                                         }
    464 
    465                                         FunctionType * function = dynamic_cast< FunctionType* >( pointer->get_base() );
    466                                         if( !function ) {
    467                                                 throw SemanticError( "candidate not viable: not a function type\n", pointer->get_base() );
    468                                         }
    469 
    470 
    471                                         {
    472                                                 auto param     = function->parameters.begin();
    473                                                 auto param_end = function->parameters.end();
    474 
    475                                                 if( !advance_to_mutex( param, param_end ) ) {
    476                                                         throw SemanticError("candidate function not viable: no mutex parameters\n", function);
    477                                                 }
    478                                         }
    479 
    480                                         Alternative newFunc( func );
    481                                         // Strip reference from function
    482                                         referenceToRvalueConversion( newFunc.expr );
    483 
    484                                         // For all the set of arguments we have try to match it with the parameter of the current function alternative
    485                                         for ( auto & argsList : possibilities ) {
    486 
    487                                                 try {
    488                                                         // Declare data structures need for resolution
    489                                                         OpenVarSet openVars;
    490                                                         AssertionSet resultNeed, resultHave;
    491                                                         TypeEnvironment resultEnv;
    492 
    493                                                         // Load type variables from arguemnts into one shared space
    494                                                         simpleCombineEnvironments( argsList.begin(), argsList.end(), resultEnv );
    495 
    496                                                         // Make sure we don't widen any existing bindings
    497                                                         for ( auto & i : resultEnv ) {
    498                                                                 i.allowWidening = false;
    499                                                         }
    500 
    501                                                         // Find any unbound type variables
    502                                                         resultEnv.extractOpenVars( openVars );
    503 
    504                                                         auto param     = function->parameters.begin();
    505                                                         auto param_end = function->parameters.end();
    506 
    507                                                         // For every arguments of its set, check if it matches one of the parameter
    508                                                         // The order is important
    509                                                         for( auto & arg : argsList ) {
    510 
    511                                                                 // Ignore non-mutex arguments
    512                                                                 if( !advance_to_mutex( param, param_end ) ) {
    513                                                                         // We ran out of parameters but still have arguments
    514                                                                         // this function doesn't match
    515                                                                         throw SemanticError("candidate function not viable: too many mutex arguments\n", function);
    516                                                                 }
    517 
    518                                                                 // Check if the argument matches the parameter type in the current scope
    519                                                                 if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) {
    520                                                                         // Type doesn't match
    521                                                                         stringstream ss;
    522                                                                         ss << "candidate function not viable: no known convertion from '";
    523                                                                         arg.expr->get_result()->print( ss );
    524                                                                         ss << "' to '";
    525                                                                         (*param)->get_type()->print( ss );
    526                                                                         ss << "'\n";
    527                                                                         throw SemanticError(ss.str(), function);
    528                                                                 }
    529 
    530                                                                 param++;
    531                                                         }
    532 
    533                                                         // All arguments match !
    534 
    535                                                         // Check if parameters are missing
    536                                                         if( advance_to_mutex( param, param_end ) ) {
    537                                                                 // We ran out of arguments but still have parameters left
    538                                                                 // this function doesn't match
    539                                                                 throw SemanticError("candidate function not viable: too few mutex arguments\n", function);
    540                                                         }
    541 
    542                                                         // All parameters match !
    543 
    544                                                         // Finish the expressions to tie in the proper environments
    545                                                         finishExpr( newFunc.expr, resultEnv );
    546                                                         for( Alternative & alt : argsList ) {
    547                                                                 finishExpr( alt.expr, resultEnv );
    548                                                         }
    549 
    550                                                         // This is a match store it and save it for later
    551                                                         func_candidates.push_back( newFunc );
    552                                                         args_candidates.push_back( argsList );
    553 
    554                                                 }
    555                                                 catch( SemanticError &e ) {
    556                                                         errors.append( e );
    557                                                 }
    558                                         }
    559                                 }
    560                                 catch( SemanticError &e ) {
    561                                         errors.append( e );
    562                                 }
    563                         }
    564 
    565                         // Make sure we got the right number of arguments
    566                         if( func_candidates.empty() )    { SemanticError top( "No alternatives for function in call to waitfor"  ); top.append( errors ); throw top; }
    567                         if( args_candidates.empty() )    { SemanticError top( "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; }
    568                         if( func_candidates.size() > 1 ) { SemanticError top( "Ambiguous function in call to waitfor"            ); top.append( errors ); throw top; }
    569                         if( args_candidates.size() > 1 ) { SemanticError top( "Ambiguous arguments in call to waitfor"           ); top.append( errors ); throw top; }
    570 
    571 
    572                         // Swap the results from the alternative with the unresolved values.
    573                         // Alternatives will handle deletion on destruction
    574                         std::swap( clause.target.function, func_candidates.front().expr );
    575                         for( auto arg_pair : group_iterate( clause.target.arguments, args_candidates.front() ) ) {
    576                                 std::swap ( std::get<0>( arg_pair), std::get<1>( arg_pair).expr );
    577                         }
    578 
    579                         // Resolve the conditions as if it were an IfStmt
    580                         // Resolve the statments normally
    581                         resolveAsIf( clause.condition, this->indexer );
    582                         clause.statement->accept( *visitor );
    583                 }
    584 
    585 
    586                 if( stmt->timeout.statement ) {
    587                         // Resolve the timeout as an size_t for now
    588                         // Resolve the conditions as if it were an IfStmt
    589                         // Resolve the statments normally
    590                         resolveAsType( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), this->indexer );
    591                         resolveAsIf  ( stmt->timeout.condition, this->indexer );
    592                         stmt->timeout.statement->accept( *visitor );
    593                 }
    594 
    595                 if( stmt->orelse.statement ) {
    596                         // Resolve the conditions as if it were an IfStmt
    597                         // Resolve the statments normally
    598                         resolveAsIf( stmt->orelse.condition, this->indexer );
    599                         stmt->orelse.statement->accept( *visitor );
    600                 }
    601         }
    602 
    603398        template< typename T >
    604399        bool isCharType( T t ) {
  • src/ResolvExpr/Resolver.h

    rf265042 r1755226  
    3232        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
    3333        Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
    34         Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer );
    3534        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    3635        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
  • src/SymTab/Mangler.cc

    rf265042 r1755226  
    307307                        mangleName << "V";
    308308                } // if
    309                 if ( type->get_mutex() ) {
    310                         mangleName << "M";
    311                 } // if
    312309                // Removed due to restrict not affecting function compatibility in GCC
    313310//              if ( type->get_isRestrict() ) {
  • src/SynTree/BaseSyntaxNode.h

    rf265042 r1755226  
    2626
    2727        virtual void accept( Visitor & v ) = 0;
    28         virtual void print( std::ostream & os, int indent = 0 ) const = 0;
     28  virtual void print( std::ostream & os, int indent = 0 ) const = 0;
    2929};
    30 
    31 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node );
    3230
    3331// Local Variables: //
  • src/SynTree/CompoundStmt.cc

    rf265042 r1755226  
    2929
    3030CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) {
    31 }
    32 
    33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement( noLabels ), kids( stmts ) {
    3431}
    3532
  • src/SynTree/Constant.cc

    rf265042 r1755226  
    3232Constant Constant::from_bool( bool b ) {
    3333        return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b );
    34 }
    35 
    36 Constant Constant::from_char( char c ) {
    37         return Constant( new BasicType( Type::Qualifiers(), BasicType::Char ), std::to_string( c ), (unsigned long long int)c );
    3834}
    3935
  • src/SynTree/Constant.h

    rf265042 r1755226  
    4040        /// generates a boolean constant of the given bool
    4141        static Constant from_bool( bool b );
    42         /// generates a char constant of the given char
    43         static Constant from_char( char c );
    4442        /// generates an integer constant of the given int
    4543        static Constant from_int( int i );
  • src/SynTree/Declaration.cc

    rf265042 r1755226  
    5959}
    6060
     61std::ostream & operator<<( std::ostream & out, const Declaration * decl ) {
     62        if ( decl ){
     63                decl->print( out );
     64        } else {
     65                out << "nullptr";
     66        }
     67        return out;
     68}
     69
    6170
    6271AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
  • src/SynTree/Declaration.h

    rf265042 r1755226  
    6262        void fixUniqueId( void );
    6363        virtual Declaration *clone() const = 0;
    64         virtual void accept( Visitor &v ) override = 0;
     64        virtual void accept( Visitor &v ) = 0;
    6565        virtual Declaration *acceptMutator( Mutator &m ) = 0;
    66         virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
     66        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    6767        virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
    6868
     
    106106        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    107107
    108         virtual DeclarationWithType *clone() const override = 0;
    109         virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
     108        virtual DeclarationWithType *clone() const = 0;
     109        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    110110
    111111        virtual Type * get_type() const = 0;
     
    128128        virtual ~ObjectDecl();
    129129
    130         virtual Type * get_type() const override { return type; }
    131         virtual void set_type(Type *newType) override { type = newType; }
     130        virtual Type * get_type() const { return type; }
     131        virtual void set_type(Type *newType) { type = newType; }
    132132
    133133        Initializer *get_init() const { return init; }
     
    139139        static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
    140140
    141         virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); }
    142         virtual void accept( Visitor &v ) override { v.visit( this ); }
    143         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    144         virtual void print( std::ostream &os, int indent = 0 ) const override;
    145         virtual void printShort( std::ostream &os, int indent = 0 ) const override;
     141        virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }
     142        virtual void accept( Visitor &v ) { v.visit( this ); }
     143        virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     144        virtual void print( std::ostream &os, int indent = 0 ) const;
     145        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    146146};
    147147
     
    157157        virtual ~FunctionDecl();
    158158
    159         virtual Type * get_type() const override { return type; }
    160         virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); }
     159        Type * get_type() const { return type; }
     160        virtual void set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); }
    161161
    162162        FunctionType * get_functionType() const { return type; }
     
    165165        void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    166166
    167         virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
    168         virtual void accept( Visitor &v ) override { v.visit( this ); }
    169         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    170         virtual void print( std::ostream &os, int indent = 0 ) const override;
    171         virtual void printShort( std::ostream &os, int indent = 0 ) const override;
     167        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     168        virtual void accept( Visitor &v ) { v.visit( this ); }
     169        virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     170        virtual void print( std::ostream &os, int indent = 0 ) const;
     171        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    172172};
    173173
     
    190190        virtual std::string typeString() const = 0;
    191191
    192         virtual NamedTypeDecl *clone() const override = 0;
    193         virtual void print( std::ostream &os, int indent = 0 ) const override;
    194         virtual void printShort( std::ostream &os, int indent = 0 ) const override;
     192        virtual NamedTypeDecl *clone() const = 0;
     193        virtual void print( std::ostream &os, int indent = 0 ) const;
     194        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    195195};
    196196
     
    227227        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    228228
    229         virtual std::string typeString() const override;
     229        virtual std::string typeString() const;
    230230        virtual std::string genTypeString() const;
    231231
    232         virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
    233         virtual void accept( Visitor &v ) override { v.visit( this ); }
    234         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    235         virtual void print( std::ostream &os, int indent = 0 ) const override;
     232        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
     233        virtual void accept( Visitor &v ) { v.visit( this ); }
     234        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     235        virtual void print( std::ostream &os, int indent = 0 ) const;
    236236
    237237  private:
     
    245245        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    246246
    247         virtual std::string typeString() const override;
    248 
    249         virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
    250         virtual void accept( Visitor &v ) override { v.visit( this ); }
    251         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     247        virtual std::string typeString() const;
     248
     249        virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
     250        virtual void accept( Visitor &v ) { v.visit( this ); }
     251        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    252252  private:
    253253};
     
    274274        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    275275
    276         virtual void print( std::ostream &os, int indent = 0 ) const override;
    277         virtual void printShort( std::ostream &os, int indent = 0 ) const override;
     276        virtual void print( std::ostream &os, int indent = 0 ) const;
     277        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    278278  protected:
    279279        virtual std::string typeString() const = 0;
     
    290290        bool is_thread() { return kind == DeclarationNode::Thread; }
    291291
    292         virtual StructDecl *clone() const override { return new StructDecl( *this ); }
    293         virtual void accept( Visitor &v ) override { v.visit( this ); }
    294         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     292        virtual StructDecl *clone() const { return new StructDecl( *this ); }
     293        virtual void accept( Visitor &v ) { v.visit( this ); }
     294        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    295295  private:
    296296        DeclarationNode::Aggregate kind;
    297         virtual std::string typeString() const override;
     297        virtual std::string typeString() const;
    298298};
    299299
     
    304304        UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    305305
    306         virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
    307         virtual void accept( Visitor &v ) override { v.visit( this ); }
    308         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    309   private:
    310         virtual std::string typeString() const override;
     306        virtual UnionDecl *clone() const { return new UnionDecl( *this ); }
     307        virtual void accept( Visitor &v ) { v.visit( this ); }
     308        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     309  private:
     310        virtual std::string typeString() const;
    311311};
    312312
     
    317317        EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    318318
    319         virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
    320         virtual void accept( Visitor &v ) override { v.visit( this ); }
    321         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    322   private:
    323         virtual std::string typeString() const override;
     319        virtual EnumDecl *clone() const { return new EnumDecl( *this ); }
     320        virtual void accept( Visitor &v ) { v.visit( this ); }
     321        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     322  private:
     323        virtual std::string typeString() const;
    324324};
    325325
     
    332332        TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    333333
    334         virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
    335         virtual void accept( Visitor &v ) override { v.visit( this ); }
    336         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    337   private:
    338         virtual std::string typeString() const override;
     334        virtual TraitDecl *clone() const { return new TraitDecl( *this ); }
     335        virtual void accept( Visitor &v ) { v.visit( this ); }
     336        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     337  private:
     338        virtual std::string typeString() const;
    339339};
    340340
     
    350350        void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    351351
    352         virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
    353         virtual void accept( Visitor &v ) override { v.visit( this ); }
    354         virtual AsmDecl *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    355         virtual void print( std::ostream &os, int indent = 0 ) const override;
    356         virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    357 };
    358 
     352        virtual AsmDecl *clone() const { return new AsmDecl( *this ); }
     353        virtual void accept( Visitor &v ) { v.visit( this ); }
     354        virtual AsmDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     355        virtual void print( std::ostream &os, int indent = 0 ) const;
     356        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     357};
     358
     359std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    359360std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    360361
  • src/SynTree/Expression.cc

    rf265042 r1755226  
    741741}
    742742
     743
     744std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
     745        if ( expr ) {
     746                expr->print( out );
     747        } else {
     748                out << "nullptr";
     749        }
     750        return out;
     751}
     752
    743753// Local Variables: //
    744754// tab-width: 4 //
  • src/SynTree/Expression.h

    rf265042 r1755226  
    821821};
    822822
     823
     824std::ostream & operator<<( std::ostream & out, const Expression * expr );
     825
    823826// Local Variables: //
    824827// tab-width: 4 //
  • src/SynTree/Initializer.cc

    rf265042 r1755226  
    137137}
    138138
     139std::ostream & operator<<( std::ostream & out, const Initializer * init ) {
     140        if ( init ) {
     141                init->print( out );
     142        } else {
     143                out << "nullptr";
     144        }
     145        return out;
     146}
     147
     148std::ostream & operator<<( std::ostream & out, const Designation * des ) {
     149        if ( des ) {
     150                des->print( out );
     151        } else {
     152                out << "nullptr";
     153        }
     154        return out;
     155}
     156
    139157// Local Variables: //
    140158// tab-width: 4 //
  • src/SynTree/Initializer.h

    rf265042 r1755226  
    3838
    3939        virtual Designation * clone() const { return new Designation( *this ); };
    40         virtual void accept( Visitor &v ) override { v.visit( this ); }
     40        virtual void accept( Visitor &v ) { v.visit( this ); }
    4141        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
    42         virtual void print( std::ostream &os, int indent = 0 ) const override;
     42        virtual void print( std::ostream &os, int indent = 0 ) const;
    4343};
    4444
     
    5555
    5656        virtual Initializer *clone() const = 0;
    57         virtual void accept( Visitor &v ) override = 0;
     57        virtual void accept( Visitor &v ) = 0;
    5858        virtual Initializer *acceptMutator( Mutator &m ) = 0;
    59         virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
     59        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    6060  private:
    6161        bool maybeConstructed;
     
    7575        void set_value( Expression *newValue ) { value = newValue; }
    7676
    77         virtual SingleInit *clone() const override { return new SingleInit( *this); }
    78         virtual void accept( Visitor &v ) override { v.visit( this ); }
    79         virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    80         virtual void print( std::ostream &os, int indent = 0 ) const override;
     77        virtual SingleInit *clone() const { return new SingleInit( *this); }
     78        virtual void accept( Visitor &v ) { v.visit( this ); }
     79        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     80        virtual void print( std::ostream &os, int indent = 0 ) const;
    8181};
    8282
     
    103103        const_iterator end() const { return initializers.end(); }
    104104
    105         virtual ListInit *clone() const override { return new ListInit( *this ); }
    106         virtual void accept( Visitor &v ) override { v.visit( this ); }
    107         virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    108         virtual void print( std::ostream &os, int indent = 0 ) const override;
     105        virtual ListInit *clone() const { return new ListInit( *this ); }
     106        virtual void accept( Visitor &v ) { v.visit( this ); }
     107        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     108        virtual void print( std::ostream &os, int indent = 0 ) const;
    109109};
    110110
     
    129129        Initializer * get_init() const { return init; }
    130130
    131         ConstructorInit *clone() const override { return new ConstructorInit( *this ); }
    132         virtual void accept( Visitor &v ) override { v.visit( this ); }
    133         virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    134         virtual void print( std::ostream &os, int indent = 0 ) const override;
     131        ConstructorInit *clone() const { return new ConstructorInit( *this ); }
     132        virtual void accept( Visitor &v ) { v.visit( this ); }
     133        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     134        virtual void print( std::ostream &os, int indent = 0 ) const;
    135135
    136136  private:
     
    140140};
    141141
     142std::ostream & operator<<( std::ostream & out, const Initializer * init );
     143std::ostream & operator<<( std::ostream & out, const Designation * des );
     144
    142145// Local Variables: //
    143146// tab-width: 4 //
  • src/SynTree/Statement.cc

    rf265042 r1755226  
    168168}
    169169
    170 SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, const std::list<Statement *> &statements ):
     170SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, std::list<Statement *> &statements ):
    171171        Statement( labels ), condition( condition ), statements( statements ) {
    172172}
     
    196196}
    197197
    198 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
     198CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    199199        Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    200200        if ( isDefault() && condition != 0 )
     
    497497}
    498498
     499std::ostream & operator<<( std::ostream & out, const Statement * statement ) {
     500        if ( statement ) {
     501                statement->print( out );
     502        } else {
     503                out << "nullptr";
     504        }
     505        return out;
     506}
     507
    499508// Local Variables: //
    500509// tab-width: 4 //
  • src/SynTree/Statement.h

    rf265042 r1755226  
    4444
    4545        virtual Statement *clone() const = 0;
    46         virtual void accept( Visitor &v ) override = 0;
     46        virtual void accept( Visitor &v ) = 0;
    4747        virtual Statement *acceptMutator( Mutator &m ) = 0;
    48         virtual void print( std::ostream &os, int indent = 0 ) const override;
     48        virtual void print( std::ostream &os, int indent = 0 ) const;
    4949};
    5050
     
    5454
    5555        CompoundStmt( std::list<Label> labels );
    56         CompoundStmt( std::list<Statement *> stmts );
    5756        CompoundStmt( const CompoundStmt &other );
    5857        virtual ~CompoundStmt();
     
    6261        void push_front( Statement * stmt ) { kids.push_front( stmt ); }
    6362
    64         virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
    65         virtual void accept( Visitor &v ) override { v.visit( this ); }
    66         virtual CompoundStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    67         virtual void print( std::ostream &os, int indent = 0 ) const override;
     63        virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
     64        virtual void accept( Visitor &v ) { v.visit( this ); }
     65        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     66        virtual void print( std::ostream &os, int indent = 0 ) const;
    6867};
    6968
     
    7372        NullStmt( std::list<Label> labels );
    7473
    75         virtual NullStmt *clone() const override { return new NullStmt( *this ); }
    76         virtual void accept( Visitor &v ) override { v.visit( this ); }
    77         virtual NullStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    78         virtual void print( std::ostream &os, int indent = 0 ) const override;
     74        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     75        virtual void accept( Visitor &v ) { v.visit( this ); }
     76        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     77        virtual void print( std::ostream &os, int indent = 0 ) const;
    7978};
    8079
     
    9089        void set_expr( Expression *newValue ) { expr = newValue; }
    9190
    92         virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
    93         virtual void accept( Visitor &v ) override { v.visit( this ); }
    94         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    95         virtual void print( std::ostream &os, int indent = 0 ) const override;
     91        virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
     92        virtual void accept( Visitor &v ) { v.visit( this ); }
     93        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     94        virtual void print( std::ostream &os, int indent = 0 ) const;
    9695};
    9796
     
    147146        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    148147
    149         virtual IfStmt *clone() const override { return new IfStmt( *this ); }
    150         virtual void accept( Visitor &v ) override { v.visit( this ); }
    151         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    152         virtual void print( std::ostream &os, int indent = 0 ) const override;
     148        virtual IfStmt *clone() const { return new IfStmt( *this ); }
     149        virtual void accept( Visitor &v ) { v.visit( this ); }
     150        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     151        virtual void print( std::ostream &os, int indent = 0 ) const;
    153152};
    154153
     
    158157        std::list<Statement *> statements;
    159158
    160         SwitchStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements );
     159        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    161160        SwitchStmt( const SwitchStmt &other );
    162161        virtual ~SwitchStmt();
     
    167166        std::list<Statement *> & get_statements() { return statements; }
    168167
    169         virtual void accept( Visitor &v ) override { v.visit( this ); }
    170         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    171 
    172         virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
    173         virtual void print( std::ostream &os, int indent = 0 ) const override;
     168        virtual void accept( Visitor &v ) { v.visit( this ); }
     169        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     170
     171        virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
     172        virtual void print( std::ostream &os, int indent = 0 ) const;
    174173
    175174};
     
    180179        std::list<Statement *> stmts;
    181180
    182         CaseStmt( std::list<Label> labels, Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     181        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    183182        CaseStmt( const CaseStmt &other );
    184183        virtual ~CaseStmt();
     
    195194        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    196195
    197         virtual void accept( Visitor &v ) override { v.visit( this ); }
    198         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    199 
    200         virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
    201         virtual void print( std::ostream &os, int indent = 0 ) const override;
     196        virtual void accept( Visitor &v ) { v.visit( this ); }
     197        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     198
     199        virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
     200        virtual void print( std::ostream &os, int indent = 0 ) const;
    202201  private:
    203202        bool _isDefault;
     
    222221        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    223222
    224         virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
    225         virtual void accept( Visitor &v ) override { v.visit( this ); }
    226         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    227         virtual void print( std::ostream &os, int indent = 0 ) const override;
     223        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
     224        virtual void accept( Visitor &v ) { v.visit( this ); }
     225        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     226        virtual void print( std::ostream &os, int indent = 0 ) const;
    228227};
    229228
     
    248247        void set_body( Statement *newValue ) { body = newValue; }
    249248
    250         virtual ForStmt *clone() const override { return new ForStmt( *this ); }
    251         virtual void accept( Visitor &v ) override { v.visit( this ); }
    252         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    253         virtual void print( std::ostream &os, int indent = 0 ) const override;
     249        virtual ForStmt *clone() const { return new ForStmt( *this ); }
     250        virtual void accept( Visitor &v ) { v.visit( this ); }
     251        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     252        virtual void print( std::ostream &os, int indent = 0 ) const;
    254253};
    255254
     
    277276        const char *get_typename() { return brType[ type ]; }
    278277
    279         virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
    280         virtual void accept( Visitor &v ) override { v.visit( this ); }
    281         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    282         virtual void print( std::ostream &os, int indent = 0 ) const override;
     278        virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
     279        virtual void accept( Visitor &v ) { v.visit( this ); }
     280        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     281        virtual void print( std::ostream &os, int indent = 0 ) const;
    283282  private:
    284283        static const char *brType[];
     
    296295        void set_expr( Expression *newValue ) { expr = newValue; }
    297296
    298         virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
    299         virtual void accept( Visitor &v ) override { v.visit( this ); }
    300         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    301         virtual void print( std::ostream &os, int indent = 0 ) const override;
     297        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
     298        virtual void accept( Visitor &v ) { v.visit( this ); }
     299        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     300        virtual void print( std::ostream &os, int indent = 0 ) const;
    302301};
    303302
     
    320319        void set_target( Expression * newTarget ) { target = newTarget; }
    321320
    322         virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
    323         virtual void accept( Visitor &v ) override { v.visit( this ); }
    324         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    325         virtual void print( std::ostream &os, int indent = 0 ) const override;
     321        virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); }
     322        virtual void accept( Visitor &v ) { v.visit( this ); }
     323        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     324        virtual void print( std::ostream &os, int indent = 0 ) const;
    326325};
    327326
     
    343342        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    344343
    345         virtual TryStmt *clone() const override { return new TryStmt( *this ); }
    346         virtual void accept( Visitor &v ) override { v.visit( this ); }
    347         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    348         virtual void print( std::ostream &os, int indent = 0 ) const override;
     344        virtual TryStmt *clone() const { return new TryStmt( *this ); }
     345        virtual void accept( Visitor &v ) { v.visit( this ); }
     346        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     347        virtual void print( std::ostream &os, int indent = 0 ) const;
    349348};
    350349
     
    371370        void set_body( Statement *newValue ) { body = newValue; }
    372371
    373         virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
    374         virtual void accept( Visitor &v ) override { v.visit( this ); }
    375         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    376         virtual void print( std::ostream &os, int indent = 0 ) const override;
     372        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
     373        virtual void accept( Visitor &v ) { v.visit( this ); }
     374        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     375        virtual void print( std::ostream &os, int indent = 0 ) const;
    377376};
    378377
     
    388387        void set_block( CompoundStmt *newValue ) { block = newValue; }
    389388
    390         virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
    391         virtual void accept( Visitor &v ) override { v.visit( this ); }
    392         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    393         virtual void print( std::ostream &os, int indent = 0 ) const override;
     389        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
     390        virtual void accept( Visitor &v ) { v.visit( this ); }
     391        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     392        virtual void print( std::ostream &os, int indent = 0 ) const;
    394393};
    395394
     
    425424        } orelse;
    426425
    427         virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
    428         virtual void accept( Visitor &v ) override { v.visit( this ); }
    429         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    430         virtual void print( std::ostream &os, int indent = 0 ) const override;
     426        virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); }
     427        virtual void accept( Visitor &v ) { v.visit( this ); }
     428        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     429        virtual void print( std::ostream &os, int indent = 0 ) const;
    431430
    432431};
     
    445444        void set_decl( Declaration *newValue ) { decl = newValue; }
    446445
    447         virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
    448         virtual void accept( Visitor &v ) override { v.visit( this ); }
    449         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    450         virtual void print( std::ostream &os, int indent = 0 ) const override;
     446        virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
     447        virtual void accept( Visitor &v ) { v.visit( this ); }
     448        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     449        virtual void print( std::ostream &os, int indent = 0 ) const;
    451450};
    452451
     
    467466        void set_callStmt( Statement * newValue ) { callStmt = newValue; }
    468467
    469         virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
    470         virtual void accept( Visitor &v ) override { v.visit( this ); }
    471         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    472         virtual void print( std::ostream &os, int indent = 0 ) const override;
    473 };
     468        virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
     469        virtual void accept( Visitor &v ) { v.visit( this ); }
     470        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     471        virtual void print( std::ostream &os, int indent = 0 ) const;
     472};
     473
     474
     475std::ostream & operator<<( std::ostream & out, const Statement * statement );
    474476
    475477// Local Variables: //
  • src/SynTree/Type.cc

    rf265042 r1755226  
    9999const Type::Qualifiers noQualifiers;
    100100
     101std::ostream & operator<<( std::ostream & out, const Type * type ) {
     102        if ( type ) {
     103                type->print( out );
     104        } else {
     105                out << "nullptr";
     106        } // if
     107        return out;
     108}
     109
    101110// Local Variables: //
    102111// tab-width: 4 //
  • src/SynTree/Type.h

    rf265042 r1755226  
    192192        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    193193
    194         virtual unsigned size() const override { return 0; };
    195         virtual bool isComplete() const override { return false; }
    196 
    197         virtual VoidType *clone() const override { return new VoidType( *this ); }
    198         virtual void accept( Visitor & v ) override { v.visit( this ); }
    199         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    200         virtual void print( std::ostream & os, int indent = 0 ) const override;
     194        virtual unsigned size() const { return 0; };
     195        virtual bool isComplete() const { return false; }
     196
     197        virtual VoidType *clone() const { return new VoidType( *this ); }
     198        virtual void accept( Visitor & v ) { v.visit( this ); }
     199        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     200        virtual void print( std::ostream & os, int indent = 0 ) const;
    201201};
    202202
     
    235235        void set_kind( Kind newValue ) { kind = newValue; }
    236236
    237         virtual BasicType *clone() const override { return new BasicType( *this ); }
    238         virtual void accept( Visitor & v ) override { v.visit( this ); }
    239         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    240         virtual void print( std::ostream & os, int indent = 0 ) const override;
     237        virtual BasicType *clone() const { return new BasicType( *this ); }
     238        virtual void accept( Visitor & v ) { v.visit( this ); }
     239        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     240        virtual void print( std::ostream & os, int indent = 0 ) const;
    241241
    242242        bool isInteger() const;
     
    268268        bool is_array() const { return isStatic || isVarLen || dimension; }
    269269
    270         virtual bool isComplete() const override { return ! isVarLen; }
    271 
    272         virtual PointerType *clone() const override { return new PointerType( *this ); }
    273         virtual void accept( Visitor & v ) override { v.visit( this ); }
    274         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    275         virtual void print( std::ostream & os, int indent = 0 ) const override;
     270        virtual bool isComplete() const { return ! isVarLen; }
     271
     272        virtual PointerType *clone() const { return new PointerType( *this ); }
     273        virtual void accept( Visitor & v ) { v.visit( this ); }
     274        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     275        virtual void print( std::ostream & os, int indent = 0 ) const;
    276276};
    277277
     
    296296        void set_isStatic( bool newValue ) { isStatic = newValue; }
    297297
    298         virtual bool isComplete() const override { return ! isVarLen; }
    299 
    300         virtual ArrayType *clone() const override { return new ArrayType( *this ); }
    301         virtual void accept( Visitor & v ) override { v.visit( this ); }
    302         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    303         virtual void print( std::ostream & os, int indent = 0 ) const override;
     298        virtual bool isComplete() const { return ! isVarLen; }
     299
     300        virtual ArrayType *clone() const { return new ArrayType( *this ); }
     301        virtual void accept( Visitor & v ) { v.visit( this ); }
     302        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     303        virtual void print( std::ostream & os, int indent = 0 ) const;
    304304};
    305305
     
    315315        void set_base( Type *newValue ) { base = newValue; }
    316316
    317         virtual int referenceDepth() const override;
     317        virtual int referenceDepth() const;
    318318
    319319        // Since reference types act like value types, their size is the size of the base.
    320320        // This makes it simple to cast the empty tuple to a reference type, since casts that increase
    321321        // the number of values are disallowed.
    322         virtual unsigned size() const override { return base->size(); }
    323 
    324         virtual ReferenceType *clone() const override { return new ReferenceType( *this ); }
    325         virtual void accept( Visitor & v ) override { v.visit( this ); }
    326         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    327         virtual void print( std::ostream & os, int indent = 0 ) const override;
     322        virtual unsigned size() const { return base->size(); }
     323
     324        virtual ReferenceType *clone() const { return new ReferenceType( *this ); }
     325        virtual void accept( Visitor & v ) { v.visit( this ); }
     326        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     327        virtual void print( std::ostream & os, int indent = 0 ) const;
    328328};
    329329
     
    349349        bool isTtype() const;
    350350
    351         virtual FunctionType *clone() const override { return new FunctionType( *this ); }
    352         virtual void accept( Visitor & v ) override { v.visit( this ); }
    353         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    354         virtual void print( std::ostream & os, int indent = 0 ) const override;
     351        virtual FunctionType *clone() const { return new FunctionType( *this ); }
     352        virtual void accept( Visitor & v ) { v.visit( this ); }
     353        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     354        virtual void print( std::ostream & os, int indent = 0 ) const;
    355355};
    356356
     
    371371        void set_hoistType( bool newValue ) { hoistType = newValue; }
    372372
    373         virtual ReferenceToType *clone() const override = 0;
    374         virtual void accept( Visitor & v ) override = 0;
    375         virtual Type *acceptMutator( Mutator & m ) override = 0;
    376         virtual void print( std::ostream & os, int indent = 0 ) const override;
     373        virtual ReferenceToType *clone() const = 0;
     374        virtual void accept( Visitor & v ) = 0;
     375        virtual Type *acceptMutator( Mutator & m ) = 0;
     376        virtual void print( std::ostream & os, int indent = 0 ) const;
    377377
    378378        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
     
    398398        std::list<TypeDecl*> * get_baseParameters();
    399399
    400         virtual bool isComplete() const override;
     400        virtual bool isComplete() const;
    401401
    402402        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    403403        /// Clones declarations into "foundDecls", caller responsible for freeing
    404         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override;
    405 
    406         virtual StructInstType *clone() const override { return new StructInstType( *this ); }
    407         virtual void accept( Visitor & v ) override { v.visit( this ); }
    408         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    409 
    410         virtual void print( std::ostream & os, int indent = 0 ) const override;
     404        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
     405
     406        virtual StructInstType *clone() const { return new StructInstType( *this ); }
     407        virtual void accept( Visitor & v ) { v.visit( this ); }
     408        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     409
     410        virtual void print( std::ostream & os, int indent = 0 ) const;
    411411  private:
    412         virtual std::string typeString() const override;
     412        virtual std::string typeString() const;
    413413};
    414414
     
    430430        std::list< TypeDecl * > * get_baseParameters();
    431431
    432         virtual bool isComplete() const override;
     432        virtual bool isComplete() const;
    433433
    434434        /// looks up the members of this union named "name" and places them into "foundDecls"
    435435        /// Clones declarations into "foundDecls", caller responsible for freeing
    436         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override;
    437 
    438         virtual UnionInstType *clone() const override { return new UnionInstType( *this ); }
    439         virtual void accept( Visitor & v ) override { v.visit( this ); }
    440         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    441 
    442         virtual void print( std::ostream & os, int indent = 0 ) const override;
     436        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
     437
     438        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
     439        virtual void accept( Visitor & v ) { v.visit( this ); }
     440        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     441
     442        virtual void print( std::ostream & os, int indent = 0 ) const;
    443443  private:
    444         virtual std::string typeString() const override;
     444        virtual std::string typeString() const;
    445445};
    446446
     
    459459        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
    460460
    461         virtual bool isComplete() const override;
    462 
    463         virtual EnumInstType *clone() const override { return new EnumInstType( *this ); }
    464         virtual void accept( Visitor & v ) override { v.visit( this ); }
    465         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     461        virtual bool isComplete() const;
     462
     463        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
     464        virtual void accept( Visitor & v ) { v.visit( this ); }
     465        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    466466  private:
    467         virtual std::string typeString() const override;
     467        virtual std::string typeString() const;
    468468};
    469469
     
    480480        ~TraitInstType();
    481481
    482         virtual bool isComplete() const override;
    483 
    484         virtual TraitInstType *clone() const override { return new TraitInstType( *this ); }
    485         virtual void accept( Visitor & v ) override { v.visit( this ); }
    486         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     482        virtual bool isComplete() const;
     483
     484        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
     485        virtual void accept( Visitor & v ) { v.visit( this ); }
     486        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    487487  private:
    488         virtual std::string typeString() const override;
     488        virtual std::string typeString() const;
    489489};
    490490
     
    507507        void set_isFtype( bool newValue ) { isFtype = newValue; }
    508508
    509         virtual bool isComplete() const override;
    510 
    511         virtual TypeInstType *clone() const override { return new TypeInstType( *this ); }
    512         virtual void accept( Visitor & v ) override { v.visit( this ); }
    513         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    514         virtual void print( std::ostream & os, int indent = 0 ) const override;
     509        virtual bool isComplete() const;
     510
     511        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
     512        virtual void accept( Visitor & v ) { v.visit( this ); }
     513        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     514        virtual void print( std::ostream & os, int indent = 0 ) const;
    515515  private:
    516         virtual std::string typeString() const override;
     516        virtual std::string typeString() const;
    517517};
    518518
     
    530530
    531531        std::list<Type *> & get_types() { return types; }
    532         virtual unsigned size() const override { return types.size(); };
     532        virtual unsigned size() const { return types.size(); };
    533533
    534534        // For now, this is entirely synthetic -- tuple types always have unnamed members.
     
    539539        iterator end() { return types.end(); }
    540540
    541         virtual Type * getComponent( unsigned i ) override {
     541        virtual Type * getComponent( unsigned i ) {
    542542                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
    543543                return *(begin()+i);
    544544        }
    545545
    546         // virtual bool isComplete() const override { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
    547 
    548         virtual TupleType *clone() const override { return new TupleType( *this ); }
    549         virtual void accept( Visitor & v ) override { v.visit( this ); }
    550         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    551         virtual void print( std::ostream & os, int indent = 0 ) const override;
     546        // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
     547
     548        virtual TupleType *clone() const { return new TupleType( *this ); }
     549        virtual void accept( Visitor & v ) { v.visit( this ); }
     550        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     551        virtual void print( std::ostream & os, int indent = 0 ) const;
    552552};
    553553
     
    563563        void set_expr( Expression *newValue ) { expr = newValue; }
    564564
    565         virtual bool isComplete() const override { assert( false ); return false; }
    566 
    567         virtual TypeofType *clone() const override { return new TypeofType( *this ); }
    568         virtual void accept( Visitor & v ) override { v.visit( this ); }
    569         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    570         virtual void print( std::ostream & os, int indent = 0 ) const override;
     565        virtual bool isComplete() const { assert( false ); return false; }
     566
     567        virtual TypeofType *clone() const { return new TypeofType( *this ); }
     568        virtual void accept( Visitor & v ) { v.visit( this ); }
     569        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     570        virtual void print( std::ostream & os, int indent = 0 ) const;
    571571};
    572572
     
    592592        void set_isType( bool newValue ) { isType = newValue; }
    593593
    594         virtual bool isComplete() const override { assert( false ); } // xxx - not sure what to do here
    595 
    596         virtual AttrType *clone() const override { return new AttrType( *this ); }
    597         virtual void accept( Visitor & v ) override { v.visit( this ); }
    598         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    599         virtual void print( std::ostream & os, int indent = 0 ) const override;
     594        virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
     595
     596        virtual AttrType *clone() const { return new AttrType( *this ); }
     597        virtual void accept( Visitor & v ) { v.visit( this ); }
     598        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     599        virtual void print( std::ostream & os, int indent = 0 ) const;
    600600};
    601601
     
    606606        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    607607
    608         virtual bool isComplete() const override{ return true; } // xxx - is this right?
    609 
    610         virtual VarArgsType *clone() const override { return new VarArgsType( *this ); }
    611         virtual void accept( Visitor & v ) override { v.visit( this ); }
    612         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    613         virtual void print( std::ostream & os, int indent = 0 ) const override;
     608        virtual bool isComplete() const{ return true; } // xxx - is this right?
     609
     610        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
     611        virtual void accept( Visitor & v ) { v.visit( this ); }
     612        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     613        virtual void print( std::ostream & os, int indent = 0 ) const;
    614614};
    615615
     
    620620        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    621621
    622         virtual ZeroType *clone() const override { return new ZeroType( *this ); }
    623         virtual void accept( Visitor & v ) override { v.visit( this ); }
    624         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    625         virtual void print( std::ostream & os, int indent = 0 ) const override;
     622        virtual ZeroType *clone() const { return new ZeroType( *this ); }
     623        virtual void accept( Visitor & v ) { v.visit( this ); }
     624        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     625        virtual void print( std::ostream & os, int indent = 0 ) const;
    626626};
    627627
     
    632632        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    633633
    634         virtual OneType *clone() const override { return new OneType( *this ); }
    635         virtual void accept( Visitor & v ) override { v.visit( this ); }
    636         virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    637         virtual void print( std::ostream & os, int indent = 0 ) const override;
    638 };
     634        virtual OneType *clone() const { return new OneType( *this ); }
     635        virtual void accept( Visitor & v ) { v.visit( this ); }
     636        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     637        virtual void print( std::ostream & os, int indent = 0 ) const;
     638};
     639
     640std::ostream & operator<<( std::ostream & out, const Type * type );
    639641
    640642// Local Variables: //
  • src/benchmark/bench.h

    rf265042 r1755226  
    11#pragma once
    22
    3 #ifdef __CFORALL__
    43extern "C" {
    5 #endif
    64        #include <unistd.h>                                     // sysconf
    75        #include <sys/times.h>                                  // times
    86        #include <time.h>
    9 #ifdef __CFORALL__
    107}
    11 #endif
    128
    13 
    14 static inline unsigned long long int Time() {
    15     struct timespec ts;
     9inline unsigned long long int Time() {
     10    timespec ts;
    1611    clock_gettime(
    1712#if defined( __linux__ )
  • src/libcfa/Makefile.am

    rf265042 r1755226  
    3636         ${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -D__CFA_DEBUG__ -O0 -c -o $@ $<
    3737
    38 EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
     38EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
    3939
    4040AM_CCASFLAGS = @CFA_FLAGS@
  • src/libcfa/Makefile.in

    rf265042 r1755226  
    416416ARFLAGS = cr
    417417lib_LIBRARIES = $(am__append_1) $(am__append_2)
    418 EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
     418EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
    419419AM_CCASFLAGS = @CFA_FLAGS@
    420420headers = fstream iostream iterator limits rational stdlib \
  • src/libcfa/concurrency/coroutine.c

    rf265042 r1755226  
    123123        if(pageSize == 0ul) pageSize = sysconf( _SC_PAGESIZE );
    124124
     125        LIB_DEBUG_PRINT_SAFE("FRED");
     126
    125127        size_t cxtSize = libCeiling( sizeof(machine_context_t), 8 ); // minimum alignment
    126128
  • src/libcfa/concurrency/invoke.h

    rf265042 r1755226  
    8484      };
    8585
    86       struct __waitfor_mask_t {
    87             short * accepted;                         // the index of the accepted function, -1 if none
    88             struct __acceptable_t * clauses;          // list of acceptable functions, null if any
    89             short size;                               // number of acceptable functions
    90       };
    91 
    9286      struct monitor_desc {
    9387            struct spinlock lock;                     // spinlock to protect internal data
     
    9690            struct __condition_stack_t signal_stack;  // stack of conditions to run next once we exit the monitor
    9791            unsigned int recursion;                   // monitor routines can be called recursively, we need to keep track of that
    98             struct __waitfor_mask_t mask;               // mask used to know if some thread is waiting for something while holding the monitor
    99       };
    10092
    101       struct __monitor_group_t {
    102             struct monitor_desc ** list;              // currently held monitors
    103             short                  size;              // number of currently held monitors
    104             fptr_t                 func;              // last function that acquired monitors
    105       };
     93            struct __acceptable_t * acceptables;      // list of acceptable functions, null if any
     94            unsigned short acceptable_count;          // number of acceptable functions
     95            short accepted_index;                     // the index of the accepted function, -1 if none
     96       };
    10697
    10798      struct thread_desc {
    10899            // Core threading fields
    109             struct coroutine_desc  self_cor;          // coroutine body used to store context
    110             struct monitor_desc    self_mon;          // monitor body used for mutual exclusion
    111             struct monitor_desc *  self_mon_p;        // pointer to monitor with sufficient lifetime for current monitors
    112             struct __monitor_group_t monitors;          // monitors currently held by this thread
     100            struct coroutine_desc cor;                // coroutine body used to store context
     101            struct monitor_desc mon;                  // monitor body used for mutual exclusion
    113102
    114103            // Link lists fields
    115104            struct thread_desc * next;                // instrusive link field for threads
    116105
    117 
     106            // Current status related to monitors
     107            struct monitor_desc ** current_monitors;  // currently held monitors
     108            unsigned short current_monitor_count;     // number of currently held monitors
     109            fptr_t current_monitor_func;              // last function that acquired monitors
    118110     };
    119 
    120      #ifdef __CFORALL__
    121      extern "Cforall" {
    122             static inline monitor_desc * ?[?]( const __monitor_group_t & this, ptrdiff_t index ) {
    123                   return this.list[index];
    124             }
    125 
    126             static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {
    127                   if( (lhs.list != 0) != (rhs.list != 0) ) return false;
    128                   if( lhs.size != rhs.size ) return false;
    129                   if( lhs.func != rhs.func ) return false;
    130 
    131                   // Check that all the monitors match
    132                   for( int i = 0; i < lhs.size; i++ ) {
    133                         // If not a match, check next function
    134                         if( lhs[i] != rhs[i] ) return false;
    135                   }
    136 
    137                   return true;
    138             }
    139       }
    140       #endif
    141111
    142112#endif //_INVOKE_H_
  • src/libcfa/concurrency/kernel.c

    rf265042 r1755226  
    106106
    107107void ?{}( thread_desc & this, current_stack_info_t * info) {
    108         (this.self_cor){ info };
     108        (this.cor){ info };
    109109}
    110110
     
    328328        // if( !thrd ) return;
    329329        verify( thrd );
    330         verify( thrd->self_cor.state != Halted );
     330        verify( thrd->cor.state != Halted );
    331331
    332332        verify( disable_preempt_count > 0 );
     
    373373        assert(thrd);
    374374        disable_interrupts();
    375         assert( thrd->self_cor.state != Halted );
     375        assert( thrd->cor.state != Halted );
    376376        this_processor->finish.action_code = Schedule;
    377377        this_processor->finish.thrd = thrd;
     
    466466        this_processor = mainProcessor;
    467467        this_thread = mainThread;
    468         this_coroutine = &mainThread->self_cor;
     468        this_coroutine = &mainThread->cor;
    469469
    470470        // Enable preemption
     
    547547        thread_desc * thrd = kernel_data;
    548548
    549         int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->self_cor.name, thrd );
     549        int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->cor.name, thrd );
    550550        __lib_debug_write( STDERR_FILENO, abort_text, len );
    551551
  • src/libcfa/concurrency/monitor

    rf265042 r1755226  
    2222#include "stdlib"
    2323
    24 trait is_monitor(dtype T) {
    25         monitor_desc * get_monitor( T & );
    26         void ^?{}( T & mutex );
    27 };
    28 
    2924static inline void ?{}(monitor_desc & this) {
    3025        (this.lock){};
     
    3328        (this.signal_stack){};
    3429        this.recursion = 0;
    35         this.mask.accepted = NULL;
    36         this.mask.clauses  = NULL;
    37         this.mask.size     = 0;
     30        this.acceptables = NULL;
     31        this.acceptable_count = 0;
     32        this.accepted_index = -1;
    3833}
    3934
     
    105100
    106101struct __acceptable_t {
    107         __monitor_group_t;
     102        fptr_t func;
     103        unsigned short count;
     104        monitor_desc ** monitors;
    108105        bool is_dtor;
    109106};
    110107
    111 void __waitfor_internal( const __waitfor_mask_t & mask, int duration );
     108int __accept_internal( unsigned short count, __acceptable_t * acceptables );
    112109
    113110// Local Variables: //
  • src/libcfa/concurrency/monitor.c

    rf265042 r1755226  
    2424// Forward declarations
    2525static inline void set_owner( monitor_desc * this, thread_desc * owner );
    26 static inline void set_owner( monitor_desc ** storage, short count, thread_desc * owner );
    27 static inline void set_mask ( monitor_desc ** storage, short count, const __waitfor_mask_t & mask );
    28 
    2926static inline thread_desc * next_thread( monitor_desc * this );
    30 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
     27static inline int is_accepted( thread_desc * owner, monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() );
    3128
    3229static inline void lock_all( spinlock ** locks, unsigned short count );
     
    3532static inline void unlock_all( monitor_desc ** locks, unsigned short count );
    3633
    37 static inline void save   ( monitor_desc ** ctx, short count, spinlock ** locks, unsigned int * /*out*/ recursions, __waitfor_mask_t * /*out*/ masks );
    38 static inline void restore( monitor_desc ** ctx, short count, spinlock ** locks, unsigned int * /*in */ recursions, __waitfor_mask_t * /*in */ masks );
     34static inline void save_recursion   ( monitor_desc ** ctx, unsigned int * /*out*/ recursions, unsigned short count );
     35static inline void restore_recursion( monitor_desc ** ctx, unsigned int * /*in */ recursions, unsigned short count );
    3936
    4037static inline void init     ( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );
    4138static inline void init_push( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );
    4239
    43 static inline thread_desc *        check_condition   ( __condition_criterion_t * );
    44 static inline void                 brand_condition   ( condition * );
    45 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc ** monitors, int count );
    46 
    47 forall(dtype T | sized( T ))
    48 static inline short insert_unique( T ** array, short & size, T * val );
    49 static inline short count_max    ( const __waitfor_mask_t & mask );
    50 static inline short aggregate    ( monitor_desc ** storage, const __waitfor_mask_t & mask );
     40static inline thread_desc * check_condition( __condition_criterion_t * );
     41static inline void brand_condition( condition * );
     42static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val );
     43
     44static inline thread_desc * search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count );
    5145
    5246//-----------------------------------------------------------------------------
    5347// Useful defines
    54 #define wait_ctx(thrd, user_info)                               /* Create the necessary information to use the signaller stack                         */ \
    55         __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
    56         __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
    57         init( count, monitors, &waiter, criteria );               /* Link everything together                                                            */ \
    58 
    59 #define wait_ctx_primed(thrd, user_info)                        /* Create the necessary information to use the signaller stack                         */ \
    60         __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
    61         __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
    62         init_push( count, monitors, &waiter, criteria );          /* Link everything together and push it to the AS-Stack                                */ \
    63 
    64 #define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
    65         monitor_desc ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
    66         unsigned short count = cnt;                               /* Save the count to a local variable                                                  */ \
    67         unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
    68         __waitfor_mask_t masks[ count ];                          /* Save the current waitfor masks to restore them later                                */ \
    69         spinlock *   locks     [ count ];                         /* We need to pass-in an array of locks to BlockInternal                               */ \
    70 
    71 #define monitor_save    save   ( monitors, count, locks, recursions, masks )
    72 #define monitor_restore restore( monitors, count, locks, recursions, masks )
    73 
    74 #define blockAndWake( thrd, cnt )                               /* Create the necessary information to use the signaller stack                         */ \
    75         monitor_save;                                             /* Save monitor states                                                                 */ \
    76         BlockInternal( locks, count, thrd, cnt );                 /* Everything is ready to go to sleep                                                  */ \
    77         monitor_restore;                                          /* We are back, restore the owners and recursions                                      */ \
    78 
     48#define wait_ctx(thrd, user_info)                               /* Create the necessary information to use the signaller stack       */ \
     49        __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                   */ \
     50        __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up          */ \
     51        init( count, monitors, &waiter, criteria );               /* Link everything together                                          */ \
     52
     53#define wait_ctx_primed(thrd, user_info)                        /* Create the necessary information to use the signaller stack       */ \
     54        __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                   */ \
     55        __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up          */ \
     56        init_push( count, monitors, &waiter, criteria );          /* Link everything together and push it to the AS-Stack              */ \
     57
     58#define monitor_ctx( mons, cnt )              /* Define that create the necessary struct for internal/external scheduling operations */ \
     59        monitor_desc ** monitors = mons;        /* Save the targeted monitors                                                          */ \
     60        unsigned short count = cnt;             /* Save the count to a local variable                                                  */ \
     61        unsigned int recursions[ count ];       /* Save the current recursion levels to restore them later                             */ \
     62        spinlock *   locks     [ count ];       /* We need to pass-in an array of locks to BlockInternal                               */ \
    7963
    8064//-----------------------------------------------------------------------------
     
    8468extern "C" {
    8569        // Enter single monitor
    86         static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
     70        static void __enter_monitor_desc( monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() ) {
    8771                // Lock the monitor spinlock, lock_yield to reduce contention
    8872                lock_yield( &this->lock DEBUG_CTX2 );
     
    9175                LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
    9276
     77                this->accepted_index = -1;
    9378                if( !this->owner ) {
    9479                        // No one has the monitor, just take it
     
    10489                        LIB_DEBUG_PRINT_SAFE("Kernel :  mon already owned \n");
    10590                }
    106                 else if( is_accepted( this, group) ) {
     91                else if( (this->accepted_index = is_accepted( thrd, this, group, group_cnt, func)) >= 0 ) {
    10792                        // Some one was waiting for us, enter
    10893                        set_owner( this, thrd );
     
    135120                lock_yield( &this->lock DEBUG_CTX2 );
    136121
    137                 LIB_DEBUG_PRINT_SAFE("Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
    138 
    139                 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
     122                verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread, this->owner, this->recursion );
    140123
    141124                // Leaving a recursion level, decrement the counter
     
    163146        // Should never return
    164147        void __leave_thread_monitor( thread_desc * thrd ) {
    165                 monitor_desc * this = &thrd->self_mon;
     148                monitor_desc * this = &thrd->mon;
    166149
    167150                // Lock the monitor now
     
    170153                disable_interrupts();
    171154
    172                 thrd->self_cor.state = Halted;
    173 
    174                 verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
     155                thrd->cor.state = Halted;
     156
     157                verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
    175158
    176159                // Leaving a recursion level, decrement the counter
     
    195178// Enter multiple monitor
    196179// relies on the monitor array being sorted
    197 static inline void enter( __monitor_group_t monitors ) {
    198         for(int i = 0; i < monitors.size; i++) {
    199                 __enter_monitor_desc( monitors.list[i], monitors );
     180static inline void enter(monitor_desc ** monitors, int count, void (*func)() ) {
     181        for(int i = 0; i < count; i++) {
     182                __enter_monitor_desc( monitors[i], monitors, count, func );
    200183        }
    201184}
     
    220203
    221204        // Save previous thread context
    222         this.prev_mntrs = this_thread->monitors.list;
    223         this.prev_count = this_thread->monitors.size;
    224         this.prev_func  = this_thread->monitors.func;
     205        this.prev_mntrs = this_thread->current_monitors;
     206        this.prev_count = this_thread->current_monitor_count;
     207        this.prev_func  = this_thread->current_monitor_func;
    225208
    226209        // Update thread context (needed for conditions)
    227         this_thread->monitors.list = m;
    228         this_thread->monitors.size = count;
    229         this_thread->monitors.func = func;
    230 
    231         LIB_DEBUG_PRINT_SAFE("MGUARD : enter %d\n", count);
     210        this_thread->current_monitors      = m;
     211        this_thread->current_monitor_count = count;
     212        this_thread->current_monitor_func  = func;
    232213
    233214        // Enter the monitors in order
    234         __monitor_group_t group = {this.m, this.count, func};
    235         enter( group );
    236 
    237         LIB_DEBUG_PRINT_SAFE("MGUARD : entered\n");
     215        enter( this.m, this.count, func );
    238216}
    239217
     
    241219// Dtor for monitor guard
    242220void ^?{}( monitor_guard_t & this ) {
    243         LIB_DEBUG_PRINT_SAFE("MGUARD : leaving %d\n", this.count);
    244 
    245221        // Leave the monitors in order
    246222        leave( this.m, this.count );
    247223
    248         LIB_DEBUG_PRINT_SAFE("MGUARD : left\n");
    249 
    250224        // Restore thread context
    251         this_thread->monitors.list = this.prev_mntrs;
    252         this_thread->monitors.size = this.prev_count;
    253         this_thread->monitors.func = this.prev_func;
     225        this_thread->current_monitors      = this.prev_mntrs;
     226        this_thread->current_monitor_count = this.prev_count;
     227        this_thread->current_monitor_func = this.prev_func;
    254228}
    255229
     
    297271        append( &this->blocked, &waiter );
    298272
    299         // Lock all monitors (aggregates the locks as well)
     273        // Lock all monitors (aggregates the lock them as well)
    300274        lock_all( monitors, locks, count );
    301275
     276        // DON'T unlock, ask the kernel to do it
     277
     278        // Save monitor state
     279        save_recursion( monitors, recursions, count );
     280
    302281        // Find the next thread(s) to run
    303         short thread_count = 0;
     282        unsigned short thread_count = 0;
    304283        thread_desc * threads[ count ];
    305284        for(int i = 0; i < count; i++) {
     
    307286        }
    308287
    309         // Save monitor states
    310         monitor_save;
    311 
    312288        // Remove any duplicate threads
    313289        for( int i = 0; i < count; i++) {
    314290                thread_desc * new_owner = next_thread( monitors[i] );
    315                 insert_unique( threads, thread_count, new_owner );
     291                thread_count = insert_unique( threads, thread_count, new_owner );
    316292        }
    317293
     
    319295        BlockInternal( locks, count, threads, thread_count );
    320296
     297
     298        // WE WOKE UP
     299
     300
    321301        // We are back, restore the owners and recursions
    322         monitor_restore;
     302        lock_all( locks, count );
     303        restore_recursion( monitors, recursions, count );
     304        unlock_all( locks, count );
    323305}
    324306
     
    333315        LIB_DEBUG_DO(
    334316                thread_desc * this_thrd = this_thread;
    335                 if ( this->monitor_count != this_thrd->monitors.size ) {
    336                         abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->monitors.size );
     317                if ( this->monitor_count != this_thrd->current_monitor_count ) {
     318                        abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->current_monitor_count );
    337319                }
    338320
    339321                for(int i = 0; i < this->monitor_count; i++) {
    340                         if ( this->monitors[i] != this_thrd->monitors.list[i] ) {
    341                                 abortf( "Signal on condition %p made with different monitor, expected %p got %i", this, this->monitors[i], this_thrd->monitors.list[i] );
     322                        if ( this->monitors[i] != this_thrd->current_monitors[i] ) {
     323                                abortf( "Signal on condition %p made with different monitor, expected %p got %i", this, this->monitors[i], this_thrd->current_monitors[i] );
    342324                        }
    343325                }
     
    382364
    383365        //save contexts
    384         monitor_save;
     366        save_recursion( monitors, recursions, count );
    385367
    386368        //Find the thread to run
    387369        thread_desc * signallee = pop_head( &this->blocked )->waiting_thread;
    388         set_owner( monitors, count, signallee );
     370        for(int i = 0; i < count; i++) {
     371                set_owner( monitors[i], signallee );
     372        }
    389373
    390374        //Everything is ready to go to sleep
     
    395379
    396380
    397         //We are back, restore the masks and recursions
    398         monitor_restore;
     381        //We are back, restore the owners and recursions
     382        lock_all( locks, count );
     383        restore_recursion( monitors, recursions, count );
     384        unlock_all( locks, count );
    399385
    400386        return true;
     
    411397
    412398//-----------------------------------------------------------------------------
    413 // External scheduling
    414 // cases to handle :
    415 //      - target already there :
    416 //              block and wake
    417 //      - dtor already there
    418 //              put thread on signaller stack
    419 //      - non-blocking
    420 //              return else
    421 //      - timeout
    422 //              return timeout
    423 //      - block
    424 //              setup mask
    425 //              block
    426 void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
    427         // This statment doesn't have a contiguous list of monitors...
    428         // Create one!
    429         short max = count_max( mask );
    430         monitor_desc * mon_storage[max];
    431         short actual_count = aggregate( mon_storage, mask );
    432 
    433         if(actual_count == 0) return;
     399// Internal scheduling
     400int __accept_internal( unsigned short acc_count, __acceptable_t * acceptables ) {
     401        thread_desc * thrd = this_thread;
    434402
    435403        // Create storage for monitor context
    436         monitor_ctx( mon_storage, actual_count );
    437 
    438         // Lock all monitors (aggregates the locks as well)
     404        monitor_ctx( acceptables->monitors, acceptables->count );
     405
     406        // Lock all monitors (aggregates the lock them as well)
    439407        lock_all( monitors, locks, count );
    440408
    441         {
    442                 // Check if the entry queue
    443                 thread_desc * next; int index;
    444                 [next, index] = search_entry_queue( mask, monitors, count );
    445 
    446                 if( next ) {
    447                         if( mask.clauses[index].is_dtor ) {
    448                                 #warning case not implemented
    449                         }
    450                         else {
    451                                 blockAndWake( &next, 1 );
    452                         }
    453 
    454                         return index;
    455                 }
    456         }
    457 
    458 
    459         if( duration == 0 ) {
    460                 unlock_all( locks, count );
    461                 return;
    462         }
    463 
    464 
    465         verifyf( duration < 0, "Timeout on waitfor statments not supported yet.");
    466 
    467 
    468         monitor_save;
    469         set_mask( monitors, count, mask );
    470 
    471         BlockInternal( locks, count );       // Everything is ready to go to sleep
     409        // Create the node specific to this wait operation
     410        wait_ctx_primed( thrd, 0 );
     411
     412        // Check if the entry queue
     413        thread_desc * next = search_entry_queue( acceptables, acc_count, monitors, count );
     414
     415        LIB_DEBUG_PRINT_SAFE("Owner(s) :");
     416        for(int i = 0; i < count; i++) {
     417                LIB_DEBUG_PRINT_SAFE(" %p", monitors[i]->owner );
     418        }
     419        LIB_DEBUG_PRINT_SAFE("\n");
     420
     421        LIB_DEBUG_PRINT_SAFE("Passing mon to %p\n", next);
     422
     423        if( !next ) {
     424                // Update acceptables on the current monitors
     425                for(int i = 0; i < count; i++) {
     426                        monitors[i]->acceptables = acceptables;
     427                        monitors[i]->acceptable_count = acc_count;
     428                }
     429        }
     430        else {
     431                for(int i = 0; i < count; i++) {
     432                        set_owner( monitors[i], next );
     433                }
     434        }
     435
     436
     437        save_recursion( monitors, recursions, count );
     438
     439
     440        // Everything is ready to go to sleep
     441        BlockInternal( locks, count, &next, next ? 1 : 0 );
     442
     443
    472444        //WE WOKE UP
    473         monitor_restore;                     //We are back, restore the masks and recursions
     445
     446
     447        //We are back, restore the owners and recursions
     448        lock_all( locks, count );
     449        restore_recursion( monitors, recursions, count );
     450        int acc_idx = monitors[0]->accepted_index;
     451        unlock_all( locks, count );
     452
     453        return acc_idx;
    474454}
    475455
     
    478458
    479459static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
    480         LIB_DEBUG_PRINT_SAFE("Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
    481 
    482460        //Pass the monitor appropriately
    483461        this->owner = owner;
     
    485463        //We are passing the monitor to someone else, which means recursion level is not 0
    486464        this->recursion = owner ? 1 : 0;
    487 }
    488 
    489 static inline void set_owner( monitor_desc ** monitors, short count, thread_desc * owner ) {
    490         for( int i = 0; i < count; i++ ) {
    491                 set_owner( monitors[i], owner );
    492         }
    493 }
    494 
    495 static inline void set_mask( monitor_desc ** storage, short count, const __waitfor_mask_t & mask ) {
    496         for(int i = 0; i < count; i++) {
    497                 storage[i]->mask = mask;
    498         }
    499465}
    500466
     
    519485}
    520486
    521 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
    522         __acceptable_t * it = this->mask.clauses; // Optim
    523         int count = this->mask.size;
     487static inline int is_accepted( thread_desc * owner, monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() ) {
     488        __acceptable_t* accs = this->acceptables; // Optim
     489        int acc_cnt = this->acceptable_count;
    524490
    525491        // Check if there are any acceptable functions
    526         if( !it ) return false;
     492        if( !accs ) return -1;
    527493
    528494        // If this isn't the first monitor to test this, there is no reason to repeat the test.
    529         if( this != group[0] ) return group[0]->mask.accepted >= 0;
     495        if( this != group[0] ) return group[0]->accepted_index;
    530496
    531497        // For all acceptable functions check if this is the current function.
    532         for( short i = 0; i < count; i++, it++ ) {
    533                 if( *it == group ) {
    534                         *this->mask.accepted = i;
    535                         return true;
     498        OUT_LOOP:
     499        for( int i = 0; i < acc_cnt; i++ ) {
     500                __acceptable_t * acc = &accs[i];
     501
     502                // if function matches, check the monitors
     503                if( acc->func == func ) {
     504
     505                        // If the group count is different then it can't be a match
     506                        if( acc->count != group_cnt ) return -1;
     507
     508                        // Check that all the monitors match
     509                        for( int j = 0; j < group_cnt; j++ ) {
     510                                // If not a match, check next function
     511                                if( acc->monitors[j] != group[j] ) continue OUT_LOOP;
     512                        }
     513
     514                        // It's a complete match, accept the call
     515                        return i;
    536516                }
    537517        }
    538518
    539519        // No function matched
    540         return false;
     520        return -1;
    541521}
    542522
     
    584564}
    585565
    586 static inline void save   ( monitor_desc ** ctx, short count, __attribute((unused)) spinlock ** locks, unsigned int * /*out*/ recursions, __waitfor_mask_t * /*out*/ masks ) {
     566
     567static inline void save_recursion   ( monitor_desc ** ctx, unsigned int * /*out*/ recursions, unsigned short count ) {
    587568        for( int i = 0; i < count; i++ ) {
    588569                recursions[i] = ctx[i]->recursion;
    589                 masks[i]      = ctx[i]->mask;
    590         }
    591 }
    592 
    593 static inline void restore( monitor_desc ** ctx, short count, spinlock ** locks, unsigned int * /*out*/ recursions, __waitfor_mask_t * /*out*/ masks ) {
    594         lock_all( locks, count );
     570        }
     571}
     572
     573static inline void restore_recursion( monitor_desc ** ctx, unsigned int * /*in */ recursions, unsigned short count ) {
    595574        for( int i = 0; i < count; i++ ) {
    596575                ctx[i]->recursion = recursions[i];
    597                 ctx[i]->mask      = masks[i];
    598         }
    599         unlock_all( locks, count );
     576        }
    600577}
    601578
     
    630607        if( !this->monitors ) {
    631608                // LIB_DEBUG_PRINT_SAFE("Branding\n");
    632                 assertf( thrd->monitors.list != NULL, "No current monitor to brand condition %p", thrd->monitors.list );
    633                 this->monitor_count = thrd->monitors.size;
     609                assertf( thrd->current_monitors != NULL, "No current monitor to brand condition %p", thrd->current_monitors );
     610                this->monitor_count = thrd->current_monitor_count;
    634611
    635612                this->monitors = malloc( this->monitor_count * sizeof( *this->monitors ) );
    636613                for( int i = 0; i < this->monitor_count; i++ ) {
    637                         this->monitors[i] = thrd->monitors.list[i];
    638                 }
    639         }
    640 }
    641 
    642 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc ** monitors, int count ) {
     614                        this->monitors[i] = thrd->current_monitors[i];
     615                }
     616        }
     617}
     618
     619static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val ) {
     620        if( !val ) return end;
     621
     622        for(int i = 0; i <= end; i++) {
     623                if( thrds[i] == val ) return end;
     624        }
     625
     626        thrds[end] = val;
     627        return end + 1;
     628}
     629
     630
     631static inline bool match( __acceptable_t * acc, thread_desc * thrd ) {
     632        verify( thrd );
     633        verify( acc );
     634        if( acc->func != thrd->current_monitor_func ) return false;
     635
     636        return true;
     637}
     638
     639static inline thread_desc * search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count ) {
    643640
    644641        __thread_queue_t * entry_queue = &monitors[0]->entry_queue;
     
    647644        for(    thread_desc ** thrd_it = &entry_queue->head;
    648645                *thrd_it;
    649                 thrd_it = &(*thrd_it)->next
    650         ) {
     646                thrd_it = &(*thrd_it)->next)
     647        {
    651648                // For each acceptable check if it matches
    652                 int i = 0;
    653                 __acceptable_t * end = mask.clauses + mask.size;
    654                 for( __acceptable_t * it = mask.clauses; it != end; it++, i++ ) {
     649                __acceptable_t * acc_end = acceptables + acc_count;
     650                for( __acceptable_t * acc_it = acceptables; acc_it != acc_end; acc_it++ ) {
    655651                        // Check if we have a match
    656                         if( *it == (*thrd_it)->monitors ) {
     652                        if( match( acc_it, *thrd_it ) ) {
    657653
    658654                                // If we have a match return it
    659655                                // after removeing it from the entry queue
    660                                 return [remove( entry_queue, thrd_it ), i];
     656                                return remove( entry_queue, thrd_it );
    661657                        }
    662658                }
    663659        }
    664660
    665         return [0, -1];
    666 }
    667 
    668 forall(dtype T | sized( T ))
    669 static inline short insert_unique( T ** array, short & size, T * val ) {
    670         if( !val ) return size;
    671 
    672         for(int i = 0; i <= size; i++) {
    673                 if( array[i] == val ) return size;
    674         }
    675 
    676         array[size] = val;
    677         size = size + 1;
    678         return size;
    679 }
    680 
    681 static inline short count_max( const __waitfor_mask_t & mask ) {
    682         short max = 0;
    683         for( int i = 0; i < mask.size; i++ ) {
    684                 max += mask.clauses[i].size;
    685         }
    686         return max;
    687 }
    688 
    689 static inline short aggregate( monitor_desc ** storage, const __waitfor_mask_t & mask ) {
    690         short size = 0;
    691         for( int i = 0; i < mask.size; i++ ) {
    692                 for( int j = 0; j < mask.clauses[i].size; j++) {
    693                         insert_unique( storage, size, mask.clauses[i].list[j] );
    694                 }
    695         }
    696         qsort( storage, size );
    697         return size;
    698 }
    699 
     661        return NULL;
     662}
    700663void ?{}( __condition_blocked_queue_t & this ) {
    701664        this.head = NULL;
  • src/libcfa/concurrency/preemption.c

    rf265042 r1755226  
    328328                siginfo_t info;
    329329                int sig = sigwaitinfo( &mask, &info );
    330 
    331                 if( sig < 0 ) {
    332                         //Error!
    333                         int err = errno;
    334                         switch( err ) {
    335                                 case EAGAIN :
    336                                 case EINTR :
    337                                         continue;
    338                         case EINVAL :
    339                                         abortf("Timeout was invalid.");
    340                                 default:
    341                                         abortf("Unhandled error %d", err);
    342                         }
    343                 }
    344330
    345331                // If another signal arrived something went wrong
  • src/libcfa/concurrency/thread

    rf265042 r1755226  
    3636forall( dtype T | is_thread(T) )
    3737static inline coroutine_desc* get_coroutine(T & this) {
    38         return &get_thread(this)->self_cor;
     38        return &get_thread(this)->cor;
    3939}
    4040
    4141forall( dtype T | is_thread(T) )
    4242static inline monitor_desc* get_monitor(T & this) {
    43         return &get_thread(this)->self_mon;
     43        return &get_thread(this)->mon;
    4444}
    4545
    4646static inline coroutine_desc* get_coroutine(thread_desc * this) {
    47         return &this->self_cor;
     47        return &this->cor;
    4848}
    4949
    5050static inline monitor_desc* get_monitor(thread_desc * this) {
    51         return &this->self_mon;
     51        return &this->mon;
    5252}
    5353
  • src/libcfa/concurrency/thread.c

    rf265042 r1755226  
    3333
    3434void ?{}(thread_desc& this) {
    35         (this.self_cor){};
    36         this.self_cor.name = "Anonymous Coroutine";
    37         this.self_mon.owner = &this;
    38         this.self_mon.recursion = 1;
    39         this.self_mon_p = &this.self_mon;
     35        (this.cor){};
     36        this.cor.name = "Anonymous Coroutine";
     37        this.mon.owner = &this;
     38        this.mon.recursion = 1;
    4039        this.next = NULL;
    4140
    42         (this.monitors){ &this.self_mon_p, 1, (fptr_t)0 };
     41        this.current_monitors      = &this.mon;
     42        this.current_monitor_count = 1;
    4343}
    4444
    4545void ^?{}(thread_desc& this) {
    46         ^(this.self_cor){};
     46        ^(this.cor){};
    4747}
    4848
  • src/prelude/prelude.cf

    rf265042 r1755226  
    4242_Bool                   ?--( _Bool & ),                         ?--( volatile _Bool & );
    4343unsigned char           ?++( unsigned char & ),                 ?++( volatile unsigned char & );
    44 signed short            ?++( signed short & ),                  ?++( volatile signed short & );
    45 signed short            ?--( signed short & ),                  ?--( volatile signed short & );
    46 unsigned short          ?++( unsigned short & ),                ?++( volatile unsigned short & );
    47 unsigned short          ?--( unsigned short & ),                ?--( volatile unsigned short & );
    4844signed int              ?++( signed int & ),                    ?++( volatile signed int & );
    4945signed int              ?--( signed int & ),                    ?--( volatile signed int & );
     
    9692
    9793_Bool                   ++?( _Bool & ),                         --?( _Bool & );
    98 signed short    ++?( signed short & ),                  --?( signed short & );
    9994signed int              ++?( signed int & ),                    --?( signed int & );
    100 unsigned short          ++?( unsigned int & ),                  --?( unsigned int & );
    101 unsigned int            ++?( unsigned short & ),                --?( unsigned short & );
     95unsigned int            ++?( unsigned int & ),                  --?( unsigned int & );
    10296signed long int         ++?( signed long int & ),               --?( signed long int & );
    10397unsigned long int       ++?( unsigned long int & ),             --?( unsigned long int & );
  • src/tests/Makefile.am

    rf265042 r1755226  
    104104        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    105105
    106 sched-ext-parse : sched-ext-parse.c @CFA_BINDIR@/@CFA_NAME@
    107         ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    108 
    109106gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
    110107        ${CC} ${AM_CFLAGS} ${CFLAGS} -lgmp ${<} -o ${@}
  • src/tests/Makefile.in

    rf265042 r1755226  
    856856        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    857857
    858 sched-ext-parse : sched-ext-parse.c @CFA_BINDIR@/@CFA_NAME@
    859         ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    860 
    861858gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
    862859        ${CC} ${AM_CFLAGS} ${CFLAGS} -lgmp ${<} -o ${@}
  • src/tests/sched-ext-parse.c

    rf265042 r1755226  
    8080                16;
    8181        }
    82         or waitfor( f2, a, a ) {
     82        or waitfor( f1, a, a ) {
    8383                17;
    8484        }
  • src/tests/sched-ext.c

    rf265042 r1755226  
    4545        acceptable.monitors      = &a;
    4646
    47         __waitfor_internal( 1, &acceptable );
     47        __accept_internal( 1, &acceptable );
    4848
    4949        sout | "Accepted" | endl;
Note: See TracChangeset for help on using the changeset viewer.