Skip to content

Commit f63ea66

Browse files
surlimonperrus
authored andcommitted
chore: help readingness and add some documentation (SpoonLabs#95)
1 parent 340aed2 commit f63ea66

File tree

4 files changed

+39
-31
lines changed

4 files changed

+39
-31
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ log
3535

3636
# Nopol
3737
z3
38+
nopol/src-gen
39+
nopol/target-gen
3840

3941
# Nopol-Server
4042
nopol-server/out

doc/jpf.md

+22-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@
22

33
## Installation
44

5-
1. clone jpf-core and jpf-symbc into a jpf folder
6-
2. clone z3 for java (```git clone https://github.com/Z3Prover/z3```)
7-
3. build z3 (```python scripts/mk_make.py --java;cd build;make```)
8-
4. define a `DYLD_LIBRARY_PATH` (for mac) `LD_LIBRARY_PATH` (for linux) with this value: `${project_path}/lib:$DYLD_LIBRARY_PATH:<path_to_z3_build_folder>`
9-
5. create ```~/.jpf/site.properties```
10-
6. put in ```~/.jpf/site.properties```
5+
### Requirements
6+
7+
- JDK 8
8+
- Ant
9+
10+
### Install JPF Core
11+
1. clone jpf-core from https://github.com/grzesuav/jpf-core
12+
2. Go to the directory and type: `ant`
13+
14+
### Install JPF Symb
15+
1. clone jpf-symbc from https://github.com/grzesuav/jpf-symbc
16+
2. go to the cloned directory and type `ant`
17+
18+
### Install Z3
19+
1. clone z3 for java (```git clone https://github.com/Z3Prover/z3```)
20+
2. build z3 (```python scripts/mk_make.py --java;cd build;make```)
21+
22+
### Create properties
23+
24+
1. define a `DYLD_LIBRARY_PATH` (for mac) `LD_LIBRARY_PATH` (for linux) with this value: `${project_path}/lib:$DYLD_LIBRARY_PATH:<path_to_z3_build_folder>`
25+
2. create ```~/.jpf/site.properties```
26+
3. put in ```~/.jpf/site.properties```
1127

1228
```property
1329
# JPF site configuration

nopol/src/main/java/fr/inria/lille/commons/spoon/SpoonedFile.java

+15-13
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,37 @@
3737

3838
public abstract class SpoonedFile {
3939

40-
protected final Config config;
40+
private File[] sourceFiles;
41+
private URL[] projectClasspath;
42+
private URL[] compilationClasspath;
43+
private Factory factory;
44+
private ProcessingManager manager;
45+
private DynamicClassCompiler compiler;
46+
private Map<String, byte[]> compiledClasses;
47+
private DefaultJavaPrettyPrinter prettyPrinter;
4148

42-
protected abstract Collection<? extends CtType<?>> modelledClasses();
49+
protected final Config config;
4350

4451
public SpoonedFile(File[] sourceFiles, URL[] projectClasspath, Config config) {
45-
//logDebug(logger(), format("[Building Spoon model from %s]", sourceFiles));
4652
this.config = config;
4753
this.sourceFiles = sourceFiles;
4854
this.projectClasspath = projectClasspath;
55+
4956
factory = SpoonModelLibrary.newFactory();
5057
factory.getEnvironment().setComplianceLevel(config.getComplianceLevel());
5158
factory.getEnvironment().setCommentEnabled(false);
5259
factory.getEnvironment().setLevel(Level.OFF.toString());
60+
5361
factory = SpoonModelLibrary.modelFor(factory, sourceFiles, projectClasspath());
62+
5463
compiler = new DynamicClassCompiler(compilationClasspath(), config);
55-
manager = new RuntimeProcessingManager(spoonFactory());
64+
manager = new RuntimeProcessingManager(factory);
5665
compiledClasses = MetaMap.newHashMap();
5766
prettyPrinter = new DefaultJavaPrettyPrinter(spoonEnvironment());
5867
}
5968

69+
protected abstract Collection<? extends CtType<?>> modelledClasses();
70+
6071
public void generateOutputFile(File destinationFolder) {
6172
Processor<?> writer = new JavaOutputProcessor(destinationFolder, new DefaultJavaPrettyPrinter(new StandardEnvironment()));
6273
process(writer);
@@ -237,13 +248,4 @@ public String toString() {
237248
private Logger logger() {
238249
return loggerFor(this);
239250
}
240-
241-
private File[] sourceFiles;
242-
private URL[] projectClasspath;
243-
private URL[] compilationClasspath;
244-
private Factory factory;
245-
private ProcessingManager manager;
246-
private DynamicClassCompiler compiler;
247-
private Map<String, byte[]> compiledClasses;
248-
private DefaultJavaPrettyPrinter prettyPrinter;
249251
}

nopol/src/main/java/fr/inria/lille/commons/spoon/util/SpoonModelLibrary.java

-12
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,6 @@ public static void setLoopingCondition(CtWhile loop, CtExpression<Boolean> loopi
217217
loop.setLoopingExpression(loopingCondition);
218218
}
219219

220-
public static CoreFactory coreFactoryOf(CtElement element) {
221-
return element.getFactory().Core();
222-
}
223-
224-
public static CodeFactory codeFactoryOf(CtElement element) {
225-
return element.getFactory().Code();
226-
}
227-
228-
public static Environment newEnvironment() {
229-
return newFactory().getEnvironment();
230-
}
231-
232220
public static Factory newFactory() {
233221
return launcher().createFactory();
234222
}

0 commit comments

Comments
 (0)