-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-23.cl
77 lines (65 loc) · 1.46 KB
/
test-23.cl
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- Adapted from the CRM
class Silly {
var1 : Int <- 0;
var2 : Int <- 0;
set_var1(v : Int) : SELF_TYPE {
{
var1 <- v;
self;
}
};
set_var2(v : Int) : SELF_TYPE {
{
var2 <- v;
self;
}
};
get_var1() : Int {
var1
};
get_var2() : Int {
var2
};
};
class Sally inherits Silly { };
class Main inherits IO {
x : Silly <- (new Silly).copy();
y : Sally <- new Sally;
z : Silly;
a : Sally;
main() : Sally {{
z <- y.copy();
out_int(x.get_var1());
out_int(x.get_var2());
out_int(y.get_var1());
out_int(y.get_var2());
out_int(z.get_var1());
out_int(z.get_var2());
y.set_var1(5);
z.set_var2(2);
a <- y.copy();
a.set_var1(1);
a.set_var2(19);
out_int(a.get_var1());
out_int(a.get_var2());
out_int(y.get_var1());
out_int(y.get_var2());
out_int(z.get_var1());
out_int(z.get_var2());
y.set_var1(23);
y.set_var2(4);
z.set_var1(8);
z.set_var2(3);
out_int(a.get_var1());
out_int(a.get_var2());
out_int(y.get_var1());
out_int(y.get_var2());
out_int(z.get_var1());
out_int(z.get_var2());
out_string(x.type_name());
out_string(y.type_name());
out_string(z.type_name());
out_string(a.type_name());
a;
}};
};