~zorba-coders/zorba/bugs-912586-912593-912722

« back to all changes in this revision

Viewing changes to src/compiler/rewriter/tools/expr_tools.cpp

  • Committer: Cezar Andrei
  • Date: 2012-03-28 15:42:12 UTC
  • mfrom: (10606.1.129 zorba)
  • Revision ID: cezar.lp@cezarandrei.com-20120328154212-jh2heq49xcqjppce
Merge from trunck and resolve ChangeLog conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
 
125
125
 
126
126
/*******************************************************************************
127
 
 
128
 
********************************************************************************/
129
 
const var_ptr_set& get_varset_annotation(const expr* e) 
130
 
{
131
 
  static var_ptr_set no_free_vars;
132
 
 
133
 
  AnnotationValue_t ann = e->get_annotation(Annotations::FREE_VARS);
134
 
  return (ann == NULL ?
135
 
          no_free_vars :
136
 
          dynamic_cast<VarSetAnnVal *>(ann.getp())->theVarset);
137
 
}
138
 
 
139
 
 
140
 
/*******************************************************************************
141
127
  copy annotations when wrapping an expression in a new one
142
128
********************************************************************************/
143
129
expr_t fix_annotations(expr* new_expr, const expr* old_expr) 
155
141
    }
156
142
  }
157
143
  
158
 
  for (int k = 0; k < Annotations::MAX_ANNOTATION; ++k) 
159
 
  {
160
 
    if (k == Annotations::FREE_VARS)
161
 
    {
162
 
      const var_ptr_set& old_set = get_varset_annotation(old_expr);
163
 
      const var_ptr_set& new_set = get_varset_annotation(new_expr);
164
 
 
165
 
      var_ptr_set s;
166
 
      std::set_union(old_set.begin(),
167
 
                     old_set.end(),
168
 
                     new_set.begin(),
169
 
                     new_set.end(),
170
 
                     inserter(s, s.begin()));
171
 
 
172
 
      new_expr->put_annotation(static_cast<Annotations::Key>(k),
173
 
                               AnnotationValue_t(new VarSetAnnVal(s)));
174
 
    }
175
 
  }
176
 
  
 
144
  const expr::FreeVars& old_set = old_expr->getFreeVars();
 
145
  const expr::FreeVars& new_set = new_expr->getFreeVars();
 
146
 
 
147
  expr::FreeVars s;
 
148
  std::set_union(old_set.begin(),
 
149
                 old_set.end(),
 
150
                 new_set.begin(),
 
151
                 new_set.end(),
 
152
                 inserter(s, s.begin()));
 
153
 
 
154
  new_expr->setFreeVars(s);
 
155
 
177
156
  return new_expr;
178
157
}
179
158