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();
|
let parser_state = parser.read();
|
||||||
match *parser_state {
|
match *parser_state {
|
||||||
ParserState::CodeOperator(ref op) => {
|
ParserState::CodeOperator(ref op) => {
|
||||||
debug_assert!(
|
if state.in_unreachable_code() {
|
||||||
state.phantom_unreachable_stack_depth == 0 ||
|
|
||||||
state.real_unreachable_stack_depth > 0
|
|
||||||
);
|
|
||||||
if state.real_unreachable_stack_depth > 0 {
|
|
||||||
translate_unreachable_operator(op, &mut builder, &mut state)
|
translate_unreachable_operator(op, &mut builder, &mut state)
|
||||||
} else {
|
} else {
|
||||||
translate_operator(
|
translate_operator(
|
||||||
|
|||||||
@@ -200,4 +200,14 @@ impl TranslationState {
|
|||||||
reachable: false,
|
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