-
Notifications
You must be signed in to change notification settings - Fork 0
/
sjp25
executable file
·164 lines (154 loc) · 3.27 KB
/
sjp25
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
1: Program
2: Vars
3: X Int
4: Y Int
5: B Bool
6: S Struct
7: X Int
8: B Bool
9: EndStruct
10: S1 Struct
11: X Int
12: B Bool
13: EndStruct
14: EndVars
15: X:=5
16: S.B:=True
17: S1.X:=4
18: S1.B:=False
19: If (X*3>10 And S.B) Then
20: S.X:=X
21: S1:=S
22: EndIf
23: WriteLn(S1.X)
24: WriteLn(S1.B)
25: EndProgram
26:
program
\__list
| \__ident(X)
| | \__int
| \__ident(Y)
| | \__int
| \__ident(B)
| | \__bool
| \__ident(S)
| | \__struct
| | \__ident(X)
| | | \__int
| | \__ident(B)
| | \__bool
| \__ident(S1)
| \__struct
| \__ident(X)
| | \__int
| \__ident(B)
| \__bool
\__list
\__list
\__:=
| \__ident(X)
| \__intconst(5)
\__:=
| \__.
| | \__ident(S)
| | \__ident(B)
| \__true
\__:=
| \__.
| | \__ident(S1)
| | \__ident(X)
| \__intconst(4)
\__:=
| \__.
| | \__ident(S1)
| | \__ident(B)
| \__false
\__if
| \__and
| | \__>
| | | \__*
| | | | \__ident(X)
| | | | \__intconst(3)
| | | \__intconst(10)
| | \__.
| | \__ident(S)
| | \__ident(B)
| \__list
| \__:=
| | \__.
| | | \__ident(S)
| | | \__ident(X)
| | \__ident(X)
| \__:=
| \__ident(S1)
| \__ident(S)
\__writeln
| \__.
| \__ident(S1)
| \__ident(X)
\__writeln
\__.
\__ident(S1)
\__ident(B)
Type Checking:
Generating code:
program
parameters
static_link
endparameters
variables
_X 4
_Y 4
_B 4
_S 8
_S1 8
endvariables
aload _X t0
iload 5 t1
stor t1 t0
aload _S t0
addi t0 4 t0
iload 1 t1
stor t1 t0
aload _S1 t0
addi t0 0 t0
iload 4 t1
stor t1 t0
aload _S1 t0
addi t0 4 t0
iload 0 t1
stor t1 t0
load _X t0
iload 3 t1
muli t0 t1 t0
iload 10 t1
grti t0 t1 t0
aload _S t1
addi t1 4 t1
load t1 t1
land t0 t1 t0
fjmp t0 endif_1
aload _S t0
addi t0 0 t0
load _X t1
stor t1 t0
aload _S1 t0
aload _S t1
copy t1 t0 8
etiq endif_1
aload _S1 t0
addi t0 0 t0
load t0 t0
wrii t0
wrln
aload _S1 t0
addi t0 4 t0
load t0 t0
wrii t0
wrln
stop
endprogram
Executing code:
5
1