Skip to content

Commit

Permalink
Allowing subclassing through mk()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaneg committed Oct 19, 2023
1 parent bb7e271 commit 0ed21e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public FieldSensitivePointBasedHeap(
@Override
public FieldSensitivePointBasedHeap mk(
FieldSensitivePointBasedHeap reference) {
return new FieldSensitivePointBasedHeap(reference.heapEnv, reference.replacements, reference.fields);
return reference;
}

@Override
Expand Down Expand Up @@ -157,7 +157,7 @@ public FieldSensitivePointBasedHeap shallowCopy(
replacement.addTarget(site);
replacements.add(replacement);

return new FieldSensitivePointBasedHeap(heap, new GenericMapLattice<>(fields.lattice, newFields));
return mk(new FieldSensitivePointBasedHeap(heap, new GenericMapLattice<>(fields.lattice, newFields)));
}

@Override
Expand Down Expand Up @@ -197,8 +197,8 @@ public FieldSensitivePointBasedHeap smallStepSemantics(
addField(site, child, mapping);
}

return new FieldSensitivePointBasedHeap(heapEnv, heapEnv.getSubstitution(),
new GenericMapLattice<>(fields.lattice, mapping));
return mk(new FieldSensitivePointBasedHeap(heapEnv, heapEnv.getSubstitution(),
new GenericMapLattice<>(fields.lattice, mapping)));
} else if (expression instanceof MemoryAllocation) {
String loc = expression.getCodeLocation().getCodeLocation();
Set<AllocationSite> alreadyAllocated = getAllocatedAt(loc);
Expand Down Expand Up @@ -245,12 +245,12 @@ public FieldSensitivePointBasedHeap smallStepSemantics(
env = new HeapEnvironment<>(env.lattice, map);
}

return new FieldSensitivePointBasedHeap(env, replacements, fields);
return mk(new FieldSensitivePointBasedHeap(env, replacements, fields));
}
}

FieldSensitivePointBasedHeap sss = super.smallStepSemantics(expression, pp, oracle);
return new FieldSensitivePointBasedHeap(sss.heapEnv, fields);
return mk(new FieldSensitivePointBasedHeap(sss.heapEnv, fields));
}

private void addField(
Expand Down Expand Up @@ -386,19 +386,19 @@ public boolean equals(
public FieldSensitivePointBasedHeap popScope(
ScopeToken scope)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.popScope(scope), fields);
return mk(new FieldSensitivePointBasedHeap(heapEnv.popScope(scope), fields));
}

@Override
public FieldSensitivePointBasedHeap pushScope(
ScopeToken scope)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.pushScope(scope), fields);
return mk(new FieldSensitivePointBasedHeap(heapEnv.pushScope(scope), fields));
}

@Override
public FieldSensitivePointBasedHeap top() {
return new FieldSensitivePointBasedHeap(heapEnv.top(), Collections.emptyList(), fields.top());
return mk(new FieldSensitivePointBasedHeap(heapEnv.top(), Collections.emptyList(), fields.top()));
}

@Override
Expand All @@ -408,7 +408,7 @@ public boolean isTop() {

@Override
public FieldSensitivePointBasedHeap bottom() {
return new FieldSensitivePointBasedHeap(heapEnv.bottom(), Collections.emptyList(), fields.bottom());
return mk(new FieldSensitivePointBasedHeap(heapEnv.bottom(), Collections.emptyList(), fields.bottom()));
}

@Override
Expand All @@ -420,18 +420,18 @@ public boolean isBottom() {
public FieldSensitivePointBasedHeap lubAux(
FieldSensitivePointBasedHeap other)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.lub(other.heapEnv),
return mk(new FieldSensitivePointBasedHeap(heapEnv.lub(other.heapEnv),
Collections.emptyList(),
fields.lub(other.fields));
fields.lub(other.fields)));
}

@Override
public FieldSensitivePointBasedHeap glbAux(
FieldSensitivePointBasedHeap other)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.glb(other.heapEnv),
return mk(new FieldSensitivePointBasedHeap(heapEnv.glb(other.heapEnv),
Collections.emptyList(),
fields.glb(other.fields));
fields.glb(other.fields)));
}

@Override
Expand All @@ -445,13 +445,13 @@ public boolean lessOrEqualAux(
public FieldSensitivePointBasedHeap forgetIdentifier(
Identifier id)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.forgetIdentifier(id), fields);
return mk(new FieldSensitivePointBasedHeap(heapEnv.forgetIdentifier(id), fields));
}

@Override
public FieldSensitivePointBasedHeap forgetIdentifiersIf(
Predicate<Identifier> test)
throws SemanticException {
return new FieldSensitivePointBasedHeap(heapEnv.forgetIdentifiersIf(test), fields);
return mk(new FieldSensitivePointBasedHeap(heapEnv.forgetIdentifiersIf(test), fields));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public PointBasedHeap(
@Override
public PointBasedHeap mk(
PointBasedHeap reference) {
return new PointBasedHeap(reference.heapEnv, reference.replacements);
return reference;
}

@Override
Expand All @@ -73,12 +73,12 @@ protected PointBasedHeap mk(

@Override
public PointBasedHeap top() {
return new PointBasedHeap(heapEnv.top());
return mk(new PointBasedHeap(heapEnv.top()));
}

@Override
public PointBasedHeap bottom() {
return new PointBasedHeap(heapEnv.bottom());
return mk(new PointBasedHeap(heapEnv.bottom()));
}

@Override
Expand All @@ -90,14 +90,14 @@ public List<HeapReplacement> getSubstitution() {
public PointBasedHeap lubAux(
PointBasedHeap other)
throws SemanticException {
return new PointBasedHeap(heapEnv.lub(other.heapEnv));
return mk(new PointBasedHeap(heapEnv.lub(other.heapEnv)));
}

@Override
public PointBasedHeap glbAux(
PointBasedHeap other)
throws SemanticException {
return new PointBasedHeap(heapEnv.glb(other.heapEnv));
return mk(new PointBasedHeap(heapEnv.glb(other.heapEnv)));
}

@Override
Expand All @@ -111,27 +111,27 @@ public boolean lessOrEqualAux(
public PointBasedHeap popScope(
ScopeToken scope)
throws SemanticException {
return new PointBasedHeap(heapEnv.popScope(scope));
return mk(new PointBasedHeap(heapEnv.popScope(scope)));
}

@Override
public PointBasedHeap pushScope(
ScopeToken scope)
throws SemanticException {
return new PointBasedHeap(heapEnv.pushScope(scope));
return mk(new PointBasedHeap(heapEnv.pushScope(scope)));
}

@Override
public PointBasedHeap forgetIdentifier(
Identifier id)
throws SemanticException {
return new PointBasedHeap(heapEnv.forgetIdentifier(id));
return mk(new PointBasedHeap(heapEnv.forgetIdentifier(id)));
}

@Override
public PointBasedHeap forgetIdentifiersIf(
Predicate<Identifier> test)
throws SemanticException {
return new PointBasedHeap(heapEnv.forgetIdentifiersIf(test));
return mk(new PointBasedHeap(heapEnv.forgetIdentifiersIf(test)));
}
}

0 comments on commit 0ed21e8

Please sign in to comment.