for (Statement it : __stmt.GetSurroundedStatements())
this.Normalize(it, new Condition(new Inequation(true)), __map, c);
Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);
IntegerPointer f = new IntegerPointer();
IntegerPointer l = new IntegerPointer();
IntegerPointer useless = new IntegerPointer();
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);
it = __stmt.GetSurroundedStatements().get(0);
it.GetEnclosed(f, useless);
__stmt.SetEnclosed(f.getValue(), l.getValue());
return;
}
if (__stmt.IsAssignment()) {
int __id = normalized_stmts.size();
List<Read_Reference> vr = new ArrayList<Read_Reference>();
List<Written_Reference> vw = new ArrayList<Written_Reference>();
Global.CollectReferences(__stmt.GetAssignment().GetLHSIndex(), vr);
Global.CollectReferences(__stmt.GetAssignment().GetRHSExpression(), vr);
Written_Reference wr = new Written_Reference(__stmt.GetAssignment().GetLHSArray(), __stmt.GetAssignment().GetLHSIndex());
vw.add(wr);
References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
__stmt.SetEnclosed(__id, __id);
Global.Connect(__stmt, new_stmt);
normalized_stmts.add(new_stmt);
//log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
return;
}
if (__stmt.IsControl()) {
if (__stmt.GetControl().IsWhileLoop()) {
// cout<<"\nProgram::Normalize, while loops are not handled yet\n";
// exit(EXIT_FAILURE);
List<Read_Reference> vr = new ArrayList<Read_Reference>();
List<Written_Reference> vw = new ArrayList<Written_Reference>();
Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);
int __id = normalized_stmts.size();
__counters.add(__stmt.GetControl().GetCounter());
Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
List<Expression> iteration = new ArrayList<Expression>();
for (String it : __counters)
iteration.add(new Expression(it));
new_domain.GetRightChild().Instanciate(__id, iteration);
__controls.put(__id, new DomainConstraint(new_domain.GetRightChild()));
References new_stmt = new References(__id, __counters, new_domain, __controls, vr, vw, __stmt);
new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
Global.Connect(__stmt, new_stmt);
normalized_stmts.add(new_stmt);
//log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
for (Statement it : __stmt.GetSurroundedStatements())
this.Normalize(it, new_domain, __controls, __counters);
Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);
IntegerPointer l = new IntegerPointer();
IntegerPointer useless = new IntegerPointer();
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);
__stmt.SetEnclosed(__id, l.getValue());
return;
}
if (__stmt.GetControl().IsIf()) {
int __id = normalized_stmts.size();
List<Read_Reference> vr = new ArrayList<Read_Reference>();
List<Written_Reference> vw = new ArrayList<Written_Reference>(); // no written variable
Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);
References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
Global.Connect(__stmt, new_stmt);
normalized_stmts.add(new_stmt);
//log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
List<Expression> iteration = new ArrayList<Expression>();
for (String it : __counters)
iteration.add(new Expression(it));
new_domain.GetRightChild().Instanciate(__id, iteration);
__controls.put(__id, new DomainConstraint(new_domain.GetRightChild())); // positive
for (Statement it : __stmt.GetSurroundedStatements())
this.Normalize(it, new_domain, __controls, __counters);
Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);
IntegerPointer l = new IntegerPointer();
IntegerPointer useless = new IntegerPointer();
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);
__stmt.SetEnclosed(__id, l.getValue());
return;
}
if (__stmt.GetControl().IsIfElse()) {
int __id = normalized_stmts.size();
List<Read_Reference> vr = new ArrayList<Read_Reference>();
List<Written_Reference> vw = new ArrayList<Written_Reference>(); // no written reference
Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);
References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
Global.Connect(__stmt, new_stmt);
normalized_stmts.add(new_stmt);
//log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
List<Expression> iteration = new ArrayList<Expression>();
for (String it : __counters)
iteration.add(new Expression(it));
new_domain.GetRightChild().Instanciate(__id, iteration);
Map<Integer, DomainConstraint> then = __controls = new HashMap<Integer, DomainConstraint>();
then.put(__id, new DomainConstraint(new_domain.GetRightChild())); // positive
for (Statement it : __stmt.GetSurroundedStatements())
this.Normalize(it, new_domain, then, __counters);
__controls.put(__id, new DomainConstraint(new_domain.GetRightChild(), false)); // positive
Condition new_else_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl()
.GetRegularDomain().FastNegation());
for (Statement it : __stmt.GetElseSurroundedStatements())
this.Normalize(it, new_else_domain, __controls, __counters);
Statement it = __stmt.GetElseSurroundedStatements().get(__stmt.GetElseSurroundedStatements().size() - 1);
IntegerPointer f = new IntegerPointer();
IntegerPointer l = new IntegerPointer();
IntegerPointer useless = new IntegerPointer();
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);
it = __stmt.GetElseSurroundedStatements().get(0);
it.GetEnclosed(f, useless);
__stmt.SetElseEnclosed(f.getValue(), l.getValue());
// it=__stmt.GetSurroundedStatements().begin();
// it.GetEnclosed(&f,&useless);
it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);
__stmt.SetEnclosed(__id, l.getValue());
return;
}
if (__stmt.GetControl().IsForLoop()) {
// cout<<"\nProgram::Normalize, it is a for loop\n";
// exit(EXIT_FAILURE);
List<Read_Reference> vr = new ArrayList<Read_Reference>();
List<Written_Reference> vw = new ArrayList<Written_Reference>();
Global.CollectReferences(__stmt.GetControl().GetForLowerBound(), vr);
Global.CollectReferences(__stmt.GetControl().GetForUpperBound(), vr);
int __id = normalized_stmts.size();
References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
Global.Connect(__stmt, new_stmt);
normalized_stmts.add(new_stmt);
//log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
__counters.add(__stmt.GetControl().GetCounter());
List<Expression> iteration = new ArrayList<Expression>();
for (String it : __counters)
iteration.add(new Expression(it));
new_domain.GetRightChild().Instanciate(__id, iteration);
__controls.put(__id, new DomainConstraint(new_domain.GetRightChild()));
for (Statement it : __stmt.GetSurroundedStatements())
this.Normalize(it, new_domain, __controls, __counters);
Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);
IntegerPointer l = new IntegerPointer();
IntegerPointer useless = new IntegerPointer();
if (it.IsControl() && it.GetControl().IsIfElse())
it.GetElseEnclosed(useless, l);
else
it.GetEnclosed(useless, l);