23
23
24
24
public final class Util {
25
25
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" ;
36
28
37
29
/**
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
+ *
41
33
* @param loader
42
34
* the class loader in which new {@link Module}s will live
43
35
* @param projectPaths
@@ -46,22 +38,52 @@ public static boolean isWindows() {
46
38
* the {@link AnalysisScope} under construction. This will be
47
39
* mutated.
48
40
* @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
51
43
*/
52
44
private static void buildScope (ClassLoaderReference loader , Collection <EclipseProjectPath > projectPaths ,
53
45
AnalysisScope scope , Collection <Module > seen ) throws IOException {
54
46
for (EclipseProjectPath path : projectPaths ) {
55
47
AnalysisScope pScope = path .toAnalysisScope ((File ) null );
56
- for (Module m : pScope .getModules (loader )) {
48
+ for (Module m : pScope .getModules (loader ))
57
49
if (!seen .contains (m )) {
58
50
seen .add (m );
59
51
scope .addToScope (loader , m );
60
52
}
61
- }
62
53
}
63
54
}
64
55
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
+
65
87
/**
66
88
* create an analysis scope as the union of a bunch of EclipseProjectPath
67
89
*/
@@ -77,26 +99,7 @@ public static AnalysisScope mergeProjectPaths(Collection<EclipseProjectPath> pro
77
99
buildScope (ClassLoaderReference .Primordial , projectPaths , scope , seen );
78
100
return scope ;
79
101
}
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
+ }
102
105
}
0 commit comments