diff options
author | sbrandt <sbrandt@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2014-09-16 19:18:13 +0000 |
---|---|---|
committer | sbrandt <sbrandt@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2014-09-16 19:18:13 +0000 |
commit | 15751b14ac9d795d8df1af3e27e72b55b9840c8c (patch) | |
tree | 3c8f38290a2b888b310ce72d658b8a2f819c3e13 | |
parent | fb6231734149ba98fc4b61fa800fe5c3996379a5 (diff) |
Ticket 1651: Applying write-after-read patch.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@5129 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r-- | src/piraha/Call.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/piraha/Call.cc b/src/piraha/Call.cc index 1f6969e8..b278bebb 100644 --- a/src/piraha/Call.cc +++ b/src/piraha/Call.cc @@ -221,6 +221,24 @@ std::map<std::string,smart_ptr<Value> > variables; smart_ptr<Value> eval_expr(std::string inp); +enum read_write { init, read, write }; + +typedef std::map<std::string,read_write> read_write_tracker_type; +read_write_tracker_type read_write_tracker; + +read_write& read_write_status(std::string& key) { + if(read_write_tracker.find(key) == read_write_tracker.end()) + read_write_tracker[key] = init; + return read_write_tracker[key]; +} + +read_write& read_write_status(std::string& thorn,std::string& name) { + std::ostringstream msg; + msg << thorn << "::" << name; + std::string key = msg.str(); + return read_write_status(key); +} + // If the value was already defined in this parameter file, look // it up in the map. Otherwise, get it from Cactus. smart_ptr<Value> find_val(smart_ptr<Group> gr,std::string thorn,std::string name) { @@ -234,6 +252,9 @@ smart_ptr<Value> find_val(smart_ptr<Group> gr,std::string thorn,std::string name std::string par = get_parfile(); CCTK_Error(gr->line(),par.c_str(),current_thorn.c_str(),msg.str().c_str()); } + read_write& status = read_write_status(thorn,name); + if(status == init) + status = read; switch(type) { case PARAMETER_REAL: @@ -938,6 +959,13 @@ extern "C" int cctk_PirahaParser(const char *buffer,unsigned long buffersize,int smv->booleanize(gr); check_types(thorn.c_str(),aexpr->line(),smv,data->type); } + read_write status = read_write_status(key); + if(status == read) { + std::ostringstream msg; + msg << "Write after read: " << key << std::endl; + std::string par = get_parfile(); + CCTK_Error(gr->line(),par.c_str(),current_thorn.c_str(),msg.str().c_str()); + } set_function( key.c_str(), val.c_str(), @@ -957,6 +985,14 @@ extern "C" int cctk_PirahaParser(const char *buffer,unsigned long buffersize,int smv->booleanize(gr); check_types(thorn.c_str(),aexpr->line(),smv,data->type); } + std::string keyi_str = keyi.str(); + read_write status = read_write_status(keyi_str); + if(status == read) { + std::ostringstream msg; + msg << "Write after read: " << keyi.str() << std::endl; + std::string par = get_parfile(); + CCTK_Error(gr->line(),par.c_str(),current_thorn.c_str(),msg.str().c_str()); + } set_function( keyi.str().c_str(), val.c_str(), |