5. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
6. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
7. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
8. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
9. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
10. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
11. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Name Analysis
Assign to each reference its corresponding deļ¬nition
12. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Type Analysis
Assign a type to each expression
13. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
Type Analysis
float
Assign a type to each expression
14. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
Type Analysis
Assign a type to each expression
float
15. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
B
Type Analysis
Assign a type to each expression
float
16. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
B
float
Type Analysis
Assign a type to each expression
float
17. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
B
float
float
Type Analysis
Assign a type to each expression
float
18. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
float
B
float
float
Type Analysis
Assign a type to each expression
float
19. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
float
B
int
float
float
Type Analysis
Assign a type to each expression
float
20. class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
float
B
int
float
float
float
21. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
float m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
float
B
int
float
float
float
float
22. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
float
B
int
float
float
int
float
23. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
float
B
int
float
float
int
int
24. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
int
return m()
25. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
return 1 + b.f
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
B
int
int
return m()
float
float
float
27. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
return 1 + b.f
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
int
return m()
28. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
return 1 + b.f
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
int
return m()
1. Caching
Reuse analysis results from previous analysis
29. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
return 1 + b.f
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
int
return m()
2. Change detection
Which part of the program has changed?
30. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
return 1 + b.f
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
int
return m()
3. Invalidation & propagation
Which calculations are affected by a change?
31. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
float
4. Dependency tracking
What are the dependencies between calculations?
32. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
What are the dependencies between calculations?
4. Dependency tracking
33. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
How to (re-)schedule invalidated calculations?
5. Scheduling
34. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
35. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
f
36. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
i
37. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Caching
i
38. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Change Detection
i
39. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Invalidation
i
40. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Propagation
i
41. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Propagation
i
42. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Propagation
i
43. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Scheduling
i
44. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Scheduling
i
45. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
float int
float
Scheduling
i
46. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
float
Scheduling
int
i
47. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
float
B
int
int
Scheduling
int
i
48. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.f;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
Scheduling
int
i
49. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
Scheduling
int
50. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
52. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
53. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
Units of computation ...
54. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
... with cacheable results ...
55. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
... and dependencies on each other
56. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
int
int
B
int
int
int
resolve class A resolve class B
resolve method m resolve field b
resolve field i
Name resolution
tasks
57. class C : A {
!
int n() {
return m();
}
}
class A {
!
B b;
!
int m;
!
int m() {
return 1 + b.i;
}
}
class B {
!
int i;
!
float f;
!
int m() {
return 0;
}
}
resolve class A resolve class B
resolve method m resolve field b
resolve field i
calc type of m()
calc type of i
calc type of b
calc type of b.i
calc type of 1 + b.i
calc type of 0
Name resolution
tasks
Typing tasks
60. class B {
int i;
float f;
}
class A {
B b;
float m() { return 1 + b.i; }
}
61. class B {
int i;
float f;
}
class A {
B b;
float m() { return 1 + b.i; }
}
62. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
class A {
B b;
float m() { return 1 + b.i; }
}
Facts
63. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
class A {
B b;
float m() { return 1 + b.i; }
}
Facts
Tasks
64. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
class A {
B b;
float m() { return 1 + b.i; }
}
Facts
Tasks
65. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
Facts
Tasks
define class A
66. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
Facts
Tasks
define class A
67. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
Facts
Tasks
define class A
68. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1 2
Facts
Tasks
define class A
69. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1 2
3Facts
Tasks
define class A
70. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1 2
4
3Facts
Tasks
define class A
71. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
5
2
4
3Facts
Tasks
define class A
72. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
6
5
2
4
3Facts
Tasks
define class A
73. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
6
5
7
2
4
3Facts
Tasks
define class A
74. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
6
5
7
2
4
3
8
Facts
Tasks
define class A
75. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B1
6
5
7
2
4
3
8
Facts
Tasks
define class A
77. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
78. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
i
79. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
f
80. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
f
81. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
f
82. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field b
calc type of b
calc type of 1
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
f
83. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
f
84. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
1
define class A
f
85. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
2
1
define class A
f
86. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
2
1
3
define class A
f
87. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
2
1
3 4
define class A
f
88. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
2
1
3 4
define class A
f
89. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
90. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
float f;
91. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
92. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
93. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
94. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
95. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
96. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
97. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
1
98. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
2
1
99. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
2
1
3
100. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
2
1
3 4
101. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
102. type of i is int
define field i
class B {
int i;
float f;
}
define class B
resolve field f
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.f
calc type of f
calc type of b.f
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.f; }
}
resolve class B
define class A
113. type of i is int
define field i
define field f
type of f is float
class B {
int i;
float f;
}
define class B
resolve field i
resolve field b
calc type of b
calc type of 1
calc type of 1 + b.i
calc type of i
calc type of b.i
define field b
define method m
type of b is B
type of m is float
class A {
B b;
float m() { return 1 + b.i; }
}
resolve class B
define class A
121. Class("Point", [
Field("x"),
Field("y"),
Func("print", [
Print(VarRef("x")),
Print(VarRef("y"))
])
])
def-site:
Class(x, _) -> <store-def(|"Class")> x
scope-site:
Class(_, _) -> <scope> ["Var", "Func"]
!
def-site:
Field(x) -> <store-def(|"Var")> x
!
def-site:
Func(x, _) -> <store-def(|"Func")> x
scope-site:
Func(_, _) -> <scope> ["Var"]
!
ref-site:
VarRef(v) -> <create-lookup-task(|"Var",
ā¦fact-dependenciesā¦)> v
!
analyse =
topdown(def-site; scope-site);
bottomup(ref-site);
execute-tasks
Implementation not
concerned with:
Incrementality
Execution order
Fact and Task Collection
122. Class("Point", [
Field("x"),
Field("y"),
Func("print", [
Print(VarRef("x")),
Print(VarRef("y"))
])
])
def-site:
Class(x, _) -> <store-def(|"Class")> x
scope-site:
Class(_, _) -> <scope> ["Var", "Func"]
!
def-site:
Field(x) -> <store-def(|"Var")> x
!
def-site:
Func(x, _) -> <store-def(|"Func")> x
scope-site:
Func(_, _) -> <scope> ["Var"]
!
ref-site:
VarRef(v) -> <create-lookup-task(|"Var",
ā¦fact-dependenciesā¦)> v
!
analyse =
topdown(def-site; scope-site);
bottomup(ref-site);
execute-tasks
Implementation not
concerned with:
Incrementality
Execution order
Analysis is described in
terms of tasks
Fact and Task Collection
123. Declarative Name Analysis Speciļ¬cation
Class(x, _):
defines Class x
scopes Var, Func
Field(x):
defines Var x
Func(x, _):
defines Func x
scopes Var
VarRef(x):
refers to Var x
NaBL
124. Declarative Name Analysis Speciļ¬cation
Class(x, _):
defines Class x
scopes Var, Func
Field(x):
defines Var x
Func(x, _):
defines Func x
scopes Var
VarRef(x):
refers to Var x
NaBL
Specify name analysis in terms of:
Deļ¬nitions
Namespaces
Scopes
References
Imports
125. Declarative Name Analysis Speciļ¬cation
Class(x, _):
defines Class x
scopes Var, Func
Field(x):
defines Var x
Func(x, _):
defines Func x
scopes Var
VarRef(x):
refers to Var x
NaBL def-site:
Class(x, _) -> <store-def(|"Class")> x
scope-site:
Class(_, _) -> <scope> ["Var", "Func"]
!
def-site:
Field(x) -> <store-def(|"Var")> x
!
def-site:
Func(x, _) -> <store-def(|"Func")> x
scope-site:
Func(_, _) -> <scope> ["Var"]
!
ref-site:
VarRef(v) -> <create-lookup-task(|"Var",
ā¦fact-dependenciesā¦)> v
!
analyse =
topdown(def-site; scope-site);
bottomup(ref-site);
execute-tasks
Generates
126. Declarative Name Analysis Speciļ¬cation
Class(x, _):
defines Class x
scopes Var, Func
Field(x):
defines Var x
Func(x, _):
defines Func x
scopes Var
VarRef(x):
refers to Var x
NaBL def-site:
Class(x, _) -> <store-def(|"Class")> x
scope-site:
Class(_, _) -> <scope> ["Var", "Func"]
!
def-site:
Field(x) -> <store-def(|"Var")> x
!
def-site:
Func(x, _) -> <store-def(|"Func")> x
scope-site:
Func(_, _) -> <scope> ["Var"]
!
ref-site:
VarRef(v) -> <create-lookup-task(|"Var",
ā¦fact-dependenciesā¦)> v
!
analyse =
topdown(def-site; scope-site);
bottomup(ref-site);
execute-tasks
Generates
resolve Var x
define Var x
define Class Point
define Var y
define Func print
resolve Var y
127. Declarative Type System Speciļ¬cation
True() : Bool()
False() : Bool()
!
And(x, y) : Bool()
where x : x-ty
and y : y-ty
and x-ty == Bool()
else error
"Expected bool"
and y-ty == Bool()
else error
"Expected bool"
TS
128. Declarative Type System Speciļ¬cation
True() : Bool()
False() : Bool()
!
And(x, y) : Bool()
where x : x-ty
and y : y-ty
and x-ty == Bool()
else error
"Expected bool"
and y-ty == Bool()
else error
"Expected bool"
TS
Specify type system in terms of:
Type rules
Relations
Error messages
129. Declarative Type System Speciļ¬cation
True() : Bool()
False() : Bool()
!
And(x, y) : Bool()
where x : x-ty
and y : y-ty
and x-ty == Bool()
else error
"Expected bool"
and y-ty == Bool()
else error
"Expected bool"
TS
create-type-task(|ctx) :
True() -> <task-create-id(|ctx,[x16])> x16
where
x16 := <type-is(|ctx)> Bool()
!
create-type-task(|ctx) :
False() -> <task-create-id(|ctx,[x17])> x17
where
x17 := <type-is(|ctx)> Bool()
!
create-type-task(|ctx) :
And(x, y) -> <task-create-id(|ctx,[x7])> x7
where
x-ty := <type-task(|ctx)> x;
y-ty := <type-task(|ctx);
eq38 := <type-match(|ctx, Bool());
<task-create-error-on-failure(|ctx, eq38, "Expected bool")> x;
eq39 := <type-match(|ctx, Bool())
<task-create-error-on-failure(|ctx, eq39, "Expected bool")> y;
x7 := <type-is(|ctx); task-create-id(|ctx, [eq39])> Bool()
Generates
130. Expressivity of Declarative Speciļ¬cations
Minus(x, y)
+ Mul(x, y)
+ Div(x, y)
+ Mod(x, y) : ty
where x : x-ty
and y : y-ty
and x-ty <is: Numerical()
else error "Expected numerical" on x
and y-ty <is: Numerical()
else error "Expected numerical" on y
and <promote-bin> (x-ty, y-ty) => ty
ClassDec(acc, ctx, mod*, c, tp*, None(), _, body):
defines Type c
of access acc
of context ctx
of modifiers mod*
of type-parameters tp*
of kind Class()
of type RefType(TypeName(c), None())
implicitly defines ImplicitField "this"
of type RefType(TypeName(c), None())
scopes TypeParam, Field, ImplicitField,
Method, Constructor
NaBL TS
131. Expressivity of Declarative Speciļ¬cations
Can specify name and type analysis of Java 3
Minus(x, y)
+ Mul(x, y)
+ Div(x, y)
+ Mod(x, y) : ty
where x : x-ty
and y : y-ty
and x-ty <is: Numerical()
else error "Expected numerical" on x
and y-ty <is: Numerical()
else error "Expected numerical" on y
and <promote-bin> (x-ty, y-ty) => ty
ClassDec(acc, ctx, mod*, c, tp*, None(), _, body):
defines Type c
of access acc
of context ctx
of modifiers mod*
of type-parameters tp*
of kind Class()
of type RefType(TypeName(c), None())
implicitly defines ImplicitField "this"
of type RefType(TypeName(c), None())
scopes TypeParam, Field, ImplicitField,
Method, Constructor
NaBL TS
140. Guido H.Wachsmuth
Vlad A.Vergu
Danny M. Groenewegen
EelcoVisser
Acknowledgements
Name Binding Language (NaBL) [Konat. SLE ā12]
Task Engine for Incremental Name and Type Analysis [Wachsmuth. SLE ā13]
Augusto Passalaqua
Eduardo S. Amorim
Pierre Neron