Skip to content

Commit 6070d11

Browse files
Kirill GolubevKirill Golubev
authored andcommitted
loop to stream and final addition
1 parent 4bb5f98 commit 6070d11

File tree

1 file changed

+25
-25
lines changed
  • liquidjava/liquidjava-umbrella/liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker

1 file changed

+25
-25
lines changed

liquidjava/liquidjava-umbrella/liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/VCChecker.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import liquidjava.errors.ErrorEmitter;
1111
import liquidjava.errors.ErrorHandler;
1212
import liquidjava.processor.VCImplication;
13-
import liquidjava.processor.context.Context;
14-
import liquidjava.processor.context.GhostState;
15-
import liquidjava.processor.context.PlacementInCode;
16-
import liquidjava.processor.context.RefinedVariable;
13+
import liquidjava.processor.context.*;
1714
import liquidjava.rj_language.Predicate;
1815
import liquidjava.smt.GhostFunctionError;
1916
import liquidjava.smt.NotFoundError;
@@ -25,9 +22,9 @@
2522
import spoon.reflect.factory.Factory;
2623

2724
public class VCChecker {
28-
private Context context;
29-
private List<RefinedVariable> pathVariables;
30-
private ErrorEmitter errorEmitter;
25+
private final Context context;
26+
private final List<RefinedVariable> pathVariables;
27+
private final ErrorEmitter errorEmitter;
3128
Pattern thisPattern = Pattern.compile("#this_\\d+");
3229
Pattern instancePattern = Pattern.compile("^#(.+)_[0-9]+$");
3330

@@ -186,7 +183,7 @@ private void addAllDiferent(List<RefinedVariable> toExpand, List<RefinedVariable
186183
private List<RefinedVariable> getVariables(Predicate c, String varName) {
187184
List<RefinedVariable> allVars = new ArrayList<>();
188185
getVariablesFromContext(c.getVariableNames(), allVars, varName);
189-
List<String> pathNames = pathVariables.stream().map(a -> a.getName()).collect(Collectors.toList());
186+
List<String> pathNames = pathVariables.stream().map(Refined::getName).collect(Collectors.toList());
190187
getVariablesFromContext(pathNames, allVars, "");
191188

192189
return allVars;
@@ -209,15 +206,16 @@ private void recAuxGetVars(RefinedVariable var, List<RefinedVariable> newVars) {
209206
Predicate c = var.getRefinement();
210207
String varName = var.getName();
211208
List<String> l = c.getVariableNames();
212-
for (String name : l) {
213-
if (!name.equals(varName) && context.hasVariable(name)) {
214-
RefinedVariable rv = context.getVariableByName(name);
215-
if (!newVars.contains(rv)) {
216-
newVars.add(rv);
217-
recAuxGetVars(rv, newVars);
218-
}
219-
}
220-
}
209+
getVariablesFromContext(l, newVars, varName);
210+
// for (String name : l) {
211+
// if (!name.equals(varName) && context.hasVariable(name)) {
212+
// RefinedVariable rv = context.getVariableByName(name);
213+
// if (!newVars.contains(rv)) {
214+
// newVars.add(rv);
215+
// recAuxGetVars(rv, newVars);
216+
// }
217+
// }
218+
// }
221219
}
222220

223221
public boolean smtChecks(Predicate cSMT, Predicate expectedType, CtElement elem) {
@@ -242,7 +240,6 @@ public boolean smtChecks(Predicate cSMT, Predicate expectedType, CtElement elem)
242240
* @param cSMT
243241
* @param expectedType
244242
* @param element
245-
* @param map
246243
*
247244
* @throws Exception
248245
* @throws GhostFunctionError
@@ -278,13 +275,16 @@ public void removePathVariable(RefinedVariable rv) {
278275
}
279276

280277
void removePathVariableThatIncludes(String otherVar) {
281-
List<RefinedVariable> toRemove = new ArrayList<>();
282-
for (RefinedVariable rv : pathVariables)
283-
if (rv.getRefinement().getVariableNames().contains(otherVar))
284-
toRemove.add(rv);
285-
286-
for (RefinedVariable rv : toRemove)
287-
pathVariables.remove(rv);
278+
pathVariables.stream().filter(rv -> rv.getRefinement().getVariableNames().contains(otherVar))
279+
.collect(Collectors.toList()).forEach(rv -> pathVariables.remove(rv));
280+
281+
// List<RefinedVariable> toRemove = new ArrayList<>();
282+
// for (RefinedVariable rv : pathVariables)
283+
// if (rv.getRefinement().getVariableNames().contains(otherVar))
284+
// toRemove.add(rv);
285+
//
286+
// for (RefinedVariable rv : toRemove)
287+
// pathVariables.remove(rv);
288288
}
289289

290290
private void printVCs(String string, String stringSMT, Predicate expectedType) {

0 commit comments

Comments
 (0)