Skip to content

Commit

Permalink
Removing 'forward' from dataflow class naming #120
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaneg committed Oct 2, 2023
1 parent 217b756 commit 7776342
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 65 deletions.
12 changes: 6 additions & 6 deletions lisa/lisa-analyses/src/main/java/it/unive/lisa/LiSAFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import it.unive.lisa.analysis.AbstractState;
import it.unive.lisa.analysis.dataflow.DataflowElement;
import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.DefiniteDataflowDomain;
import it.unive.lisa.analysis.dataflow.PossibleDataflowDomain;
import it.unive.lisa.analysis.heap.HeapDomain;
import it.unive.lisa.analysis.nonrelational.heap.HeapEnvironment;
import it.unive.lisa.analysis.nonrelational.heap.NonRelationalHeapDomain;
Expand Down Expand Up @@ -153,10 +153,10 @@ else if (DataflowElement.class.isAssignableFrom(param.getClass())) {
for (Type gi : elem.getGenericInterfaces())
if (gi instanceof ParameterizedType && ((ParameterizedType) gi).getRawType() == DataflowElement.class) {
Type domain = ((ParameterizedType) gi).getActualTypeArguments()[0];
if (((ParameterizedType) domain).getRawType() == PossibleForwardDataflowDomain.class)
return new PossibleForwardDataflowDomain((DataflowElement<?, ?>) param);
else if (((ParameterizedType) domain).getRawType() == DefiniteForwardDataflowDomain.class)
return new DefiniteForwardDataflowDomain((DataflowElement<?, ?>) param);
if (((ParameterizedType) domain).getRawType() == PossibleDataflowDomain.class)
return new PossibleDataflowDomain((DataflowElement<?, ?>) param);
else if (((ParameterizedType) domain).getRawType() == DefiniteDataflowDomain.class)
return new DefiniteDataflowDomain((DataflowElement<?, ?>) param);
else
return param;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public class AvailableExpressions
implements
DataflowElement<DefiniteForwardDataflowDomain<AvailableExpressions>, AvailableExpressions> {
DataflowElement<DefiniteDataflowDomain<AvailableExpressions>, AvailableExpressions> {

private final ValueExpression expression;

Expand Down Expand Up @@ -90,7 +90,7 @@ public Collection<AvailableExpressions> gen(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<AvailableExpressions> domain) {
DefiniteDataflowDomain<AvailableExpressions> domain) {
Collection<AvailableExpressions> result = new HashSet<>();
AvailableExpressions ae = new AvailableExpressions(expression);
if (!ae.getInvolvedIdentifiers().contains(id) && filter(expression))
Expand All @@ -102,7 +102,7 @@ public Collection<AvailableExpressions> gen(
public Collection<AvailableExpressions> gen(
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<AvailableExpressions> domain) {
DefiniteDataflowDomain<AvailableExpressions> domain) {
Collection<AvailableExpressions> result = new HashSet<>();
AvailableExpressions ae = new AvailableExpressions(expression);
if (filter(expression))
Expand All @@ -128,7 +128,7 @@ public Collection<AvailableExpressions> kill(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<AvailableExpressions> domain) {
DefiniteDataflowDomain<AvailableExpressions> domain) {
Collection<AvailableExpressions> result = new HashSet<>();

for (AvailableExpressions ae : domain.getDataflowElements()) {
Expand All @@ -145,7 +145,7 @@ public Collection<AvailableExpressions> kill(
public Collection<AvailableExpressions> kill(
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<AvailableExpressions> domain) {
DefiniteDataflowDomain<AvailableExpressions> domain) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class ConstantPropagation
implements
DataflowElement<DefiniteForwardDataflowDomain<ConstantPropagation>, ConstantPropagation> {
DataflowElement<DefiniteDataflowDomain<ConstantPropagation>, ConstantPropagation> {

private final Identifier id;
private final Integer constant;
Expand Down Expand Up @@ -69,7 +69,7 @@ public Collection<Identifier> getInvolvedIdentifiers() {

private static Integer eval(
SymbolicExpression e,
DefiniteForwardDataflowDomain<ConstantPropagation> domain) {
DefiniteDataflowDomain<ConstantPropagation> domain) {

if (e instanceof Constant) {
Constant c = (Constant) e;
Expand Down Expand Up @@ -123,7 +123,7 @@ public Collection<ConstantPropagation> gen(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<ConstantPropagation> domain) {
DefiniteDataflowDomain<ConstantPropagation> domain) {
Set<ConstantPropagation> gen = new HashSet<>();

Integer v = eval(expression, domain);
Expand All @@ -137,7 +137,7 @@ public Collection<ConstantPropagation> gen(
public Collection<ConstantPropagation> gen(
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<ConstantPropagation> domain) {
DefiniteDataflowDomain<ConstantPropagation> domain) {
return Collections.emptyList();
}

Expand All @@ -146,7 +146,7 @@ public Collection<ConstantPropagation> kill(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<ConstantPropagation> domain) {
DefiniteDataflowDomain<ConstantPropagation> domain) {
Collection<ConstantPropagation> result = new HashSet<>();

for (ConstantPropagation cp : domain.getDataflowElements())
Expand All @@ -160,7 +160,7 @@ public Collection<ConstantPropagation> kill(
public Collection<ConstantPropagation> kill(
ValueExpression expression,
ProgramPoint pp,
DefiniteForwardDataflowDomain<ConstantPropagation> domain) {
DefiniteDataflowDomain<ConstantPropagation> domain) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public class ReachingDefinitions
implements
DataflowElement<PossibleForwardDataflowDomain<ReachingDefinitions>, ReachingDefinitions> {
DataflowElement<PossibleDataflowDomain<ReachingDefinitions>, ReachingDefinitions> {

private final Identifier variable;

Expand Down Expand Up @@ -93,15 +93,15 @@ public Collection<ReachingDefinitions> gen(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
PossibleForwardDataflowDomain<ReachingDefinitions> domain) {
PossibleDataflowDomain<ReachingDefinitions> domain) {
return Collections.singleton(new ReachingDefinitions(id, pp));
}

@Override
public Collection<ReachingDefinitions> gen(
ValueExpression expression,
ProgramPoint pp,
PossibleForwardDataflowDomain<ReachingDefinitions> domain) {
PossibleDataflowDomain<ReachingDefinitions> domain) {
return Collections.emptyList();
}

Expand All @@ -110,7 +110,7 @@ public Collection<ReachingDefinitions> kill(
Identifier id,
ValueExpression expression,
ProgramPoint pp,
PossibleForwardDataflowDomain<ReachingDefinitions> domain) {
PossibleDataflowDomain<ReachingDefinitions> domain) {
Collection<ReachingDefinitions> result = new HashSet<>();

for (ReachingDefinitions rd : domain.getDataflowElements())
Expand All @@ -124,7 +124,7 @@ public Collection<ReachingDefinitions> kill(
public Collection<ReachingDefinitions> kill(
ValueExpression expression,
ProgramPoint pp,
PossibleForwardDataflowDomain<ReachingDefinitions> domain) {
PossibleDataflowDomain<ReachingDefinitions> domain) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import it.unive.lisa.CronConfiguration;
import it.unive.lisa.DefaultConfiguration;
import it.unive.lisa.analysis.dataflow.AvailableExpressions;
import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.DefiniteDataflowDomain;
import org.junit.Test;

public class AvailableExpressionsTest extends AnalysisTestExecutor {
Expand All @@ -15,7 +15,7 @@ public void testAvailableExpressions() {
conf.serializeResults = true;
conf.abstractState = DefaultConfiguration.simpleState(
DefaultConfiguration.defaultHeapDomain(),
new DefiniteForwardDataflowDomain<>(new AvailableExpressions()),
new DefiniteDataflowDomain<>(new AvailableExpressions()),
DefaultConfiguration.defaultTypeDomain());
conf.testDir = "available-expressions";
conf.programFile = "available-expressions.imp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import it.unive.lisa.CronConfiguration;
import it.unive.lisa.DefaultConfiguration;
import it.unive.lisa.analysis.dataflow.ConstantPropagation;
import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.DefiniteDataflowDomain;
import org.junit.Test;

public class ConstantPropagationDFTest extends AnalysisTestExecutor {
Expand All @@ -15,7 +15,7 @@ public void testConstantPropagation() {
conf.serializeResults = true;
conf.abstractState = DefaultConfiguration.simpleState(
DefaultConfiguration.defaultHeapDomain(),
new DefiniteForwardDataflowDomain<>(new ConstantPropagation()),
new DefiniteDataflowDomain<>(new ConstantPropagation()),
DefaultConfiguration.defaultTypeDomain());
conf.testDir = "constant-propagation-df";
conf.programFile = "constant-propagation.imp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import it.unive.lisa.AnalysisTestExecutor;
import it.unive.lisa.CronConfiguration;
import it.unive.lisa.DefaultConfiguration;
import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.PossibleDataflowDomain;
import it.unive.lisa.analysis.dataflow.ReachingDefinitions;
import org.junit.Test;

Expand All @@ -15,7 +15,7 @@ public void testReachingDefinitions() {
conf.serializeResults = true;
conf.abstractState = DefaultConfiguration.simpleState(
DefaultConfiguration.defaultHeapDomain(),
new PossibleForwardDataflowDomain<>(new ReachingDefinitions()),
new PossibleDataflowDomain<>(new ReachingDefinitions()),
DefaultConfiguration.defaultTypeDomain());
conf.testDir = "reaching-definitions";
conf.programFile = "reaching-definitions.imp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import it.unive.lisa.analysis.StatementStore;
import it.unive.lisa.analysis.combination.ValueCartesianProduct;
import it.unive.lisa.analysis.dataflow.AvailableExpressions;
import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain;
import it.unive.lisa.analysis.dataflow.DefiniteDataflowDomain;
import it.unive.lisa.analysis.dataflow.PossibleDataflowDomain;
import it.unive.lisa.analysis.dataflow.ReachingDefinitions;
import it.unive.lisa.analysis.heap.HeapDomain;
import it.unive.lisa.analysis.heap.MonolithicHeap;
Expand Down Expand Up @@ -385,9 +385,9 @@ private Object domainFor(
return new InferredTypes();
if (root == InferenceSystem.class)
return new NonInterference();
if (root == PossibleForwardDataflowDomain.class)
if (root == PossibleDataflowDomain.class)
return new ReachingDefinitions();
if (root == DefiniteForwardDataflowDomain.class)
if (root == DefiniteDataflowDomain.class)
return new AvailableExpressions();
if (param == AbstractState.class)
return new SimpleAbstractState<>(new MonolithicHeap(), new ValueEnvironment<>(new Sign()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@
import org.apache.commons.collections4.SetUtils;

/**
* A {@link DataflowDomain} for <b>forward</b> and <b>definite</b> dataflow
* analysis. Being definite means that this domain is an instance of
* {@link InverseSetLattice}, i.e., is a set whose join operation is the set
* intersection.
* A {@link DataflowDomain} for <b>definite</b> dataflow analysis. Being
* definite means that this domain is an instance of {@link InverseSetLattice},
* i.e., is a set whose join operation is the set intersection.
*
* @author <a href="mailto:[email protected]">Luca Negrini</a>
*
* @param <E> the type of {@link DataflowElement} contained in this domain
*/
public class DefiniteForwardDataflowDomain<E extends DataflowElement<DefiniteForwardDataflowDomain<E>, E>>
public class DefiniteDataflowDomain<E extends DataflowElement<DefiniteDataflowDomain<E>, E>>
extends
DataflowDomain<DefiniteForwardDataflowDomain<E>, E> {
DataflowDomain<DefiniteDataflowDomain<E>, E> {

/**
* Builds an empty domain.
*
* @param domain a singleton instance to be used during semantic operations
* to perform <i>kill</i> and <i>gen</i> operations
*/
public DefiniteForwardDataflowDomain(
public DefiniteDataflowDomain(
E domain) {
this(domain, new HashSet<>(), true, false);
}

private DefiniteForwardDataflowDomain(
private DefiniteDataflowDomain(
E domain,
Set<E> elements,
boolean isTop,
Expand All @@ -40,34 +39,34 @@ private DefiniteForwardDataflowDomain(
}

@Override
public DefiniteForwardDataflowDomain<E> mk(
public DefiniteDataflowDomain<E> mk(
E domain,
Set<E> elements,
boolean isTop,
boolean isBottom) {
return new DefiniteForwardDataflowDomain<>(domain, elements, isTop, isBottom);
return new DefiniteDataflowDomain<>(domain, elements, isTop, isBottom);
}

@Override
public DefiniteForwardDataflowDomain<E> lubAux(
DefiniteForwardDataflowDomain<E> other)
public DefiniteDataflowDomain<E> lubAux(
DefiniteDataflowDomain<E> other)
throws SemanticException {
Set<E> intersection = SetUtils.intersection(this.getDataflowElements(), other.getDataflowElements());
return new DefiniteForwardDataflowDomain<>(domain, intersection, false, false);
return new DefiniteDataflowDomain<>(domain, intersection, false, false);
}

@Override
public boolean lessOrEqualAux(
DefiniteForwardDataflowDomain<E> other)
DefiniteDataflowDomain<E> other)
throws SemanticException {
return this.getDataflowElements().containsAll(other.getDataflowElements());
}

@Override
public DefiniteForwardDataflowDomain<E> glbAux(
DefiniteForwardDataflowDomain<E> other)
public DefiniteDataflowDomain<E> glbAux(
DefiniteDataflowDomain<E> other)
throws SemanticException {
Set<E> intersection = SetUtils.union(this.getDataflowElements(), other.getDataflowElements());
return new DefiniteForwardDataflowDomain<>(domain, intersection, false, false);
return new DefiniteDataflowDomain<>(domain, intersection, false, false);
}
}
Loading

0 comments on commit 7776342

Please sign in to comment.