@@ -107,24 +107,24 @@ The control stack is likewise manipulated through auxiliary functions:
107
107
.. code-block :: pseudo
108
108
109
109
func push_ctrl(opcode : opcode, in : list(val_type), out : list(val_type)) =
110
- let frame = ctrl_frame(opcode, in, out, vals.size(), false)
111
- ctrls.push(frame)
110
+ let frame = ctrl_frame(opcode, in, out, vals.size(), false)
111
+ ctrls.push(frame)
112
112
push_vals(in)
113
113
114
114
func pop_ctrl() : ctrl_frame =
115
- error_if(ctrls.is_empty())
116
- let frame = ctrls[0]
117
- pop_vals(frame.end_types)
118
- error_if(vals.size() =/= frame.height)
115
+ error_if(ctrls.is_empty())
116
+ let frame = ctrls[0]
117
+ pop_vals(frame.end_types)
118
+ error_if(vals.size() =/= frame.height)
119
119
ctrls.pop()
120
- return frame
120
+ return frame
121
121
122
122
func label_types(frame : ctrl_frame) : list(val_types) =
123
123
return (if frame.opcode == loop then frame.start_types else frame.end_types)
124
124
125
125
func unreachable() =
126
- vals.resize(ctrls[0].height)
127
- ctrls[0].unreachable := true
126
+ vals.resize(ctrls[0].height)
127
+ ctrls[0].unreachable := true
128
128
129
129
Pushing a control frame takes the types of the label and result values.
130
130
It allocates a new frame record recording them along with the current height of the operand stack and marks the block as reachable.
@@ -182,8 +182,8 @@ Other instructions are checked in a similar manner.
182
182
pop_val(t)
183
183
push_val(t)
184
184
185
- case (unreachable)
186
- unreachable()
185
+ case (unreachable)
186
+ unreachable()
187
187
188
188
case (block t1*->t2*)
189
189
pop_vals([t1*])
@@ -208,26 +208,26 @@ Other instructions are checked in a similar manner.
208
208
push_ctrl(else, frame.start_types, frame.end_types)
209
209
210
210
case (br n)
211
- error_if(ctrls.size() < n)
212
- pop_vals(label_types(ctrls[n]))
213
- unreachable()
211
+ error_if(ctrls.size() < n)
212
+ pop_vals(label_types(ctrls[n]))
213
+ unreachable()
214
214
215
215
case (br_if n)
216
- error_if(ctrls.size() < n)
216
+ error_if(ctrls.size() < n)
217
217
pop_val(I32)
218
- pop_vals(label_types(ctrls[n]))
219
- push_vals(label_types(ctrls[n]))
218
+ pop_vals(label_types(ctrls[n]))
219
+ push_vals(label_types(ctrls[n]))
220
220
221
- case (br_table n* m)
221
+ case (br_table n* m)
222
222
pop_val(I32)
223
- error_if(ctrls.size() < m)
223
+ error_if(ctrls.size() < m)
224
224
let arity = label_types(ctrls[m]).size()
225
- foreach (n in n*)
226
- error_if(ctrls.size() < n)
227
- error_if(label_types(ctrls[n]).size() =/= arity)
225
+ foreach (n in n*)
226
+ error_if(ctrls.size() < n)
227
+ error_if(label_types(ctrls[n]).size() =/= arity)
228
228
push_vals(pop_vals(label_types(ctrls[n])))
229
229
pop_vals(label_types(ctrls[m]))
230
- unreachable()
230
+ unreachable()
231
231
232
232
233
233
.. note ::
0 commit comments