This repository was archived by the owner on Jul 12, 2023. It is now read-only.
forked from polyglot-compiler/JLang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssign.java
97 lines (90 loc) · 1.75 KB
/
Assign.java
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
public class Assign {
static int g = ten();
int i = ten();
static int ten() {
System.out.println("Side effect");
return 10;
}
Assign(int n) {}
Assign() {
// Test that member initializer side effects are not duplicated.
this(0);
}
public static void main(String[] args) {
int n = ten();
show(n);
n += 3;
show(n);
n -= 3;
show(n);
n *= 2;
show(n);
n /= 2;
show(n);
n %= 6;
show(n);
n |= 0x12345678;
show(n);
n &= 0x87654321;
show(n);
n >>= 3;
show(n);
n <<= 2;
show(n);
n = -1;
n >>>= 12;
show(n);
System.out.println();
show(g);
g += 3;
show(g);
g -= 3;
show(g);
g *= 2;
show(g);
g /= 2;
show(g);
g %= 6;
show(g);
g |= 0x12345678;
show(g);
g &= 0x87654321;
show(g);
g >>= 3;
show(g);
g <<= 2;
show(g);
g = -1;
g >>>= 12;
show(g);
System.out.println();
Assign a = new Assign();
show(a.i);
a.i += 3;
show(a.i);
a.i -= 3;
show(a.i);
a.i *= 2;
show(a.i);
a.i /= 2;
show(a.i);
a.i %= 6;
show(a.i);
a.i |= 0x12345678;
show(a.i);
a.i &= 0x87654321;
show(a.i);
a.i >>= 3;
show(a.i);
a.i <<= 2;
show(a.i);
a.i = -1;
a.i >>>= 12;
show(a.i);
System.out.println();
}
static void show(int n) {
System.out.print(n);
System.out.print(" ");
}
}