Skip to content

Commit 552f221

Browse files
committed
Clean up.
1 parent 2f5b870 commit 552f221

File tree

2 files changed

+47
-46
lines changed

2 files changed

+47
-46
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/wala/Util.java

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,13 @@
2323

2424
public final class Util {
2525

26-
private Util() {
27-
}
28-
29-
public static String getOSName() {
30-
return System.getProperty("os.name");
31-
}
32-
33-
public static boolean isWindows() {
34-
return getOSName().startsWith("Windows");
35-
}
26+
private static final String OS_NAME = "os.name";
27+
private static final String WINDOWS = "Windows";
3628

3729
/**
38-
* Enhance an {@link AnalysisScope} to include in a particular loader,
39-
* elements from a set of Eclipse projects
40-
*
30+
* Enhance an {@link AnalysisScope} to include in a particular loader, elements
31+
* from a set of Eclipse projects
32+
*
4133
* @param loader
4234
* the class loader in which new {@link Module}s will live
4335
* @param projectPaths
@@ -46,22 +38,52 @@ public static boolean isWindows() {
4638
* the {@link AnalysisScope} under construction. This will be
4739
* mutated.
4840
* @param seen
49-
* set of {@link Module}s which have already been seen, and
50-
* should not be added to the analysis scope
41+
* set of {@link Module}s which have already been seen, and should
42+
* not be added to the analysis scope
5143
*/
5244
private static void buildScope(ClassLoaderReference loader, Collection<EclipseProjectPath> projectPaths,
5345
AnalysisScope scope, Collection<Module> seen) throws IOException {
5446
for (EclipseProjectPath path : projectPaths) {
5547
AnalysisScope pScope = path.toAnalysisScope((File) null);
56-
for (Module m : pScope.getModules(loader)) {
48+
for (Module m : pScope.getModules(loader))
5749
if (!seen.contains(m)) {
5850
seen.add(m);
5951
scope.addToScope(loader, m);
6052
}
61-
}
6253
}
6354
}
6455

56+
public static String getOSName() {
57+
return System.getProperty(OS_NAME);
58+
}
59+
60+
public static boolean isWindows() {
61+
return getOSName().startsWith(WINDOWS);
62+
}
63+
64+
/**
65+
* make a {@link CallGraphBuilder} that uses call-string context sensitivity,
66+
* with call-string length limited to n, and a context-sensitive
67+
* allocation-site-based heap abstraction.
68+
*/
69+
public static SSAPropagationCallGraphBuilder makeNCFABuilder(int n, AnalysisOptions options, AnalysisCache cache,
70+
IClassHierarchy cha, AnalysisScope scope) {
71+
if (options == null)
72+
throw new IllegalArgumentException("options is null");
73+
addDefaultSelectors(options, cha);
74+
addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha);
75+
ContextSelector appSelector = null;
76+
SSAContextInterpreter appInterpreter = null;
77+
SSAPropagationCallGraphBuilder result = new nCFABuilderWithActualParametersInContext(n, cha, options, cache,
78+
appSelector, appInterpreter);
79+
// nCFABuilder uses type-based heap abstraction by default, but we want
80+
// allocation sites
81+
result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(),
82+
ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS
83+
| ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_THROWABLES));
84+
return result;
85+
}
86+
6587
/**
6688
* create an analysis scope as the union of a bunch of EclipseProjectPath
6789
*/
@@ -77,26 +99,7 @@ public static AnalysisScope mergeProjectPaths(Collection<EclipseProjectPath> pro
7799
buildScope(ClassLoaderReference.Primordial, projectPaths, scope, seen);
78100
return scope;
79101
}
80-
81-
/**
82-
* make a {@link CallGraphBuilder} that uses call-string context sensitivity,
83-
* with call-string length limited to n, and a context-sensitive
84-
* allocation-site-based heap abstraction.
85-
*/
86-
public static SSAPropagationCallGraphBuilder makeNCFABuilder(int n, AnalysisOptions options, AnalysisCache cache,
87-
IClassHierarchy cha, AnalysisScope scope) {
88-
if (options == null) {
89-
throw new IllegalArgumentException("options is null");
90-
}
91-
addDefaultSelectors(options, cha);
92-
addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha);
93-
ContextSelector appSelector = null;
94-
SSAContextInterpreter appInterpreter = null;
95-
SSAPropagationCallGraphBuilder result = new nCFABuilderWithActualParametersInContext(n, cha, options, cache, appSelector, appInterpreter);
96-
// nCFABuilder uses type-based heap abstraction by default, but we want allocation sites
97-
result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(), ZeroXInstanceKeys.ALLOCATIONS
98-
| ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS
99-
| ZeroXInstanceKeys.SMUSH_THROWABLES));
100-
return result;
101-
}
102+
103+
private Util() {
104+
}
102105
}

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/wala/nCFABuilderWithActualParametersInContext.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,23 @@ public class nCFABuilderWithActualParametersInContext extends SSAPropagationCall
1919
public nCFABuilderWithActualParametersInContext(int n, IClassHierarchy cha, AnalysisOptions options,
2020
AnalysisCache cache, ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {
2121
super(cha, options, cache, new DefaultPointerKeyFactory());
22-
if (options == null) {
22+
if (options == null)
2323
throw new IllegalArgumentException("options is null");
24-
}
2524

26-
setInstanceKeys(new ClassBasedInstanceKeys(options, cha));
25+
this.setInstanceKeys(new ClassBasedInstanceKeys(options, cha));
2726

2827
ContextSelector def = new DefaultContextSelector(options, cha);
2928
ContextSelector contextSelector = appContextSelector == null ? def
3029
: new DelegatingContextSelector(appContextSelector, def);
3130
contextSelector = new nCFAContextWithReceiversSelector(n, contextSelector);
32-
setContextSelector(contextSelector);
31+
this.setContextSelector(contextSelector);
3332

3433
SSAContextInterpreter defI = new DefaultSSAInterpreter(options, cache);
3534
defI = new DelegatingSSAContextInterpreter(
36-
ReflectionContextInterpreter.createReflectionContextInterpreter(cha, options, getAnalysisCache()),
35+
ReflectionContextInterpreter.createReflectionContextInterpreter(cha, options, this.getAnalysisCache()),
3736
defI);
3837
SSAContextInterpreter contextInterpreter = appContextInterpreter == null ? defI
3938
: new DelegatingSSAContextInterpreter(appContextInterpreter, defI);
40-
setContextInterpreter(contextInterpreter);
39+
this.setContextInterpreter(contextInterpreter);
4140
}
42-
4341
}

0 commit comments

Comments
 (0)