Changeset 1cb758f2 for src/Concurrency


Ignore:
Timestamp:
Aug 27, 2017, 11:26:26 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, stuck-waitfor-destruct, with_gc
Children:
111a8af8, 26238c1, 7ee1e2f6
Parents:
0c6596f (diff), eca3d10a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r0c6596f r1cb758f2  
    201201                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
    202202                void validate( DeclarationWithType * );
    203                 void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);
     203                void addStatments( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
    204204
    205205                static void implement( std::list< Declaration * > & translationUnit ) {
     
    211211                StructDecl* monitor_decl = nullptr;
    212212                StructDecl* guard_decl = nullptr;
     213
     214                static std::unique_ptr< Type > generic_func;
    213215        };
     216
     217        std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >(
     218                new FunctionType(
     219                        noQualifiers,
     220                        true
     221                )
     222        );
    214223
    215224        //-----------------------------------------------------------------------------
     
    395404        // Mutex keyword implementation
    396405        //=============================================================================================
     406
    397407        void MutexKeyword::visit(FunctionDecl* decl) {
    398408                Visitor::visit(decl);
     
    411421                if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
    412422
    413                 addStatments( body, mutexArgs );
     423                addStatments( decl, body, mutexArgs );
    414424        }
    415425
     
    458468        }
    459469
    460         void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
     470        void MutexKeyword::addStatments( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
    461471                ObjectDecl * monitors = new ObjectDecl(
    462472                        "__monitors",
     
    489499                );
    490500
     501                assert(generic_func);
     502
    491503                //in reverse order :
    492                 // monitor_guard_t __guard = { __monitors, # };
     504                // monitor_guard_t __guard = { __monitors, #, func };
    493505                body->push_front(
    494506                        new DeclStmt( noLabels, new ObjectDecl(
     
    504516                                        {
    505517                                                new SingleInit( new VariableExpr( monitors ) ),
    506                                                 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
     518                                                new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ),
     519                                                new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )
    507520                                        },
    508521                                        noDesignators,
Note: See TracChangeset for help on using the changeset viewer.