Changeset 310e5b7 for src/Concurrency


Ignore:
Timestamp:
Sep 14, 2017, 4:26:54 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:
e149f77
Parents:
1dcd9554
Message:

Fix some issues with waitfor... it appears to work!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waitfor.cc

    r1dcd9554 r310e5b7  
    204204                        return new ConstantExpr( Constant::from_bool( ifnull ) );
    205205                }
     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 * betterIsDtor( 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                }
    206221        };
    207222
     
    212227
    213228        void GenerateWaitForPass::premutate( FunctionDecl * decl) {
    214                 if( decl->name != "__accept_internal" ) return;
     229                if( decl->name != "__waitfor_internal" ) return;
    215230
    216231                decl_waitfor = decl;
     
    313328                Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
    314329
     330                Expression * is_dtor = betterIsDtor( clause.target.function );
    315331                CompoundStmt * compound = new CompoundStmt( noLabels );
    316332                compound->push_back( makeAccStatement( acceptables, index, "func"    , new CastExpr( clause.target.function, fptr_t )                            , indexer ) );
    317333                compound->push_back( makeAccStatement( acceptables, index, "count"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ) );
    318334                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 ) );
     335                compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , is_dtor                                                                   , indexer ) );
    320336
    321337                stmt->push_back( new IfStmt(
Note: See TracChangeset for help on using the changeset viewer.