Changeset ef42b143 for src/Concurrency


Ignore:
Timestamp:
Mar 16, 2017, 5:20:16 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:
3743983
Parents:
1fbab5a
Message:

Implemented monitor keyword, and it works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r1fbab5a ref42b143  
    111111          private:
    112112                StructDecl* monitor_decl = nullptr;
     113                StructDecl* guard_decl = nullptr;
    113114        };
    114115
     
    137138                if( ! body ) return;
    138139
    139                 assert(monitor_decl);
    140140                addStatments( body, mutexArgs );
    141141        }
     
    146146                        monitor_decl = decl;
    147147                }
     148                else if( decl->get_name() == "monitor_guard_t" ) {
     149                        assert( !guard_decl );
     150                        guard_decl = decl;
     151                }
    148152        }
    149153
     
    175179
    176180                //Make sure that typed isn't mutex
    177                 if( ! base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );
     181                if( base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );
    178182        }
    179183
    180184        void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
     185                assert(monitor_decl);
     186                assert(guard_decl);
    181187
    182188                ObjectDecl * monitors = new ObjectDecl(
     
    218224                                new StructInstType(
    219225                                        noQualifiers,
    220                                         "monitor_guard_t"
     226                                        guard_decl
    221227                                ),
    222228                                new ListInit(
     
    224230                                                new SingleInit( new VariableExpr( monitors ) ),
    225231                                                new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
    226                                         }
     232                                        },
     233                                        noDesignators,
     234                                        true
    227235                                )
    228236                        ))
    229237                );
    230238
    231                 //monitor_desc * __monitors[] = { a, b };
     239                //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
    232240                body->push_front( new DeclStmt( noLabels, monitors) );
    233241        }
Note: See TracChangeset for help on using the changeset viewer.