-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExercise7.ql
More file actions
48 lines (40 loc) · 1.45 KB
/
Exercise7.ql
File metadata and controls
48 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java
// Replace with the solution from exercise 1
class AllocationSite extends Expr {
AllocationSite() { none() }
}
predicate alloc(LocalScopeVariable variable, AllocationSite allocationSite, Callable callable) {
// Replace with the solution from exercise 2.
any()
}
predicate move(LocalScopeVariable dest, Variable src) {
// Exercise 3: Describe how a value in `src` is moved to `dest`
none()
}
predicate store(LocalScopeVariable qualifier, Field field, LocalScopeVariable src) {
// Replace with the solution from exercise 4.
any()
}
predicate load(LocalScopeVariable dest, LocalScopeVariable qualifier, Field field) {
// Replace with the solution from exercise 5.
any()
}
predicate fieldPointsTo(
AllocationSite qualifierAllocationSite, Field field, AllocationSite srcAllocationSite
) {
// Replace with the solution from exercise 6
any()
}
predicate varPointsTo(LocalScopeVariable variable, AllocationSite allocationSite) {
alloc(variable, allocationSite, _)
or
exists(LocalScopeVariable src | move(variable, src) and varPointsTo(src, allocationSite))
// Exercise 7: Implement the propagation of points-to information from a field load to a variable.
// That is the pattern, `a = b.c`
// or
//exists(LocalScopeVariable qualifier, AllocationSite qualifierAllocationSite, Field field |
//)
}
from LocalScopeVariable variable, AllocationSite allocationSite
where varPointsTo(variable, allocationSite)
select variable, allocationSite