Skip to content

Commit

Permalink
parser: Handle unreachable reminder of a block
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Apr 2, 2020
1 parent 7e3e9ee commit 8687ebf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/fizzy/parser_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, bool have
case Instr::f64_reinterpret_i64:

case Instr::unreachable:
case Instr::return_:
frame.unreachable = true;
break;

case Instr::nop:
case Instr::return_:
case Instr::drop:
case Instr::select:
case Instr::i32_eq:
Expand Down Expand Up @@ -339,6 +339,10 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, bool have
throw validation_error{"invalid label index"};

push(code.immediates, label_idx);

if (instr == Instr::br)
frame.unreachable = true;

break;
}

Expand Down Expand Up @@ -375,6 +379,9 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, bool have
for (const auto idx : label_indices)
push(code.immediates, idx);
push(code.immediates, default_label_idx);

frame.unreachable = true;

break;
}

Expand Down

0 comments on commit 8687ebf

Please sign in to comment.