Skip to content

Commit

Permalink
bug fixing for the reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuejun Yang committed Jun 3, 2011
1 parent d2b0dc1 commit 9daf965
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Reducer.cpp
Expand Up @@ -106,6 +106,22 @@ Reducer::configure(void)
StringUtils::chop(line);
// make sure the focus var is marked as used var
const Variable* key = VariableSelector::find_var_by_name(line);
if (key == NULL) {
// it's possible an array variable that is not specifically itemized in the
// program that is the focus var. we manually itemize it here
vector<string> strs;
StringUtils::split_string(line, strs, "[]");
const Variable* ary = VariableSelector::find_var_by_name(strs[0]);
assert(ary && ary->isArray);
const ArrayVariable* av = (const ArrayVariable*)ary;
vector<int> indices;
for (size_t k=0; k<av->get_dimension(); k++) {
assert(k + 1 < strs.size());
indices.push_back(StringUtils::str2int(strs[k+1]));
}
av->itemize(indices);
}
key = VariableSelector::find_var_by_name(line);
assert(key);
monitored_var = key;
used_vars.push_back(key->get_named_var());
Expand Down

0 comments on commit 9daf965

Please sign in to comment.