Commit 6ee4ca44 authored by Allan MILHOMME's avatar Allan MILHOMME

m

parent 5d757ac9
package inflow;
import language.parser.tokens.Expression;
public class LoopInflow extends BasicInflow {
public final LoopValue value = new LoopValue(this);
public LoopInflow(BasicInflow p) {
super(p);
}
public Expression getConditionExp() {return null;}
public HigherInfo updateInfos() {
HigherInfo loopedInfos = this.currentInfos.toLoop(value);
HigherInfo deduced = this.getConditionExp().toOperationList().knowing(false, loopedInfos);
HigherInfo newInfos = new AndInfo(loopedInfos, deduced);
return newInfos.removeInfosOn(new OperationList(value), newInfos);
}
}
package inflow;
public class LoopValue implements Value {
public final WhileInflow loop;
public final LoopInflow loop;
public LoopValue(WhileInflow l) {
public LoopValue(LoopInflow l) {
this.loop = l;
}
}
package inflow;
public class WhileInflow extends BasicInflow {
public final LoopValue value = new LoopValue(this);
public WhileInflow(BasicInflow p) {
super(p);
}
}
......@@ -101,14 +101,22 @@ public class Calcul {
return this.applyInf0().apply(new MethodUse(OperationEnum.BOOL_NOT));
}
@Override
public Calcul toLoop(Value assignedTo, LoopValue value) {
if (this.isConstant())
return this;
LinkedList<Value> values = new LinkedList<>();
values.add(assignedTo);
if (this.calc1.getMult(values))
if (this.calc2.isConstant() && this.calc2.getConstant() == 1 && this.calc1.elements.size() == 2)
if (this.calc1.getMult(values) == 1 && this.calc1.getMult(new LinkedList<>()) != 0) {
Element e1 = new Element((VariableValue)assignedTo);
Element e2 = new Element(this.calc1.getMult(new LinkedList<>()));
LinkedList<Element> els = new LinkedList<>();
els.add(e1); els.add(e2);
return new Calcul(new Ligne(els));
}
return null;
}
}
......@@ -126,7 +134,7 @@ class Ligne {
this.elements.add(new Element(var));
}
private Ligne(LinkedList<Element> e) {
public Ligne(LinkedList<Element> e) {
this.elements = e;
}
......
package info;
import compiler.UnitCompiler;
import compiler.Variable;
import inflow.*;
import inflow.AndInfo;
import inflow.ConstantValue;
import inflow.HigherInfo;
import inflow.IfInfo;
import inflow.LoopValue;
import inflow.MethodUse;
import inflow.NoInfo;
import inflow.OperationEnum;
import inflow.OperationList;
import inflow.OrInfo;
import inflow.Value;
import inflow.ValueInfo;
import inflow.VariableValue;
public class IntRangeInfo extends Info {
public final Calcul min, max;
......@@ -268,10 +279,6 @@ public class IntRangeInfo extends Info {
@Override
public Info toLoop(Value assignedTo, LoopValue value) {
Calcul newMin = this.min.isConstant() ? this.min : null;
Calcul newMax = this.max.isConstant() ? this.max : null;
if (this.min.equals(new Calcul(new Ligne())))
return new IntRangeInfo(this.min.toLoop(assignedTo, value), this.max.toLoop(assignedTo, value));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment