1010import liquidjava .errors .ErrorEmitter ;
1111import liquidjava .errors .ErrorHandler ;
1212import 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 .*;
1714import liquidjava .rj_language .Predicate ;
1815import liquidjava .smt .GhostFunctionError ;
1916import liquidjava .smt .NotFoundError ;
2522import spoon .reflect .factory .Factory ;
2623
2724public 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