Changes in / [39fea2f:764e009]


Ignore:
Location:
src
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/CodeGen/CodeGenerator.cc

    r39fea2f r764e009  
    865865        void CodeGenerator::visit( CaseStmt * caseStmt ) {
    866866                updateLocation( caseStmt );
     867                output << indent;
    867868                if ( caseStmt->isDefault()) {
    868869                        output << "default";
     
    10011002} // namespace CodeGen
    10021003
     1004std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
     1005        if ( node ) {
     1006                node->print( out );
     1007        } else {
     1008                out << "nullptr";
     1009        }
     1010        return out;
     1011}
     1012
    10031013// Local Variables: //
    10041014// tab-width: 4 //
  • TabularUnified src/Concurrency/Waitfor.cc

    r39fea2f r764e009  
    2727#include "InitTweak/InitTweak.h"   // for getPointerBase
    2828#include "Parser/LinkageSpec.h"    // for Cforall
    29 #include "SymTab/AddVisit.h"       // for acceptAndAdd
     29#include "ResolvExpr/Resolver.h"   // for findVoidExpression
    3030#include "SynTree/Constant.h"      // for Constant
    3131#include "SynTree/Declaration.h"   // for StructDecl, FunctionDecl, ObjectDecl
     
    112112        //=============================================================================================
    113113
    114         class GenerateWaitForPass final : public WithStmtsToAdd {
     114        class GenerateWaitForPass final : public WithIndexer {
    115115          public:
    116116
     
    129129                void         init( ObjectDecl * acceptables, int index, WaitForStmt::Clause & clause, CompoundStmt * stmt );
    130130                Expression * init_timeout( Expression *& time, Expression *& time_cond, bool has_else, Expression *& else_cond, CompoundStmt * stmt );
    131                 Expression * call();
    132                 void choose();
     131                Expression * call(size_t count, ObjectDecl * acceptables, Expression * timeout, CompoundStmt * stmt);
     132                void         choose( WaitForStmt * waitfor, Expression  * result, CompoundStmt * stmt );
    133133
    134134                static void implement( std::list< Declaration * > & translationUnit ) {
     
    142142                StructDecl          * decl_acceptable = nullptr;
    143143                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;
    148144
    149145                static std::unique_ptr< Type > generic_func;
     
    152148                UniqueName namer_acc = "__acceptables_"s;
    153149                UniqueName namer_tim = "__timeout_"s;
     150                UniqueName namer_ret = "__return_"s;
    154151        };
    155152
     
    167164        namespace {
    168165                Expression * makeOpIndex( DeclarationWithType * array, unsigned long index ) {
    169                         return new ApplicationExpr(
     166                        return new UntypedExpr(
    170167                                new NameExpr( "?[?]" ),
    171168                                {
     
    177174
    178175                Expression * makeOpAssign( Expression * lhs, Expression * rhs ) {
    179                         return new ApplicationExpr(
     176                        return new UntypedExpr(
    180177                                        new NameExpr( "?=?" ),
    181178                                        { lhs, rhs }
     
    183180                }
    184181
    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
     182                Expression * makeOpMember( Expression * sue, const std::string & mem ) {
     183                        return new UntypedMemberExpr( new NameExpr( mem ), sue );
     184                }
     185
     186                Statement * makeAccStatement( DeclarationWithType * object, unsigned long index, const std::string & member, Expression * value, const SymTab::Indexer & indexer ) {
     187                        std::unique_ptr< Expression > expr( makeOpAssign(
     188                                makeOpMember(
     189                                        makeOpIndex(
     190                                                object,
     191                                                index
    199192                                        ),
    200                                         value
    201                                 )
    202                         );
     193                                        member
     194                                ),
     195                                value
     196                        ) );
     197
     198                        return new ExprStmt( noLabels, ResolvExpr::findVoidExpression( expr.get(), indexer ) );
    203199                }
    204200
     
    208204                        return new ConstantExpr( Constant::from_bool( ifnull ) );
    209205                }
     206
     207                VariableExpr * extractVariable( Expression * func ) {
     208                        if( VariableExpr * var = dynamic_cast< VariableExpr * >( func ) ) {
     209                                return var;
     210                        }
     211
     212                        CastExpr * cast = strict_dynamic_cast< CastExpr * >( func );
     213                        return strict_dynamic_cast< VariableExpr * >( cast->arg );
     214                }
     215
     216                Expression * detectIsDtor( Expression * func ) {
     217                        VariableExpr * typed_func = extractVariable( func );
     218                        bool is_dtor = InitTweak::isDestructor( typed_func->var );
     219                        return new ConstantExpr( Constant::from_bool( is_dtor ) );
     220                }
    210221        };
    211222
     
    216227
    217228        void GenerateWaitForPass::premutate( FunctionDecl * decl) {
    218                 if( decl->name != "__accept_internal" ) return;
     229                if( decl->name != "__waitfor_internal" ) return;
    219230
    220231                decl_waitfor = decl;
     
    227238                        assert( !decl_acceptable );
    228239                        decl_acceptable = 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 
    236240                }
    237241                else if( decl->name == "monitor_desc" ) {
     
    242246
    243247        Statement * GenerateWaitForPass::postmutate( WaitForStmt * waitfor ) {
    244                 return waitfor;
    245 
    246248                if( !decl_monitor || !decl_acceptable ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor );
    247249
     
    265267                );
    266268
    267                 // Expression * result  = call( acceptables, timeout, orelse, stmt );
    268 
    269                 // choose( waitfor, result );
     269                Expression * result = call( waitfor->clauses.size(), acceptables, timeout, stmt );
     270
     271                choose( waitfor, result, stmt );
    270272
    271273                return stmt;
     
    274276        ObjectDecl * GenerateWaitForPass::declare( unsigned long count, CompoundStmt * stmt )
    275277        {
    276                 ObjectDecl * acceptables = new ObjectDecl(
     278                ObjectDecl * acceptables = ObjectDecl::newObject(
    277279                        namer_acc.newName(),
    278                         noStorage,
    279                         LinkageSpec::Cforall,
    280                         nullptr,
    281280                        new ArrayType(
    282281                                noQualifiers,
     
    299298        ObjectDecl * GenerateWaitForPass::declMon( WaitForStmt::Clause & clause, CompoundStmt * stmt ) {
    300299
    301                 ObjectDecl * mon = new ObjectDecl(
     300                ObjectDecl * mon = ObjectDecl::newObject(
    302301                        namer_mon.newName(),
    303                         noStorage,
    304                         LinkageSpec::Cforall,
    305                         nullptr,
    306302                        new ArrayType(
    307303                                noQualifiers,
    308                                 new StructInstType(
     304                                new PointerType(
    309305                                        noQualifiers,
    310                                         decl_monitor
     306                                        new StructInstType(
     307                                                noQualifiers,
     308                                                decl_monitor
     309                                        )
    311310                                ),
    312311                                new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ),
     
    316315                        new ListInit(
    317316                                map_range < std::list<Initializer*> > ( clause.target.arguments, [this](Expression * expr ){
    318                                         return new SingleInit( expr );
     317                                        Expression * untyped = new CastExpr(
     318                                                new UntypedExpr(
     319                                                        new NameExpr( "get_monitor" ),
     320                                                        { expr }
     321                                                ),
     322                                                new PointerType(
     323                                                        noQualifiers,
     324                                                        new StructInstType(
     325                                                                noQualifiers,
     326                                                                decl_monitor
     327                                                        )
     328                                                )
     329                                        );
     330
     331                                        Expression * init = ResolvExpr::findSingleExpression( untyped, indexer );
     332                                        delete untyped;
     333                                        return new SingleInit( init );
    319334                                })
    320335                        )
     
    330345                ObjectDecl * monitors = declMon( clause, stmt );
    331346
     347                Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
     348
    332349                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 ) ) ) );
     350                compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , detectIsDtor( clause.target.function )                                    , indexer ) );
     351                compound->push_back( makeAccStatement( acceptables, index, "func"    , new CastExpr( clause.target.function, fptr_t )                            , indexer ) );
     352                compound->push_back( makeAccStatement( acceptables, index, "monitors", new VariableExpr( monitors )                                              , indexer ) );
     353                compound->push_back( makeAccStatement( acceptables, index, "count"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ) );
    337354
    338355                stmt->push_back( new IfStmt(
     
    355372                CompoundStmt * stmt
    356373        ) {
    357                 ObjectDecl * timeout = new ObjectDecl(
     374                ObjectDecl * timeout = ObjectDecl::newObject(
    358375                        namer_tim.newName(),
    359                         noStorage,
    360                         LinkageSpec::Cforall,
    361                         nullptr,
    362376                        new BasicType(
    363377                                noQualifiers,
     
    374388                        stmt->push_back( new IfStmt(
    375389                                noLabels,
    376                                 safeCond( else_cond ),
     390                                safeCond( time_cond ),
    377391                                new ExprStmt(
    378392                                        noLabels,
     
    407421                return new VariableExpr( timeout );
    408422        }
     423
     424        Expression * GenerateWaitForPass::call(
     425                size_t count,
     426                ObjectDecl * acceptables,
     427                Expression * timeout,
     428                CompoundStmt * stmt
     429        ) {
     430                ObjectDecl * decl = ObjectDecl::newObject(
     431                        namer_ret.newName(),
     432                        new BasicType(
     433                                noQualifiers,
     434                                BasicType::LongLongUnsignedInt
     435                        ),
     436                        new SingleInit(
     437                                new UntypedExpr(
     438                                        VariableExpr::functionPointer( decl_waitfor ),
     439                                        {
     440                                                new ConstantExpr( Constant::from_ulong( count ) ),
     441                                                new VariableExpr( acceptables ),
     442                                                timeout
     443                                        }
     444                                )
     445                        )
     446                );
     447
     448                stmt->push_back( new DeclStmt( noLabels, decl ) );
     449
     450                return new VariableExpr( decl );
     451        }
     452
     453        void GenerateWaitForPass::choose(
     454                WaitForStmt * waitfor,
     455                Expression  * result,
     456                CompoundStmt * stmt
     457        ) {
     458                SwitchStmt * swtch = new SwitchStmt(
     459                        noLabels,
     460                        result,
     461                        std::list<Statement *>()
     462                );
     463
     464                unsigned long i = 0;
     465                for( auto & clause : waitfor->clauses ) {
     466                        swtch->statements.push_back(
     467                                new CaseStmt(
     468                                        noLabels,
     469                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     470                                        {
     471                                                clause.statement,
     472                                                new BranchStmt(
     473                                                        noLabels,
     474                                                        "",
     475                                                        BranchStmt::Break
     476                                                )
     477                                        }
     478                                )
     479                        );
     480                }
     481
     482                if(waitfor->timeout.statement) {
     483                        swtch->statements.push_back(
     484                                new CaseStmt(
     485                                        noLabels,
     486                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     487                                        {
     488                                                waitfor->timeout.statement,
     489                                                new BranchStmt(
     490                                                        noLabels,
     491                                                        "",
     492                                                        BranchStmt::Break
     493                                                )
     494                                        }
     495                                )
     496                        );
     497                }
     498
     499                if(waitfor->orelse.statement) {
     500                        swtch->statements.push_back(
     501                                new CaseStmt(
     502                                        noLabels,
     503                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     504                                        {
     505                                                waitfor->orelse.statement,
     506                                                new BranchStmt(
     507                                                        noLabels,
     508                                                        "",
     509                                                        BranchStmt::Break
     510                                                )
     511                                        }
     512                                )
     513                        );
     514                }
     515
     516                stmt->push_back( swtch );
     517        }
    409518};
    410519
  • TabularUnified src/Parser/StatementNode.cc

    r39fea2f r764e009  
    234234                target,
    235235                maybeMoveBuild<Statement >( stmt ),
    236                 maybeMoveBuild<Expression>( when )
     236                notZeroExpr( maybeMoveBuild<Expression>( when ) )
    237237        });
    238238
     
    250250        delete targetExpr;
    251251
    252         node->clauses.push_back( WaitForStmt::Clause{
     252        node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{
    253253                std::move( target ),
    254254                maybeMoveBuild<Statement >( stmt ),
    255                 maybeMoveBuild<Expression>( when )
     255                notZeroExpr( maybeMoveBuild<Expression>( when ) )
    256256        });
    257257
     
    265265                node->timeout.time      = maybeMoveBuild<Expression>( timeout );
    266266                node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
    267                 node->timeout.condition = maybeMoveBuild<Expression>( when    );
     267                node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
    268268        }
    269269        else {
    270                 node->orelse.statement  = maybeMoveBuild<Statement >( stmt    );
    271                 node->orelse.condition  = maybeMoveBuild<Expression>( when    );
     270                node->orelse.statement  = maybeMoveBuild<Statement >( stmt );
     271                node->orelse.condition  = notZeroExpr( maybeMoveBuild<Expression>( when ) );
    272272        }
    273273
     
    280280        node->timeout.time      = maybeMoveBuild<Expression>( timeout );
    281281        node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
    282         node->timeout.condition = maybeMoveBuild<Expression>( when    );
     282        node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
    283283
    284284        node->orelse.statement = maybeMoveBuild<Statement >( else_stmt );
    285         node->orelse.condition = maybeMoveBuild<Expression>( else_when );
     285        node->orelse.condition  = notZeroExpr( 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 // }
    295289
    296290Statement *build_compound( StatementNode *first ) {
  • TabularUnified src/Parser/parserutility.cc

    r39fea2f r764e009  
    2929
    3030Expression *notZeroExpr( Expression *orig ) {
     31        if( !orig ) return nullptr;
    3132        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    3233        comparison->get_args().push_back( orig );
  • TabularUnified src/ResolvExpr/AlternativeFinder.cc

    r39fea2f r764e009  
    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                 }
    153146        } // 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 >
  • TabularUnified src/ResolvExpr/AlternativeFinder.h

    r39fea2f r764e009  
    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 );
    5257          private:
    5358                virtual void visit( ApplicationExpr *applicationExpr );
     
    8186                virtual void visit( StmtExpr *stmtExpr );
    8287                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 );
    8788
    8889                /// Adds alternatives for anonymous members
     
    108109
    109110        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
     111        void referenceToRvalueConversion( Expression *& expr );
    110112
    111113        template< typename InputIterator, typename OutputIterator >
  • TabularUnified src/ResolvExpr/Resolver.cc

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

    r39fea2f r764e009  
    2929        /// Checks types and binds syntactic constructs to typed representations
    3030        void resolve( std::list< Declaration * > translationUnit );
    31         Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
    32         Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
     31        Expression * resolveInVoidContext( Expression *expr   , const SymTab::Indexer &indexer );
     32        Expression * findVoidExpression  ( Expression *untyped, const SymTab::Indexer &indexer );
     33        Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer );
    3334        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    3435        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
  • TabularUnified src/SymTab/Mangler.cc

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

    r39fea2f r764e009  
    2626
    2727        virtual void accept( Visitor & v ) = 0;
     28
     29        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    2830};
     31
     32std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node );
    2933
    3034// Local Variables: //
  • TabularUnified src/SynTree/Declaration.cc

    r39fea2f r764e009  
    5959}
    6060
    61 std::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 
    7061
    7162AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
  • TabularUnified src/SynTree/Declaration.h

    r39fea2f r764e009  
    6262        void fixUniqueId( void );
    6363        virtual Declaration *clone() const = 0;
    64         virtual void accept( Visitor &v ) = 0;
     64        virtual void accept( Visitor &v ) override = 0;
    6565        virtual Declaration *acceptMutator( Mutator &m ) = 0;
    66         virtual void print( std::ostream &os, int indent = 0 ) const = 0;
     66        virtual void print( std::ostream &os, int indent = 0 ) const override = 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 = 0;
    109         virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     108        virtual DeclarationWithType *clone() const override = 0;
     109        virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
    110110
    111111        virtual Type * get_type() const = 0;
     
    128128        virtual ~ObjectDecl();
    129129
    130         virtual Type * get_type() const { return type; }
    131         virtual void set_type(Type *newType) { type = newType; }
     130        virtual Type * get_type() const override { return type; }
     131        virtual void set_type(Type *newType) override { 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 { 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;
     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;
    146146};
    147147
     
    157157        virtual ~FunctionDecl();
    158158
    159         Type * get_type() const { return type; }
    160         virtual void set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); }
     159        virtual Type * get_type() const override { return type; }
     160        virtual void set_type(Type * t) override { 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 { 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;
     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;
    172172};
    173173
     
    190190        virtual std::string typeString() const = 0;
    191191
    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;
     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;
    195195};
    196196
     
    227227        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    228228
    229         virtual std::string typeString() const;
     229        virtual std::string typeString() const override;
    230230        virtual std::string genTypeString() const;
    231231
    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;
     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;
    236236
    237237  private:
     
    245245        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    246246
    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 ); }
     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 ); }
    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;
    277         virtual void printShort( std::ostream &os, int indent = 0 ) const;
     276        virtual void print( std::ostream &os, int indent = 0 ) const override;
     277        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    278278  protected:
    279279        virtual std::string typeString() const = 0;
     
    290290        bool is_thread() { return kind == DeclarationNode::Thread; }
    291291
    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 ); }
     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 ); }
    295295  private:
    296296        DeclarationNode::Aggregate kind;
    297         virtual std::string typeString() const;
     297        virtual std::string typeString() const override;
    298298};
    299299
     
    304304        UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    305305
    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;
     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;
    311311};
    312312
     
    317317        EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    318318
    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;
     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;
    324324};
    325325
     
    332332        TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    333333
    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;
     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;
    339339};
    340340
     
    350350        void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    351351
    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 
    359 std::ostream & operator<<( std::ostream & out, const Declaration * decl );
     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
    360359std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    361360
  • TabularUnified src/SynTree/Expression.cc

    r39fea2f r764e009  
    741741}
    742742
    743 
    744 std::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 
    753743// Local Variables: //
    754744// tab-width: 4 //
  • TabularUnified src/SynTree/Expression.h

    r39fea2f r764e009  
    821821};
    822822
    823 
    824 std::ostream & operator<<( std::ostream & out, const Expression * expr );
    825 
    826823// Local Variables: //
    827824// tab-width: 4 //
  • TabularUnified src/SynTree/Initializer.cc

    r39fea2f r764e009  
    137137}
    138138
    139 std::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 
    148 std::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 
    157139// Local Variables: //
    158140// tab-width: 4 //
  • TabularUnified src/SynTree/Initializer.h

    r39fea2f r764e009  
    3838
    3939        virtual Designation * clone() const { return new Designation( *this ); };
    40         virtual void accept( Visitor &v ) { v.visit( this ); }
     40        virtual void accept( Visitor &v ) override { v.visit( this ); }
    4141        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
    42         virtual void print( std::ostream &os, int indent = 0 ) const;
     42        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4343};
    4444
     
    5555
    5656        virtual Initializer *clone() const = 0;
    57         virtual void accept( Visitor &v ) = 0;
     57        virtual void accept( Visitor &v ) override = 0;
    5858        virtual Initializer *acceptMutator( Mutator &m ) = 0;
    59         virtual void print( std::ostream &os, int indent = 0 ) const = 0;
     59        virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
    6060  private:
    6161        bool maybeConstructed;
     
    7575        void set_value( Expression *newValue ) { value = newValue; }
    7676
    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;
     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;
    8181};
    8282
     
    103103        const_iterator end() const { return initializers.end(); }
    104104
    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;
     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;
    109109};
    110110
     
    129129        Initializer * get_init() const { return init; }
    130130
    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;
     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;
    135135
    136136  private:
     
    140140};
    141141
    142 std::ostream & operator<<( std::ostream & out, const Initializer * init );
    143 std::ostream & operator<<( std::ostream & out, const Designation * des );
    144 
    145142// Local Variables: //
    146143// tab-width: 4 //
  • TabularUnified src/SynTree/Statement.cc

    r39fea2f r764e009  
    168168}
    169169
    170 SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, std::list<Statement *> &statements ):
     170SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, const std::list<Statement *> &statements ):
    171171        Statement( labels ), condition( condition ), statements( statements ) {
    172172}
     
    196196}
    197197
    198 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
     198CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    199199        Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    200200        if ( isDefault() && condition != 0 )
     
    497497}
    498498
    499 std::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 
    508499// Local Variables: //
    509500// tab-width: 4 //
  • TabularUnified src/SynTree/Statement.h

    r39fea2f r764e009  
    4444
    4545        virtual Statement *clone() const = 0;
    46         virtual void accept( Visitor &v ) = 0;
     46        virtual void accept( Visitor &v ) override = 0;
    4747        virtual Statement *acceptMutator( Mutator &m ) = 0;
    48         virtual void print( std::ostream &os, int indent = 0 ) const;
     48        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4949};
    5050
     
    6161        void push_front( Statement * stmt ) { kids.push_front( stmt ); }
    6262
    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;
     63        virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
     64        virtual void accept( Visitor &v ) override { v.visit( this ); }
     65        virtual CompoundStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     66        virtual void print( std::ostream &os, int indent = 0 ) const override;
    6767};
    6868
     
    7272        NullStmt( std::list<Label> labels );
    7373
    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;
     74        virtual NullStmt *clone() const override { return new NullStmt( *this ); }
     75        virtual void accept( Visitor &v ) override { v.visit( this ); }
     76        virtual NullStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     77        virtual void print( std::ostream &os, int indent = 0 ) const override;
    7878};
    7979
     
    8989        void set_expr( Expression *newValue ) { expr = newValue; }
    9090
    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;
     91        virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
     92        virtual void accept( Visitor &v ) override { v.visit( this ); }
     93        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     94        virtual void print( std::ostream &os, int indent = 0 ) const override;
    9595};
    9696
     
    146146        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    147147
    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;
     148        virtual IfStmt *clone() const override { return new IfStmt( *this ); }
     149        virtual void accept( Visitor &v ) override { v.visit( this ); }
     150        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     151        virtual void print( std::ostream &os, int indent = 0 ) const override;
    152152};
    153153
     
    157157        std::list<Statement *> statements;
    158158
    159         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
     159        SwitchStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements );
    160160        SwitchStmt( const SwitchStmt &other );
    161161        virtual ~SwitchStmt();
     
    166166        std::list<Statement *> & get_statements() { return statements; }
    167167
    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;
     168        virtual void accept( Visitor &v ) override { v.visit( this ); }
     169        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     170
     171        virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
     172        virtual void print( std::ostream &os, int indent = 0 ) const override;
    173173
    174174};
     
    179179        std::list<Statement *> stmts;
    180180
    181         CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     181        CaseStmt( std::list<Label> labels, Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    182182        CaseStmt( const CaseStmt &other );
    183183        virtual ~CaseStmt();
     
    194194        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    195195
    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;
     196        virtual void accept( Visitor &v ) override { v.visit( this ); }
     197        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     198
     199        virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
     200        virtual void print( std::ostream &os, int indent = 0 ) const override;
    201201  private:
    202202        bool _isDefault;
     
    221221        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    222222
    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;
     223        virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
     224        virtual void accept( Visitor &v ) override { v.visit( this ); }
     225        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     226        virtual void print( std::ostream &os, int indent = 0 ) const override;
    227227};
    228228
     
    247247        void set_body( Statement *newValue ) { body = newValue; }
    248248
    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;
     249        virtual ForStmt *clone() const override { return new ForStmt( *this ); }
     250        virtual void accept( Visitor &v ) override { v.visit( this ); }
     251        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     252        virtual void print( std::ostream &os, int indent = 0 ) const override;
    253253};
    254254
     
    276276        const char *get_typename() { return brType[ type ]; }
    277277
    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;
     278        virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
     279        virtual void accept( Visitor &v ) override { v.visit( this ); }
     280        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     281        virtual void print( std::ostream &os, int indent = 0 ) const override;
    282282  private:
    283283        static const char *brType[];
     
    295295        void set_expr( Expression *newValue ) { expr = newValue; }
    296296
    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;
     297        virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
     298        virtual void accept( Visitor &v ) override { v.visit( this ); }
     299        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     300        virtual void print( std::ostream &os, int indent = 0 ) const override;
    301301};
    302302
     
    319319        void set_target( Expression * newTarget ) { target = newTarget; }
    320320
    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;
     321        virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
     322        virtual void accept( Visitor &v ) override { v.visit( this ); }
     323        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     324        virtual void print( std::ostream &os, int indent = 0 ) const override;
    325325};
    326326
     
    342342        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    343343
    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;
     344        virtual TryStmt *clone() const override { return new TryStmt( *this ); }
     345        virtual void accept( Visitor &v ) override { v.visit( this ); }
     346        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     347        virtual void print( std::ostream &os, int indent = 0 ) const override;
    348348};
    349349
     
    370370        void set_body( Statement *newValue ) { body = newValue; }
    371371
    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;
     372        virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
     373        virtual void accept( Visitor &v ) override { v.visit( this ); }
     374        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     375        virtual void print( std::ostream &os, int indent = 0 ) const override;
    376376};
    377377
     
    387387        void set_block( CompoundStmt *newValue ) { block = newValue; }
    388388
    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;
     389        virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
     390        virtual void accept( Visitor &v ) override { v.visit( this ); }
     391        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     392        virtual void print( std::ostream &os, int indent = 0 ) const override;
    393393};
    394394
     
    424424        } orelse;
    425425
    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;
     426        virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
     427        virtual void accept( Visitor &v ) override { v.visit( this ); }
     428        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     429        virtual void print( std::ostream &os, int indent = 0 ) const override;
    430430
    431431};
     
    444444        void set_decl( Declaration *newValue ) { decl = newValue; }
    445445
    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;
     446        virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
     447        virtual void accept( Visitor &v ) override { v.visit( this ); }
     448        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     449        virtual void print( std::ostream &os, int indent = 0 ) const override;
    450450};
    451451
     
    466466        void set_callStmt( Statement * newValue ) { callStmt = newValue; }
    467467
    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 
    475 std::ostream & operator<<( std::ostream & out, const Statement * statement );
     468        virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
     469        virtual void accept( Visitor &v ) override { v.visit( this ); }
     470        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     471        virtual void print( std::ostream &os, int indent = 0 ) const override;
     472};
    476473
    477474// Local Variables: //
  • TabularUnified src/SynTree/Type.cc

    r39fea2f r764e009  
    9999const Type::Qualifiers noQualifiers;
    100100
    101 std::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 
    110101// Local Variables: //
    111102// tab-width: 4 //
  • TabularUnified src/SynTree/Type.h

    r39fea2f r764e009  
    192192        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    193193
    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;
     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;
    201201};
    202202
     
    235235        void set_kind( Kind newValue ) { kind = newValue; }
    236236
    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;
     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;
    241241
    242242        bool isInteger() const;
     
    268268        bool is_array() const { return isStatic || isVarLen || dimension; }
    269269
    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;
     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;
    276276};
    277277
     
    296296        void set_isStatic( bool newValue ) { isStatic = newValue; }
    297297
    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;
     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;
    304304};
    305305
     
    315315        void set_base( Type *newValue ) { base = newValue; }
    316316
    317         virtual int referenceDepth() const;
     317        virtual int referenceDepth() const override;
    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 { 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;
     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;
    328328};
    329329
     
    349349        bool isTtype() const;
    350350
    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;
     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;
    355355};
    356356
     
    371371        void set_hoistType( bool newValue ) { hoistType = newValue; }
    372372
    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;
     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;
    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;
     400        virtual bool isComplete() const override;
    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;
    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;
     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;
    411411  private:
    412         virtual std::string typeString() const;
     412        virtual std::string typeString() const override;
    413413};
    414414
     
    430430        std::list< TypeDecl * > * get_baseParameters();
    431431
    432         virtual bool isComplete() const;
     432        virtual bool isComplete() const override;
    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;
    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;
     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;
    443443  private:
    444         virtual std::string typeString() const;
     444        virtual std::string typeString() const override;
    445445};
    446446
     
    459459        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
    460460
    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 ); }
     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 ); }
    466466  private:
    467         virtual std::string typeString() const;
     467        virtual std::string typeString() const override;
    468468};
    469469
     
    480480        ~TraitInstType();
    481481
    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 ); }
     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 ); }
    487487  private:
    488         virtual std::string typeString() const;
     488        virtual std::string typeString() const override;
    489489};
    490490
     
    507507        void set_isFtype( bool newValue ) { isFtype = newValue; }
    508508
    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;
     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;
    515515  private:
    516         virtual std::string typeString() const;
     516        virtual std::string typeString() const override;
    517517};
    518518
     
    530530
    531531        std::list<Type *> & get_types() { return types; }
    532         virtual unsigned size() const { return types.size(); };
     532        virtual unsigned size() const override { 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 ) {
     541        virtual Type * getComponent( unsigned i ) override {
    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 { 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;
     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;
    552552};
    553553
     
    563563        void set_expr( Expression *newValue ) { expr = newValue; }
    564564
    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;
     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;
    571571};
    572572
     
    592592        void set_isType( bool newValue ) { isType = newValue; }
    593593
    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;
     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;
    600600};
    601601
     
    606606        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    607607
    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;
     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;
    614614};
    615615
     
    620620        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    621621
    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;
     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;
    626626};
    627627
     
    632632        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    633633
    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 
    640 std::ostream & operator<<( std::ostream & out, const Type * type );
     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};
    641639
    642640// Local Variables: //
  • TabularUnified src/libcfa/concurrency/monitor

    r39fea2f r764e009  
    2121#include "invoke.h"
    2222#include "stdlib"
     23
     24trait is_monitor(dtype T) {
     25        monitor_desc * get_monitor( T & );
     26        void ^?{}( T & mutex );
     27};
    2328
    2429static inline void ?{}(monitor_desc & this) {
     
    106111};
    107112
    108 int __accept_internal( unsigned short count, __acceptable_t * acceptables );
     113int __waitfor_internal( unsigned short count, __acceptable_t * acceptables, int duration );
    109114
    110115// Local Variables: //
  • TabularUnified src/libcfa/concurrency/monitor.c

    r39fea2f r764e009  
    398398//-----------------------------------------------------------------------------
    399399// Internal scheduling
    400 int __accept_internal( unsigned short acc_count, __acceptable_t * acceptables ) {
     400int __waitfor_internal( unsigned short acc_count, __acceptable_t * acceptables ) {
    401401        thread_desc * thrd = this_thread;
    402402
  • TabularUnified src/tests/sched-ext-parse.c

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

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