@@ -28,25 +28,25 @@ TEST(parser_expr, instr_loop)
2828{
2929 const auto loop_void = " 03400b0b" _bytes;
3030 const auto [code1, pos1] = parse_expr (loop_void);
31- EXPECT_THAT (code1.instructions , ElementsAre (Instr::end, Instr::end ));
31+ EXPECT_THAT (code1.instructions , ElementsAre (Instr::end));
3232 EXPECT_EQ (code1.max_stack_height , 0 );
3333
3434 const auto loop_i32 = " 037f41000b1a0b" _bytes;
3535 const auto [code2, pos2] = parse_expr (loop_i32);
36- EXPECT_THAT (code2. instructions ,
37- ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::end , Instr::drop, Instr::end));
36+ EXPECT_THAT (
37+ code2. instructions , ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
3838 EXPECT_EQ (code2.max_stack_height , 1 );
3939
4040 const auto loop_f32 = " 037d43000000000b1a0b" _bytes;
4141 const auto [code3, pos3] = parse_expr (loop_f32);
42- EXPECT_THAT (code3. instructions ,
43- ElementsAre (Instr::f32_const, 0 , 0 , 0 , 0 , Instr::end , Instr::drop, Instr::end));
42+ EXPECT_THAT (
43+ code3. instructions , ElementsAre (Instr::f32_const, 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
4444 EXPECT_EQ (code3.max_stack_height , 1 );
4545
4646 const auto loop_f64 = " 037c4400000000000000000b1a0b" _bytes;
4747 const auto [code4, pos4] = parse_expr (loop_f64);
4848 EXPECT_THAT (code4.instructions ,
49- ElementsAre (Instr::f64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::end, Instr:: drop, Instr::end));
49+ ElementsAre (Instr::f64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
5050 EXPECT_EQ (code4.max_stack_height , 1 );
5151}
5252
@@ -64,17 +64,17 @@ TEST(parser_expr, instr_block)
6464
6565 const auto empty = " 010102400b0b" _bytes;
6666 const auto [code1, pos1] = parse_expr (empty);
67- EXPECT_THAT (code1.instructions , ElementsAre (Instr::end, Instr::end ));
67+ EXPECT_THAT (code1.instructions , ElementsAre (Instr::end));
6868
6969 const auto block_i64 = " 027e42000b1a0b" _bytes;
7070 const auto [code2, pos2] = parse_expr (block_i64);
7171 EXPECT_THAT (code2.instructions ,
72- ElementsAre (Instr::i64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::end, Instr:: drop, Instr::end));
72+ ElementsAre (Instr::i64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
7373
7474 const auto block_f64 = " 027c4400000000000000000b1a0b" _bytes;
7575 const auto [code3, pos3] = parse_expr (block_f64);
7676 EXPECT_THAT (code3.instructions ,
77- ElementsAre (Instr::f64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::end, Instr:: drop, Instr::end));
77+ ElementsAre (Instr::f64_const, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
7878}
7979
8080TEST (parser_expr, instr_block_input_buffer_overflow)
@@ -94,7 +94,7 @@ TEST(parser_expr, loop_br)
9494
9595 EXPECT_THAT (module ->codesec [0 ].instructions ,
9696 ElementsAre (Instr::br, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 0 , 0 , 0 , 0 ,
97- /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::end ));
97+ /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end));
9898
9999 /* wat2wasm
100100 (func
@@ -109,8 +109,7 @@ TEST(parser_expr, loop_br)
109109
110110 EXPECT_THAT (module_parent_stack->codesec [0 ].instructions ,
111111 ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br, /* arity:*/ 0 , 0 , 0 , 0 ,
112- /* code_offset:*/ 5 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::drop,
113- Instr::end));
112+ /* code_offset:*/ 5 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
114113
115114 /* wat2wasm
116115 (func
@@ -127,8 +126,7 @@ TEST(parser_expr, loop_br)
127126
128127 EXPECT_THAT (module_arity->codesec [0 ].instructions ,
129128 ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br, /* arity:*/ 0 , 0 , 0 , 0 ,
130- /* code_offset:*/ 0 , 0 , 0 , 0 , /* stack_drop:*/ 1 , 0 , 0 , 0 , Instr::end, Instr::drop,
131- Instr::end));
129+ /* code_offset:*/ 0 , 0 , 0 , 0 , /* stack_drop:*/ 1 , 0 , 0 , 0 , Instr::drop, Instr::end));
132130}
133131
134132TEST (parser_expr, loop_return)
@@ -140,8 +138,8 @@ TEST(parser_expr, loop_return)
140138 const auto module = parse (wasm);
141139
142140 EXPECT_THAT (module ->codesec [0 ].instructions ,
143- ElementsAre (Instr::return_, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 14 , 0 , 0 , 0 ,
144- /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::end ));
141+ ElementsAre (Instr::return_, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 13 , 0 , 0 , 0 ,
142+ /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end));
145143}
146144
147145TEST (parser_expr, block_br)
@@ -162,9 +160,9 @@ TEST(parser_expr, block_br)
162160 const auto [code, pos] = parse_expr (code_bin, 0 , {{2 , ValType::i32 }});
163161 EXPECT_THAT (code.instructions ,
164162 ElementsAre (Instr::i32_const, 0x0a , 0 , 0 , 0 , Instr::local_set, 1 , 0 , 0 , 0 , Instr::br,
165- /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 34 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
166- Instr::i32_const, 0x0b , 0 , 0 , 0 , Instr::local_set, 1 , 0 , 0 , 0 , Instr::end ,
167- Instr::local_get, 1 , 0 , 0 , 0 , Instr::drop, Instr::end));
163+ /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 33 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
164+ Instr::i32_const, 0x0b , 0 , 0 , 0 , Instr::local_set, 1 , 0 , 0 , 0 , Instr::local_get, 1 , 0 ,
165+ 0 , 0 , Instr::drop, Instr::end));
168166 EXPECT_EQ (code.max_stack_height , 1 );
169167
170168 /* wat2wasm
@@ -180,8 +178,7 @@ TEST(parser_expr, block_br)
180178
181179 EXPECT_THAT (module_parent_stack->codesec [0 ].instructions ,
182180 ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br, /* arity:*/ 0 , 0 , 0 , 0 ,
183- /* code_offset:*/ 19 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::drop,
184- Instr::end));
181+ /* code_offset:*/ 18 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
185182
186183 /* wat2wasm
187184 (func
@@ -198,8 +195,7 @@ TEST(parser_expr, block_br)
198195
199196 EXPECT_THAT (module_arity->codesec [0 ].instructions ,
200197 ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br, /* arity:*/ 1 , 0 , 0 , 0 ,
201- /* code_offset:*/ 19 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::drop,
202- Instr::end));
198+ /* code_offset:*/ 18 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::drop, Instr::end));
203199}
204200
205201TEST (parser_expr, block_return)
@@ -211,8 +207,8 @@ TEST(parser_expr, block_return)
211207 const auto module = parse (wasm);
212208
213209 EXPECT_THAT (module ->codesec [0 ].instructions ,
214- ElementsAre (Instr::return_, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 14 , 0 , 0 , 0 ,
215- /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, Instr::end ));
210+ ElementsAre (Instr::return_, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 13 , 0 , 0 , 0 ,
211+ /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end));
216212}
217213
218214TEST (parser_expr, if_br)
@@ -227,9 +223,9 @@ TEST(parser_expr, if_br)
227223 const auto module = parse (wasm);
228224
229225 EXPECT_THAT (module ->codesec [0 ].instructions ,
230- ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::if_, /* else_offset:*/ 24 , 0 , 0 , 0 ,
231- Instr::br, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 24 , 0 , 0 , 0 ,
232- /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end, /* 24 :*/ Instr::end));
226+ ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::if_, /* else_offset:*/ 23 , 0 , 0 , 0 ,
227+ Instr::br, /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 23 , 0 , 0 , 0 ,
228+ /* stack_drop:*/ 0 , 0 , 0 , 0 , /* 23 :*/ Instr::end));
233229
234230 /* wat2wasm
235231 (func
@@ -245,9 +241,9 @@ TEST(parser_expr, if_br)
245241
246242 EXPECT_THAT (module_parent_stack->codesec [0 ].instructions ,
247243 ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::i32_const, 0 , 0 , 0 , 0 , Instr::if_,
248- /* else_offset:*/ 29 , 0 , 0 , 0 , Instr::br, /* arity:*/ 0 , 0 , 0 , 0 ,
249- /* code_offset:*/ 29 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
250- /* 29 :*/ Instr::end, Instr::drop, Instr::end));
244+ /* else_offset:*/ 28 , 0 , 0 , 0 , Instr::br, /* arity:*/ 0 , 0 , 0 , 0 ,
245+ /* code_offset:*/ 28 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
246+ /* 28 :*/ Instr::drop, Instr::end));
251247}
252248
253249TEST (parser_expr, instr_br_table)
@@ -284,24 +280,24 @@ TEST(parser_expr, instr_br_table)
284280 EXPECT_THAT (code.instructions ,
285281 ElementsAre (Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table,
286282 /* label_count:*/ 4 , 0 , 0 , 0 , /* arity:*/ 0 , 0 , 0 , 0 ,
287- /* code_offset:*/ 130 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
288- /* code_offset:*/ 111 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
289- /* code_offset:*/ 92 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
290- /* code_offset:*/ 73 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
291- /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
283+ /* code_offset:*/ 126 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
284+ /* code_offset:*/ 108 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
285+ /* code_offset:*/ 90 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
286+ /* code_offset:*/ 72 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
287+ /* code_offset:*/ 144 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
292288
293289 /* 54:*/ Instr::i32_const, 0x41 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
294- /* code_offset:*/ 154 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end ,
295- /* 73 :*/ Instr::i32_const, 0x42 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
296- /* code_offset:*/ 154 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end ,
297- /* 92 :*/ Instr::i32_const, 0x43 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
298- /* code_offset:*/ 154 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end ,
299- /* 111 :*/ Instr::i32_const, 0x44 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
300- /* code_offset:*/ 154 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end ,
301- /* 130 :*/ Instr::i32_const, 0x45 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
302- /* code_offset:*/ 154 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::end ,
303- /* 149 :*/ Instr::i32_const, 0x46 , 0 , 0 , 0 ,
304- /* 154 :*/ Instr::end));
290+ /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
291+ /* 72 :*/ Instr::i32_const, 0x42 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
292+ /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
293+ /* 90 :*/ Instr::i32_const, 0x43 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
294+ /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
295+ /* 108 :*/ Instr::i32_const, 0x44 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
296+ /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
297+ /* 126 :*/ Instr::i32_const, 0x45 , 0 , 0 , 0 , Instr::return_, /* arity:*/ 1 , 0 , 0 , 0 ,
298+ /* code_offset:*/ 149 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
299+ /* 144 :*/ Instr::i32_const, 0x46 , 0 , 0 , 0 ,
300+ /* 149 :*/ Instr::end));
305301
306302 EXPECT_EQ (code.max_stack_height , 1 );
307303}
@@ -326,10 +322,10 @@ TEST(parser_expr, instr_br_table_empty_vector)
326322
327323 EXPECT_THAT (code.instructions ,
328324 ElementsAre (Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table,
329- /* label_count:*/ 0 , 0 , 0 , 0 , /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 41 , 0 , 0 , 0 ,
325+ /* label_count:*/ 0 , 0 , 0 , 0 , /* arity:*/ 0 , 0 , 0 , 0 , /* code_offset:*/ 40 , 0 , 0 , 0 ,
330326 /* stack_drop:*/ 0 , 0 , 0 , 0 , Instr::i32_const, 0x63 , 0 , 0 , 0 , Instr::return_,
331- /* arity:*/ 1 , 0 , 0 , 0 , /* code_offset:*/ 46 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
332- Instr::end, Instr:: i32_const, 0x64 , 0 , 0 , 0 , Instr::end));
327+ /* arity:*/ 1 , 0 , 0 , 0 , /* code_offset:*/ 45 , 0 , 0 , 0 , /* stack_drop:*/ 0 , 0 , 0 , 0 ,
328+ Instr::i32_const, 0x64 , 0 , 0 , 0 , Instr::end));
333329
334330 EXPECT_EQ (code.max_stack_height , 1 );
335331}
0 commit comments