Changeset 1dcd9554


Ignore:
Timestamp:
Sep 14, 2017, 3:42:14 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
310e5b7
Parents:
f92c696
Message:

First "working" implementation of waitfor

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rf92c696 r1dcd9554  
    865865        void CodeGenerator::visit( CaseStmt * caseStmt ) {
    866866                updateLocation( caseStmt );
     867                output << indent;
    867868                if ( caseStmt->isDefault()) {
    868869                        output << "default";
  • src/Concurrency/Waitfor.cc

    rf92c696 r1dcd9554  
    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
     
    227223                        assert( !decl_acceptable );
    228224                        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 
    236225                }
    237226                else if( decl->name == "monitor_desc" ) {
     
    242231
    243232        Statement * GenerateWaitForPass::postmutate( WaitForStmt * waitfor ) {
    244                 return waitfor;
    245 
    246233                if( !decl_monitor || !decl_acceptable ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor );
    247234
     
    265252                );
    266253
    267                 // Expression * result  = call( acceptables, timeout, orelse, stmt );
    268 
    269                 // choose( waitfor, result );
     254                Expression * result = call( waitfor->clauses.size(), acceptables, timeout, stmt );
     255
     256                choose( waitfor, result, stmt );
    270257
    271258                return stmt;
     
    274261        ObjectDecl * GenerateWaitForPass::declare( unsigned long count, CompoundStmt * stmt )
    275262        {
    276                 ObjectDecl * acceptables = new ObjectDecl(
     263                ObjectDecl * acceptables = ObjectDecl::newObject(
    277264                        namer_acc.newName(),
    278                         noStorage,
    279                         LinkageSpec::Cforall,
    280                         nullptr,
    281265                        new ArrayType(
    282266                                noQualifiers,
     
    299283        ObjectDecl * GenerateWaitForPass::declMon( WaitForStmt::Clause & clause, CompoundStmt * stmt ) {
    300284
    301                 ObjectDecl * mon = new ObjectDecl(
     285                ObjectDecl * mon = ObjectDecl::newObject(
    302286                        namer_mon.newName(),
    303                         noStorage,
    304                         LinkageSpec::Cforall,
    305                         nullptr,
    306287                        new ArrayType(
    307288                                noQualifiers,
     
    330311                ObjectDecl * monitors = declMon( clause, stmt );
    331312
     313                Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
     314
    332315                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 ) ) ) );
     316                compound->push_back( makeAccStatement( acceptables, index, "func"    , new CastExpr( clause.target.function, fptr_t )                            , indexer ) );
     317                compound->push_back( makeAccStatement( acceptables, index, "count"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ) );
     318                compound->push_back( makeAccStatement( acceptables, index, "monitors", new VariableExpr( monitors )                                              , indexer ) );
     319                compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , new ConstantExpr( Constant::from_bool( true ) )                           , indexer ) );
    337320
    338321                stmt->push_back( new IfStmt(
     
    355338                CompoundStmt * stmt
    356339        ) {
    357                 ObjectDecl * timeout = new ObjectDecl(
     340                ObjectDecl * timeout = ObjectDecl::newObject(
    358341                        namer_tim.newName(),
    359                         noStorage,
    360                         LinkageSpec::Cforall,
    361                         nullptr,
    362342                        new BasicType(
    363343                                noQualifiers,
     
    374354                        stmt->push_back( new IfStmt(
    375355                                noLabels,
    376                                 safeCond( else_cond ),
     356                                safeCond( time_cond ),
    377357                                new ExprStmt(
    378358                                        noLabels,
     
    407387                return new VariableExpr( timeout );
    408388        }
     389
     390        Expression * GenerateWaitForPass::call(
     391                size_t count,
     392                ObjectDecl * acceptables,
     393                Expression * timeout,
     394                CompoundStmt * stmt
     395        ) {
     396                ObjectDecl * decl = ObjectDecl::newObject(
     397                        namer_ret.newName(),
     398                        new BasicType(
     399                                noQualifiers,
     400                                BasicType::LongLongUnsignedInt
     401                        ),
     402                        new SingleInit(
     403                                new UntypedExpr(
     404                                        VariableExpr::functionPointer( decl_waitfor ),
     405                                        {
     406                                                new ConstantExpr( Constant::from_ulong( count ) ),
     407                                                new VariableExpr( acceptables ),
     408                                                timeout
     409                                        }
     410                                )
     411                        )
     412                );
     413
     414                stmt->push_back( new DeclStmt( noLabels, decl ) );
     415
     416                return new VariableExpr( decl );
     417        }
     418
     419        void GenerateWaitForPass::choose(
     420                WaitForStmt * waitfor,
     421                Expression  * result,
     422                CompoundStmt * stmt
     423        ) {
     424                SwitchStmt * swtch = new SwitchStmt(
     425                        noLabels,
     426                        result,
     427                        std::list<Statement *>()
     428                );
     429
     430                unsigned long i = 0;
     431                for( auto & clause : waitfor->clauses ) {
     432                        swtch->statements.push_back(
     433                                new CaseStmt(
     434                                        noLabels,
     435                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     436                                        {
     437                                                clause.statement,
     438                                                new BranchStmt(
     439                                                        noLabels,
     440                                                        "",
     441                                                        BranchStmt::Break
     442                                                )
     443                                        }
     444                                )
     445                        );
     446                }
     447
     448                if(waitfor->timeout.statement) {
     449                        swtch->statements.push_back(
     450                                new CaseStmt(
     451                                        noLabels,
     452                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     453                                        {
     454                                                waitfor->timeout.statement,
     455                                                new BranchStmt(
     456                                                        noLabels,
     457                                                        "",
     458                                                        BranchStmt::Break
     459                                                )
     460                                        }
     461                                )
     462                        );
     463                }
     464
     465                if(waitfor->orelse.statement) {
     466                        swtch->statements.push_back(
     467                                new CaseStmt(
     468                                        noLabels,
     469                                        new ConstantExpr( Constant::from_ulong( i++ ) ),
     470                                        {
     471                                                waitfor->orelse.statement,
     472                                                new BranchStmt(
     473                                                        noLabels,
     474                                                        "",
     475                                                        BranchStmt::Break
     476                                                )
     477                                        }
     478                                )
     479                        );
     480                }
     481
     482                stmt->push_back( swtch );
     483        }
    409484};
    410485
  • src/Parser/StatementNode.cc

    rf92c696 r1dcd9554  
    234234                target,
    235235                maybeMoveBuild<Statement >( stmt ),
    236                 maybeMoveBuild<Expression>( when )
     236                notZeroExpr( maybeMoveBuild<Expression>( when ) )
    237237        });
    238238
     
    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 ) {
  • src/ResolvExpr/AlternativeFinder.cc

    rf92c696 r1dcd9554  
    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 >
  • src/ResolvExpr/AlternativeFinder.h

    rf92c696 r1dcd9554  
    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 >
  • src/ResolvExpr/Resolver.cc

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

    rf92c696 r1dcd9554  
    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 )
  • src/SynTree/Statement.h

    rf92c696 r1dcd9554  
    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();
     
    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();
  • src/libcfa/concurrency/monitor

    rf92c696 r1dcd9554  
    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 __accept_internal( unsigned short count, __acceptable_t * acceptables, int duration );
    109114
    110115// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.