-
Notifications
You must be signed in to change notification settings - Fork 29
IDE Basics #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rkoer
wants to merge
172
commits into
opalj:develop
Choose a base branch
from
Rkoer:ide-basics
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
IDE Basics #240
Changes from all commits
Commits
Show all changes
172 commits
Select commit
Hold shift + click to select a range
54dda6d
Add IDE module
RobinKorke eb634e4
Basic model of IDE problems
RobinKorke fdf5928
First working solver
RobinKorke 5bd3293
Integrate IDE solver into OPAL
RobinKorke 30084ec
Improve debugging possibilities
RobinKorke 5775d1a
Preparations to integrate IDE into TAC
RobinKorke aa4a0f0
Add abstraction layer to reduce complexity of analyses for Java programs
RobinKorke bfff8cb
Replace functions with properties
RobinKorke 9970be9
Add IDE version of linear constant propagation
RobinKorke 6c35b5e
Prepare test environment for linear constant propagation
RobinKorke 146b123
Add tests for linear constant propagation
RobinKorke f0580ab
Fix IDE solver/linear constant propagation (temporary)
RobinKorke 1c4062b
Fix linear constant propagation tests (some calls are identified as s…
RobinKorke 95b3225
Add abstraction for IDE tests
RobinKorke 2d80f58
Extend IDE problem function signatures to allow passing/using more in…
RobinKorke 8a08d82
Refactor linear constant propagation edge functions
RobinKorke ae2fde6
Adjust/Fix linear constant propagation edge functions to find more co…
RobinKorke 9e9326c
Implement end summaries extension
RobinKorke f61124e
Use end summaries in linear constant propagation
RobinKorke 9bed114
Move safety check to ICFG implementation
RobinKorke 7560325
Refactor flow recording
RobinKorke b518340
Add more logging
RobinKorke 1cd6551
Introduce EdgeFunctionResult to allow usage of lazily computed proper…
RobinKorke 542b49e
Small fixes
RobinKorke 1e77801
Add equality check for properties
RobinKorke 7615102
Reduce dependencies to IFDS
RobinKorke 84c24c0
Fix dependee handling
RobinKorke 978f0b7
Remove statement part from IDE properties
RobinKorke 88717cc
Enable analyzing a certain statement inside a callable
RobinKorke 3c1c6f1
Make cyclic analyses produce more precise results (and remove lambdas…
RobinKorke 8be9534
Generate properties for all computed results
RobinKorke e479a5a
Some type fixes
RobinKorke 8ba62dc
Fix some typos
RobinKorke 9e28294
Add concept of additional seeds
RobinKorke 2e87f98
Add problem-global identity edge function
RobinKorke 26c05f2
Add predefined flow functions
RobinKorke 00b598f
Prepare linear constant propagation for 'on fields' extension
RobinKorke 324677a
Prepare linear constant propagation for 'on fields' extension
RobinKorke d3f8265
Extend linear constant propagation with array access expressions
RobinKorke c58da7e
Prepare linear constant propagation for 'on fields' extension
RobinKorke 7215e99
Refactor test execution
RobinKorke 83b08f9
Fix propagation and equality issues (esp. when applying end summaries)
RobinKorke 31c83ad
Fix UnknownValueEdgeFunction going to edge function that produces Var…
RobinKorke 9fa18e8
Pass callee to call-to-return edge function generation
RobinKorke c49b2d1
Add fallback for missing edge functions while recording flow (due to …
RobinKorke 0386854
Hide ICFG construction in JavaIDEProblem
RobinKorke e678847
Add matcher for UnknownValue
RobinKorke e29b374
Add IDE version of LCP on fields
RobinKorke 3473777
Prepare test environment for LCP on fields
RobinKorke 3582288
Add tests for LCP on fields
RobinKorke 7aa00ba
Add parameter to general PropertiesTest to allow non-final results at…
RobinKorke 42d067b
Exchange InterimResults with empty dependees with PartialResults
RobinKorke ce3a418
Enhance directory handling and logging of FlowRecordingIDEAnalysis
RobinKorke 387b72b
Merge branch 'refs/heads/develop' into ide-basics
RobinKorke ab90eef
Fix lines continued by operator
3865ca7
Add header to test files
ab125dc
Import formatting
2acf812
Apply formatter
RobinKorke 610d108
Apply formatter
RobinKorke e2d6138
Fix result creation and introduce strict type and scheduler separatio…
RobinKorke 6d6d8af
Add eager scheduler variant of IDEAnalysisProxy
RobinKorke c0910f9
Fix LCPOnFieldsTests to trigger property computation in phase
RobinKorke e7e718a
Revert "Add parameter to general PropertiesTest to allow non-final re…
RobinKorke ec9a1bc
Merge branch 'develop' into ide-basics
RobinKorke b4e7ae7
Apply formatter
RobinKorke 5e6470b
Refactor callable passing in IDEAnalysis
RobinKorke f1ab938
Extend linear constant propagation to deal with boolean operators
RobinKorke d696969
Fix LCP on fields edge function computation
RobinKorke b224011
Refactor property matchers
RobinKorke 45193f7
Fix IDEAnalysis final result creation
RobinKorke e05fcf2
Add facts and values to LCP on fields for array detection
RobinKorke 3ba7a8b
Extend test annotations and matcher of LCP on fields
RobinKorke a710689
Refactor linear constant propagation problem definition
RobinKorke 0809bad
Fix LCP on fields tests
RobinKorke dd5d496
Make IDEAnalysisProxy more robust
RobinKorke 84d8e67
Extend LCP on fields problem with array detection
RobinKorke 2ac5750
Extend LCP on fields problem with array detection
RobinKorke 1fb83f8
Use method instead of string comparison
RobinKorke 039a72a
Refactor logging
RobinKorke 1f6577d
Refactor IDEAnalysisScheduler to adapt flow recording functionality
RobinKorke 2e288d9
Prepare for backward analyses
RobinKorke 388386e
Refactor ICFG and remove dependency to IFDS
RobinKorke 5e886a5
Add backward problem and ICFG
RobinKorke bf67bcb
Refactor ICFG types
RobinKorke b5217e9
Add missing annotations and matchers for LCP on fields values
RobinKorke fa06f93
Add possibility to provide precomputed summary functions per problem …
RobinKorke a1acb01
Use precomputed summaries for linear constant propagation and LCP on …
RobinKorke 9d3725b
Refactor LCP on fields facts
RobinKorke 60f04a9
Prepare problem definitions for interim flow functions
RobinKorke 8a2eb83
Implement interim flow functions
RobinKorke c5b4d39
Adjust dependee handling in phase 2
RobinKorke f7413d3
Document restrictions for interim flow functions
RobinKorke 42b0731
Add IFDS integration based on IDE problems/solver
RobinKorke 4f8f40c
Fix LCP on fields tests
RobinKorke 7cff6f9
Fix ClassFile::staticInitializer loop termination
RobinKorke 971703f
Extend LCP on fields analysis with immutability information to be abl…
RobinKorke fcfc831
Refactor ICFG being rooted at analysis scheduler and not at problem d…
RobinKorke dddf278
Refactor FlowFunction sourceFact parameter
RobinKorke de9d160
Refactor ICFG handling (and passing)
RobinKorke 7819259
Fix callable result for analysis targets with multiple returns
RobinKorke db957e7
Add cache for TAC
RobinKorke 12ef951
Resolve TODOs
RobinKorke 47383b5
Optimize second phase of IDE solver
RobinKorke 79bffb7
Update TODOs
RobinKorke 6ad5aa4
Merge branch 'develop' into ide-basics
RobinKorke 73470d2
Allow custom continuations when handling an edge function result
RobinKorke d887c2e
Allow custom edge functions for flows starting with additional seeds
RobinKorke bdc31b0
Improve LCP on fields for static fields
RobinKorke d5f9ad1
Add precomputed flow and summary function for static fields LCP
RobinKorke 572f67a
Adjust analysis logging
RobinKorke 8b606be
Fix corner cases of linear constant propagation and LCP on fields
RobinKorke cd390ef
Fix corner cases of linear constant propagation and LCP on fields
RobinKorke 3f09a5b
Fix analysis of some more empty callables
RobinKorke 4b64423
Fix return of special exceptions
RobinKorke 3206fa8
Fix processing of static callables
RobinKorke bdfc72c
Fix logging issues
RobinKorke 266743f
Optimize jump functions lookup
RobinKorke 932d52f
Fix pattern matching exception in linear constant propagation
RobinKorke 9ccdcb6
Fix termination issues due to faulty problem definition
RobinKorke 84d1e63
Increase performance impact of raw results
RobinKorke 57743a5
Extend IDE precomputation extension to be able to deal with call stat…
RobinKorke 99f3902
Enhance precomputation for known callable in linear constant propagation
RobinKorke f1fc580
Implement precomputation for unknown callable in linear constant prop…
RobinKorke b16c37f
Fix hashCode implementation
RobinKorke b697e7e
Allow precomputed summary functions to be intermediate edge functions
RobinKorke 0c7e9bf
More conservative handling of static fields in LCP on fields
RobinKorke e59dcfd
More precise summaries for object and array facts in LCP on fields
RobinKorke 9497afa
More precise summaries for static facts in LCP on fields
RobinKorke afe0d81
Fix precomputed flow function generation for linear constant propagation
RobinKorke 3a0fb6a
Fix linting issues
RobinKorke 57a5bc1
Do not include runtime in IDE tests by default
RobinKorke 31dacbb
Merge branch 'develop' into ide-basics
RobinKorke 498958d
More precise summaries for object facts in LCP on fields
RobinKorke bd6e10e
Improve precision of linear constant propagation
RobinKorke f9eb565
Consequent AllTopEdgeFunction implementations
RobinKorke 365ee58
Implement return flow functions extension
RobinKorke fdc1f20
Improve precision of LCP on fields
RobinKorke 7a844b9
fixup! Improve precision of LCP on fields
RobinKorke 0e2d139
Reorder and extend generics
RobinKorke 4dc2bdb
Prepare to track target callables
RobinKorke 4e9e779
Fix linting issues
RobinKorke 8c0248a
Extend IDE solver framework to analyse multiple callables efficiently
RobinKorke 1a9da62
Fix LCP on fields tests
RobinKorke 5dcc0d4
Fix issue about missing results
RobinKorke 1e58918
Fix pattern match exception
RobinKorke ce44d36
Fix inconsistent results for static fields
RobinKorke 04961fb
Fix inconsistent seeds
RobinKorke 8dfdb33
Fix problem definitions
RobinKorke a6a8752
Fix rare pattern matching bug
RobinKorke 686fa2e
Fix invalid edge function
RobinKorke b7ba93d
Do not produce final results too early
RobinKorke 5759a8f
Use smarter seeding algorithm for phase 1
RobinKorke e5cb973
Improve comparability of property stringification
RobinKorke 0041c6f
Implement incremental phase 2 by tracking changes
RobinKorke c6cd5f2
Fix linting issue
RobinKorke 6e740a5
Improve handling of static fields in LCP on fields
RobinKorke f050013
Memory usage improvements
RobinKorke 046c6a5
Improve value handling
RobinKorke 291ff02
Memory usage improvements
RobinKorke 3a73395
Improve comparability of property stringification
RobinKorke e9de3ca
Memory usage/performance improvements
RobinKorke a63d838
Make ICFG more robust
RobinKorke 1019506
Fix LCP on fields problem definition
RobinKorke 047312f
Fix LCP extended problem definition
RobinKorke c9cb861
Fix LCP problem definition
RobinKorke 7196339
Fix sbt config
RobinKorke a648b23
Run scalafmt
RobinKorke 17f6029
Adjust package declarations
RobinKorke e932212
Adjust author and documentation
RobinKorke c790102
Fix doc references
RobinKorke 47d1ce6
Replace immutability with assignability
RobinKorke 5ef0696
Merge branch 'develop' into ide-basics
errt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...alidate/src/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/ArrayNativeMethodExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ArrayValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ArrayValues; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ConstantArrayElement; | ||
import org.opalj.fpcf.properties.lcp_on_fields.VariableArrayElement; | ||
|
||
/** | ||
* An example to test conservative handling of array elements in native method calls. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class ArrayNativeMethodExample { | ||
@ArrayValues({ | ||
@ArrayValue(variable = "lv1", variableElements = { | ||
@VariableArrayElement(index = 0), | ||
@VariableArrayElement(index = 1), | ||
@VariableArrayElement(index = 2), | ||
@VariableArrayElement(index = 3) | ||
}), | ||
@ArrayValue(variable = "lvf", constantElements = { | ||
@ConstantArrayElement(index = 0, value = 42), | ||
@ConstantArrayElement(index = 1, value = 23) | ||
}), | ||
@ArrayValue(variable = "lv17", variableElements = { | ||
@VariableArrayElement(index = 0), | ||
@VariableArrayElement(index = 1), | ||
@VariableArrayElement(index = 2), | ||
@VariableArrayElement(index = 3), | ||
@VariableArrayElement(index = 4), | ||
@VariableArrayElement(index = 5) | ||
}) | ||
}) | ||
public static void main(String[] args) { | ||
int[] arr1 = new int[]{4, 5, 6, 7}; | ||
int[] arr2 = new int[]{42, 23}; | ||
int[] arr3 = new int[6]; | ||
System.arraycopy(arr1, 1, arr3, 2, 3); | ||
|
||
System.out.println("arr1: {" + arr1[0] + ", " + arr1[1] + ", " + arr1[2] + ", " + arr1[3] + "}; arr2: {" + | ||
arr2[0] + ", " + arr2[1] + "}; arr3: {" + arr3[0] + ", " + arr3[1] + ", " + arr3[2] + ", " + arr3[3] + | ||
", " + arr3[4] + ", " + arr3[5] + "}"); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/ArrayReadWriteAcrossMethodsExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.*; | ||
|
||
/** | ||
* An example to test reading and writing array elements across methods. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class ArrayReadWriteAcrossMethodsExample { | ||
public void setIndexTo23(int[] arr, int index) { | ||
arr[index] = 23; | ||
} | ||
|
||
public void set11To42(int[] arr) { | ||
arr[11] = 42; | ||
} | ||
|
||
@ArrayValues({ | ||
@ArrayValue(variable = "lv3", unknownElements = { | ||
@UnknownArrayElement(index = 0), | ||
@UnknownArrayElement(index = 1), | ||
@UnknownArrayElement(index = 2), | ||
@UnknownArrayElement(index = 3) | ||
}), | ||
@ArrayValue(variable = "lv5", constantElements = { | ||
@ConstantArrayElement(index = 11, value = 42) | ||
}) | ||
}) | ||
public static void main(String[] args) { | ||
ArrayReadWriteAcrossMethodsExample example = new ArrayReadWriteAcrossMethodsExample(); | ||
|
||
int[] arr1 = new int[100]; | ||
int[] arr2 = new int[100]; | ||
|
||
example.setIndexTo23(arr1, 2); | ||
example.set11To42(arr2); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...te/src/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/ArrayReadWriteConstantExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ArrayValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ArrayValues; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ConstantArrayElement; | ||
|
||
/** | ||
* An example to test reading and writing array elements in one method. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class ArrayReadWriteConstantExample { | ||
@ArrayValues({ | ||
@ArrayValue(variable = "lv1", constantElements = { | ||
@ConstantArrayElement(index = 0, value = 0), | ||
@ConstantArrayElement(index = 1, value = 0), | ||
@ConstantArrayElement(index = 2, value = 42), | ||
@ConstantArrayElement(index = 3, value = 4), | ||
@ConstantArrayElement(index = 4, value = 0) | ||
}), | ||
@ArrayValue(variable = "lv3", constantElements = { | ||
@ConstantArrayElement(index = 0, value = 0), | ||
@ConstantArrayElement(index = 1, value = 2), | ||
@ConstantArrayElement(index = 2, value = 3), | ||
@ConstantArrayElement(index = 3, value = 4) | ||
}), | ||
@ArrayValue(variable = "lv11", constantElements = { | ||
@ConstantArrayElement(index = 0, value = 11), | ||
@ConstantArrayElement(index = 1, value = 12), | ||
@ConstantArrayElement(index = 2, value = 13) | ||
}) | ||
}) | ||
public static void main(String[] args) { | ||
int[] arr1 = new int[5]; | ||
int[] arr2 = new int[]{1, 2, 3, 4}; | ||
int[] arr3 = new int[]{11, 12, 13}; | ||
|
||
arr1[2] = 42; | ||
arr1[3] = arr2[3]; | ||
arr2[0] = arr1[4]; | ||
|
||
System.out.println("arr1: {" + arr1[0] + ", " + arr1[1] + ", " + arr1[2] + ", " + arr1[3] + ", " + arr1[4] + | ||
"}; arr2: {" + arr2[0] + ", " + arr2[1] + ", " + arr2[2] + ", " + arr2[3] + "}; arr3: {" + arr3[0] + | ||
", " + arr3[1] + ", " + arr3[2] + "}"); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...idate/src/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/ArrayUnknownIndicesExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ArrayValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ConstantArrayElement; | ||
import org.opalj.fpcf.properties.lcp_on_fields.VariableArrayElement; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.ConstantValue; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.VariableValue; | ||
|
||
/** | ||
* An example to test reading and writing of arrays at an unknown index. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class ArrayUnknownIndicesExample { | ||
@ArrayValue(variable = "lv1", variableElements = { | ||
@VariableArrayElement(index = 0), | ||
@VariableArrayElement(index = 1), | ||
@VariableArrayElement(index = 10), | ||
@VariableArrayElement(index = 11), | ||
@VariableArrayElement(index = 12), | ||
@VariableArrayElement(index = 13), | ||
@VariableArrayElement(index = 98), | ||
@VariableArrayElement(index = 99), | ||
}, constantElements = { | ||
@ConstantArrayElement(index = 50, value = 99) | ||
}) | ||
@ConstantValue(variable = "lv9", value = 0) | ||
@VariableValue(variable = "lvf") | ||
public static void main(String[] args) { | ||
int[] arr = new int[100]; | ||
|
||
int i; | ||
int j; | ||
if (args.length == 0) { | ||
i = 42; | ||
j = 11; | ||
} else { | ||
i = 23; | ||
j = 12; | ||
} | ||
|
||
int a1 = arr[i]; | ||
|
||
arr[j] = 13; | ||
arr[50] = 99; | ||
|
||
int a2 = arr[i]; | ||
|
||
System.out.println("a1: " + a1 + ", a2: " + a2); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...date/src/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/CreateObjectInMethodExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValues; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.ConstantValue; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.VariableValue; | ||
|
||
/** | ||
* An example to test objects created across methods. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class CreateObjectInMethodExample { | ||
private int a = 42; | ||
|
||
private CreateObjectInMethodExample createNew1() { | ||
CreateObjectInMethodExample example = new CreateObjectInMethodExample(); | ||
example.a -= 11; | ||
return example; | ||
} | ||
|
||
@ObjectValue(variable = "lv0", constantValues = {@ConstantValue(variable = "a", value = 33)}) | ||
private CreateObjectInMethodExample createNew2() { | ||
CreateObjectInMethodExample example = new CreateObjectInMethodExample(); | ||
example.a = a + 2; | ||
return example; | ||
} | ||
|
||
@ObjectValue(variable = "lv0", variableValues = {@VariableValue(variable = "a")}) | ||
private CreateObjectInMethodExample createNew3() { | ||
CreateObjectInMethodExample example = new CreateObjectInMethodExample(); | ||
example.a = a + 2; | ||
return example; | ||
} | ||
|
||
@ObjectValues({ | ||
@ObjectValue(variable = "lv0", constantValues = {@ConstantValue(variable = "a", value = 42)}), | ||
@ObjectValue(variable = "lv2", constantValues = {@ConstantValue(variable = "a", value = 31)}), | ||
@ObjectValue(variable = "lv3", constantValues = {@ConstantValue(variable = "a", value = 33)}), | ||
@ObjectValue(variable = "lv4", variableValues = {@VariableValue(variable = "a")}), | ||
@ObjectValue(variable = "lv5", variableValues = {@VariableValue(variable = "a")}) | ||
}) | ||
public static void main(String[] args) { | ||
CreateObjectInMethodExample example1 = new CreateObjectInMethodExample(); | ||
CreateObjectInMethodExample example2 = example1.createNew1(); | ||
CreateObjectInMethodExample example3 = example2.createNew2(); | ||
CreateObjectInMethodExample example4 = example3.createNew3(); | ||
CreateObjectInMethodExample example5 = example4.createNew3(); | ||
|
||
System.out.println("e1: " + example1.a + ", e2: " + example2.a + ", e3: " + example3.a + ", e4: " + | ||
example4.a + ", e5: " + example5.a); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...c/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/FieldReadWriteAcrossMethodsExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValues; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.ConstantValue; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.UnknownValue; | ||
|
||
/** | ||
* An example to test reading and writing fields of objects across methods. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class FieldReadWriteAcrossMethodsExample { | ||
private int a = -2; | ||
|
||
private void setA(int a) { | ||
this.a = a; | ||
} | ||
|
||
private void setATo42() { | ||
this.a = 42; | ||
} | ||
|
||
private int getA() { | ||
return a; | ||
} | ||
|
||
@ObjectValues({ | ||
@ObjectValue(variable = "lv0", unknownValues = {@UnknownValue(variable = "a")}), | ||
@ObjectValue(variable = "lv2", constantValues = {@ConstantValue(variable = "a", value = 42)}), | ||
@ObjectValue(variable = "lv4", constantValues = {@ConstantValue(variable = "a", value = -2)}) | ||
}) | ||
public static void main(String[] args) { | ||
FieldReadWriteAcrossMethodsExample example1 = new FieldReadWriteAcrossMethodsExample(); | ||
FieldReadWriteAcrossMethodsExample example2 = new FieldReadWriteAcrossMethodsExample(); | ||
FieldReadWriteAcrossMethodsExample example3 = new FieldReadWriteAcrossMethodsExample(); | ||
|
||
example1.setA(23); | ||
int e1a = example1.getA(); | ||
|
||
example2.setATo42(); | ||
int e2a = example2.getA(); | ||
|
||
int e3a = example3.getA(); | ||
|
||
System.out.println("e1a: " + e1a + ", e2a: " + e2a + ", e3a: " + e3a); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...te/src/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/FieldReadWriteConstantExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValues; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.ConstantValue; | ||
|
||
/** | ||
* An example to test reading and writing of object fields with constants. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class FieldReadWriteConstantExample { | ||
private int a = -1; | ||
|
||
@ObjectValues({ | ||
@ObjectValue(variable = "lv0", constantValues = {@ConstantValue(variable = "a", value = -1)}), | ||
@ObjectValue(variable = "lv2", constantValues = {@ConstantValue(variable = "a", value = 42)}), | ||
@ObjectValue(variable = "lv4", constantValues = {@ConstantValue(variable = "a", value = 41)}) | ||
}) | ||
public static void main(String[] args) { | ||
FieldReadWriteConstantExample example1 = new FieldReadWriteConstantExample(); | ||
FieldReadWriteConstantExample example2 = new FieldReadWriteConstantExample(); | ||
FieldReadWriteConstantExample example3 = new FieldReadWriteConstantExample(); | ||
|
||
example2.a = 23; | ||
example2.a = 42; | ||
|
||
example3.a = example2.a; | ||
example3.a--; | ||
|
||
System.out.println("e1: " + example1.a + ", e2: " + example2.a + ", e3: " + example3.a); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...c/test/java/org/opalj/fpcf/fixtures/lcp_on_fields/FieldReadWriteWithBranchingExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
package org.opalj.fpcf.fixtures.lcp_on_fields; | ||
|
||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValue; | ||
import org.opalj.fpcf.properties.lcp_on_fields.ObjectValues; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.ConstantValue; | ||
import org.opalj.fpcf.properties.linear_constant_propagation.VariableValue; | ||
|
||
/** | ||
* An example to test reading and writing object fields in presence of if-then-else constructs. | ||
* | ||
* @author Robin Körkemeier | ||
*/ | ||
public class FieldReadWriteWithBranchingExample { | ||
private int a = -1; | ||
|
||
@ObjectValue(variable = "lv0", variableValues = {@VariableValue(variable = "a")}) | ||
public static FieldReadWriteWithBranchingExample multipleReturns(int y) { | ||
FieldReadWriteWithBranchingExample e = new FieldReadWriteWithBranchingExample(); | ||
if (y > 0) { | ||
e.a = 42; | ||
return e; | ||
} else { | ||
e.a = 23; | ||
return e; | ||
} | ||
} | ||
|
||
@ObjectValues({ | ||
@ObjectValue(variable = "lv0", constantValues = {@ConstantValue(variable = "a", value = 42)}), | ||
@ObjectValue(variable = "lv2", variableValues = {@VariableValue(variable = "a")}), | ||
@ObjectValue(variable = "lv4", variableValues = {@VariableValue(variable = "a")}) | ||
}) | ||
public static void main(String[] args) { | ||
FieldReadWriteWithBranchingExample example1 = new FieldReadWriteWithBranchingExample(); | ||
FieldReadWriteWithBranchingExample example2 = new FieldReadWriteWithBranchingExample(); | ||
FieldReadWriteWithBranchingExample example3 = new FieldReadWriteWithBranchingExample(); | ||
|
||
if (args.length == 0) { | ||
example1.a = 42; | ||
example2.a = 23; | ||
example3.a = example2.a; | ||
} else { | ||
example1.a = 40; | ||
example1.a += 2; | ||
example3.a = example1.a; | ||
} | ||
|
||
System.out.println("e1: " + example1.a + ", e2: " + example2.a + ", e3: " + example3.a); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be sensible to move these into a subpackage of the fixtures.linear_constant_propagation package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds logical. However, at the moment there are two separate test classes, one for LCP and one for LCPoF. When moving the fixtures inside the linear_constant_propagation package then the tests for LCP do pick up the fixtures for LCPoF too. I guess we would need to specify each test fixture for LCP manually instead of providing the package. Is there an alternative solution to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about one fixture directory with two subdirectories, for LCP and LCPoF?