[GIT] ppl/ppl(master): Variable shadowing avoided. Scope of variables reduced. One FIXME added.

Module: ppl/ppl Branch: master Commit: 3c3188f08c10a1914cd545f35ba10a6ee464c3b9 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=3c3188f08c10a...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Wed Feb 17 10:16:43 2010 +0100
Variable shadowing avoided. Scope of variables reduced. One FIXME added.
---
demos/ppl_pips/ppl_pips.cc | 48 ++++++++++++++++++++++++++----------------- src/Grid_public.cc | 4 +- src/wrap_assign.hh | 22 ++++++++++---------- 3 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc index 378a65b..edb60da 100644 --- a/demos/ppl_pips/ppl_pips.cc +++ b/demos/ppl_pips/ppl_pips.cc @@ -124,10 +124,13 @@ pip_display_sol(std::ostream& out, using namespace Parma_Polyhedra_Library::IO_Operators; if (!pip) { out << setw(indent*2) << "" << "_|_" << endl; - } else { - PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator i, i_end; - i_end = pip->art_parameter_end(); - for (i = pip->art_parameter_begin(); i != i_end; ++i) { + } + else { + for (PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator + i = pip->art_parameter_begin(), + i_end = pip->art_parameter_end(); + i != i_end; + ++i) { out << setw(indent*2) << "" << "Parameter " << Linear_Expression(Variable(space_dimension++)) << " = " << *i << endl; @@ -137,10 +140,10 @@ pip_display_sol(std::ostream& out, if (!constraints_empty) { out << setw(indent*2) << "" << "if "; for (Constraint_System::const_iterator - begin = constraints.begin(), - end = constraints.end(), - i = begin; i != end; ++i) - out << ((i == begin) ? "" : " and ") << *i; + cs_begin = constraints.begin(), + cs_end = constraints.end(), + i = cs_begin; i != cs_end; ++i) + out << ((i == cs_begin) ? "" : " and ") << *i; out << " then" << endl; } const PIP_Decision_Node* dn = pip->as_decision(); @@ -154,10 +157,10 @@ pip_display_sol(std::ostream& out, const PIP_Solution_Node* sn = pip->as_solution(); out << setw(indent*2 + (constraints_empty ? 0 : 2)) << "" << "{"; for (Variables_Set::const_iterator - begin = vars.begin(), - end = vars.end(), - i = begin; i != end; ++i) - out << ((i == begin) ? "" : " ; ") + v_begin = vars.begin(), + v_end = vars.end(), + i = v_begin; i != v_end; ++i) + out << ((i == v_begin) ? "" : " ; ") << sn->parametric_values(Variable(*i), parameters); out << "}" << endl; if (!constraints_empty) { @@ -265,8 +268,10 @@ public: PPL::dimension_type constraint_width; std::string line; getline_nocomment(in, line); - std::istringstream sin(line); - sin >> num_ctx_rows >> num_params; + { + std::istringstream sin(line); + sin >> num_ctx_rows >> num_params; + } num_params -= 2; PPL::Coefficient context[num_ctx_rows][num_params+1]; int ctx_type[num_ctx_rows]; @@ -279,14 +284,19 @@ public: sin >> context[i][j]; } } - getline_nocomment(in, line); - std::istringstream sin2(line); + // FIXME: can this variable be given a better name? int tmp; - sin2 >> tmp; + getline_nocomment(in, line); + { + std::istringstream sin(line); + sin >> tmp; + }
getline_nocomment(in, line); - std::istringstream sin3(line); - sin3 >> num_constraints >> constraint_width; + { + std::istringstream sin(line); + sin >> num_constraints >> constraint_width; + } constraint_width -= 1; num_vars = constraint_width - num_params - 1; PPL::Coefficient constraints[num_constraints][constraint_width]; diff --git a/src/Grid_public.cc b/src/Grid_public.cc index 36b9926..0b30a9e 100644 --- a/src/Grid_public.cc +++ b/src/Grid_public.cc @@ -1611,8 +1611,8 @@ PPL::Grid::simplify_using_context_assign(const Grid& y) { gr.refine_no_check(le == 1); else { Linear_Expression le2; - for (dimension_type i = le.space_dimension(); i-- > 0; ) - le2 += 2 * le.coefficient(Variable(i)) * Variable(i); + for (dimension_type j = le.space_dimension(); j-- > 0; ) + le2 += 2 * le.coefficient(Variable(j)) * Variable(j); le2 += 2 * le.inhomogeneous_term(); gr.refine_no_check(le2 == y_modulus_i); } diff --git a/src/wrap_assign.hh b/src/wrap_assign.hh index 9e55948..fec4ac1 100644 --- a/src/wrap_assign.hh +++ b/src/wrap_assign.hh @@ -312,24 +312,24 @@ wrap_assign(PSET& pointset, quadrants = last_quadrant - first_quadrant + 1;
unsigned extension; - Result r = assign_r(extension, quadrants, ROUND_IGNORE); - if (result_overflow(r) || extension > complexity_threshold) + Result res = assign_r(extension, quadrants, ROUND_IGNORE); + if (result_overflow(res) || extension > complexity_threshold) goto set_full_range;
if (!wrap_individually && !collective_wrap_too_complex) { - r = mul_assign_r(collective_wrap_complexity, - collective_wrap_complexity, extension, ROUND_IGNORE); - if (result_overflow(r) + res = mul_assign_r(collective_wrap_complexity, + collective_wrap_complexity, extension, ROUND_IGNORE); + if (result_overflow(res) || collective_wrap_complexity > complexity_threshold) collective_wrap_too_complex = true; if (collective_wrap_too_complex) { // Set all the dimensions in `translations' to full range. - for (Wrap_Translations::const_iterator i = translations.begin(), - tend = translations.end(); i != tend; ++i) { - const Variable& x = i->var; - pointset.unconstrain(x); - full_range_bounds.insert(min_value <= x); - full_range_bounds.insert(x <= max_value); + for (Wrap_Translations::const_iterator j = translations.begin(), + tend = translations.end(); j != tend; ++j) { + const Variable& y = j->var; + pointset.unconstrain(y); + full_range_bounds.insert(min_value <= y); + full_range_bounds.insert(y <= max_value); } } }
participants (1)
-
Roberto Bagnara