Add TranslationState::in_unreachable_code().
Move an unreachable code test and sanity check into this method.
This commit is contained in:
@@ -118,11 +118,7 @@ pub fn translate_function_body(
|
||||
let parser_state = parser.read();
|
||||
match *parser_state {
|
||||
ParserState::CodeOperator(ref op) => {
|
||||
debug_assert!(
|
||||
state.phantom_unreachable_stack_depth == 0 ||
|
||||
state.real_unreachable_stack_depth > 0
|
||||
);
|
||||
if state.real_unreachable_stack_depth > 0 {
|
||||
if state.in_unreachable_code() {
|
||||
translate_unreachable_operator(op, &mut builder, &mut state)
|
||||
} else {
|
||||
translate_operator(
|
||||
|
||||
@@ -200,4 +200,14 @@ impl TranslationState {
|
||||
reachable: false,
|
||||
});
|
||||
}
|
||||
|
||||
/// Test if the translation state is currently in unreachable code.
|
||||
pub fn in_unreachable_code(&self) -> bool {
|
||||
if self.real_unreachable_stack_depth > 0 {
|
||||
true
|
||||
} else {
|
||||
debug_assert_eq!(self.phantom_unreachable_stack_depth, 0, "in reachable code");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user