Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring compareTo()'s #299

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public String toString() {
return "fake";
}

@Override
protected int compareSameClass(
Statement o) {
return 0;
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> forwardSemantics(
AnalysisState<A> entryState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public IMPArrayLength(
super(cfg, location, "arraylen", parameter);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdUnarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import it.unive.lisa.program.SourceCodeLocation;
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.program.type.StringType;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
Expand Down Expand Up @@ -56,6 +57,12 @@ public IMPAddOrConcat(
super(cfg, new SourceCodeLocation(sourceFile, line, col), "+", left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.statement.BinaryExpression;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.heap.AccessChild;
import it.unive.lisa.symbolic.heap.HeapDereference;
Expand Down Expand Up @@ -47,6 +48,12 @@ public IMPArrayAccess(
super(cfg, new SourceCodeLocation(sourceFile, line, col), "[]", container, location);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.SourceCodeLocation;
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.program.cfg.statement.UnaryStatement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.Skip;
Expand Down Expand Up @@ -39,6 +40,12 @@ public IMPAssert(
super(cfg, new SourceCodeLocation(sourceFile, line, col), "assert", expression);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdUnarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.NaryExpression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.program.type.Int32Type;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.heap.AccessChild;
Expand Down Expand Up @@ -62,6 +63,12 @@ public IMPNewArray(
this.staticallyAllocated = staticallyAllocated;
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return Boolean.compare(staticallyAllocated, ((IMPNewArray) o).staticallyAllocated);
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> forwardSemanticsAux(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.NaryExpression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.program.cfg.statement.VariableRef;
import it.unive.lisa.program.cfg.statement.call.Call.CallType;
import it.unive.lisa.program.cfg.statement.call.UnresolvedCall;
Expand Down Expand Up @@ -64,6 +65,12 @@ public IMPNewObj(
this.staticallyAllocated = staticallyAllocated;
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return Boolean.compare(staticallyAllocated, ((IMPNewObj) o).staticallyAllocated);
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> forwardSemanticsAux(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonEq;
Expand Down Expand Up @@ -37,6 +38,12 @@ public Equal(
super(cfg, location, "==", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonGe;
Expand Down Expand Up @@ -40,6 +41,12 @@ public GreaterOrEqual(
super(cfg, location, ">=", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonGt;
Expand Down Expand Up @@ -40,6 +41,12 @@ public GreaterThan(
super(cfg, location, ">", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonLe;
Expand Down Expand Up @@ -40,6 +41,12 @@ public LessOrEqual(
super(cfg, location, "<=", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonLt;
Expand Down Expand Up @@ -40,6 +41,12 @@ public LessThan(
super(cfg, location, "<", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.ComparisonNe;
Expand Down Expand Up @@ -37,6 +38,12 @@ public NotEqual(
super(cfg, location, "!=", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ public boolean equals(
return true;
}

@Override
protected int compareSameClass(
Statement o) {
AccessGlobal other = (AccessGlobal) o;
int cmp;
if ((cmp = container.getName().compareTo(other.container.getName())) != 0)
return cmp;
return target.getName().compareTo(other.target.getName());
}

@Override
public String toString() {
return container.getName() + "::" + target.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.program.cfg.statement.UnaryExpression;
import it.unive.lisa.program.language.hierarchytraversal.HierarcyTraversalStrategy;
import it.unive.lisa.symbolic.SymbolicExpression;
Expand Down Expand Up @@ -100,6 +101,13 @@ public boolean equals(
return true;
}

@Override
protected int compareSameClassAndParams(
Statement o) {
AccessInstanceGlobal other = (AccessInstanceGlobal) o;
return target.compareTo(other.target);
}

@Override
public String toString() {
return getSubExpression() + "::" + target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.LogicalAnd;
Expand Down Expand Up @@ -39,6 +40,12 @@ public And(
super(cfg, location, "&&", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.UnaryExpression;
import it.unive.lisa.symbolic.value.operator.unary.LogicalNegation;
Expand Down Expand Up @@ -37,6 +38,12 @@ public Not(
super(cfg, location, "!", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), expression);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdUnarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.LogicalOr;
Expand Down Expand Up @@ -39,6 +40,12 @@ public Or(
super(cfg, location, "||", cfg.getDescriptor().getUnit().getProgram().getTypes().getBooleanType(), left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unive.lisa.program.cfg.CFG;
import it.unive.lisa.program.cfg.CodeLocation;
import it.unive.lisa.program.cfg.statement.Expression;
import it.unive.lisa.program.cfg.statement.Statement;
import it.unive.lisa.symbolic.SymbolicExpression;
import it.unive.lisa.symbolic.value.BinaryExpression;
import it.unive.lisa.symbolic.value.operator.binary.NumericNonOverflowingAdd;
Expand Down Expand Up @@ -40,6 +41,12 @@ public Addition(
super(cfg, location, "+", left, right);
}

@Override
protected int compareSameClassAndParams(
Statement o) {
return 0; // no extra fields to compare
}

@Override
public <A extends AbstractState<A>> AnalysisState<A> fwdBinarySemantics(
InterproceduralAnalysis<A> interprocedural,
Expand Down
Loading
Loading