@@ -49,22 +49,35 @@ public AstBasedPropagation(Map<SymbolV2, Set<Propagation>> propagationsByLhs, Ty
49
49
}
50
50
51
51
public Map <SymbolV2 , Set <PythonType >> processPropagations (Set <SymbolV2 > trackedVars ) {
52
- Set <Propagation > propagations = new HashSet <>();
52
+ computePropagationDependencies (trackedVars );
53
+
53
54
Set <SymbolV2 > initializedVars = new HashSet <>();
55
+ Set <Propagation > propagations = getTrackedPropagation (trackedVars );
54
56
57
+ applyPropagations (propagations , initializedVars , true );
58
+ applyPropagations (propagations , initializedVars , false );
59
+ return propagations .stream ().collect (Collectors .groupingBy (Propagation ::lhsSymbol , Collectors .mapping (Propagation ::rhsType , Collectors .toSet ())));
60
+ }
61
+
62
+ private void computePropagationDependencies (Set <SymbolV2 > trackedVars ) {
55
63
propagationsByLhs .forEach ((lhs , props ) -> {
56
64
if (trackedVars .contains (lhs )) {
57
65
props .stream ()
58
66
.filter (Assignment .class ::isInstance )
59
67
.map (Assignment .class ::cast )
60
68
.forEach (a -> a .computeDependencies (trackedVars ));
61
- propagations .addAll (props );
62
69
}
63
70
});
71
+ }
64
72
65
- applyPropagations (propagations , initializedVars , true );
66
- applyPropagations (propagations , initializedVars , false );
67
- return propagations .stream ().collect (Collectors .groupingBy (Propagation ::lhsSymbol , Collectors .mapping (Propagation ::rhsType , Collectors .toSet ())));
73
+ private Set <Propagation > getTrackedPropagation (Set <SymbolV2 > trackedVars ) {
74
+ Set <Propagation > trackedPropagations = new HashSet <>();
75
+ propagationsByLhs .forEach ((lhs , propagations ) -> {
76
+ if (trackedVars .contains (lhs )) {
77
+ trackedPropagations .addAll (propagations );
78
+ }
79
+ });
80
+ return trackedPropagations ;
68
81
}
69
82
70
83
private void applyPropagations (Set <Propagation > propagations , Set <SymbolV2 > initializedVars , boolean checkDependenciesReadiness ) {
0 commit comments