Skip to content

Commit d38ca73

Browse files
committed
aml: fix handling of DefContinue
1 parent eb47b1c commit d38ca73

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

aml/src/lib.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,16 +932,22 @@ where
932932
context.start_in_flight_op(OpInFlight::new(Opcode::While, 1));
933933
}
934934
Opcode::Continue => {
935-
let BlockKind::While { start_pc } = &context.current_block.kind else {
936-
Err(AmlError::ContinueOutsideOfWhile)?
937-
};
938-
context.current_block.pc = *start_pc;
935+
if let BlockKind::While { start_pc } = &context.current_block.kind {
936+
context.current_block.pc = *start_pc;
937+
} else {
938+
loop {
939+
let Some(block) = context.block_stack.pop() else {
940+
Err(AmlError::ContinueOutsideOfWhile)?
941+
};
942+
if let BlockKind::While { start_pc } = block.kind {
943+
context.current_block.pc = start_pc;
944+
break;
945+
}
946+
}
947+
}
939948
context.start_in_flight_op(OpInFlight::new(Opcode::While, 1));
940949
}
941950
Opcode::Break => {
942-
/*
943-
* Break out of the innermost `DefWhile`.
944-
*/
945951
if let BlockKind::While { .. } = &context.current_block.kind {
946952
context.current_block = context.block_stack.pop().unwrap();
947953
} else {
@@ -950,10 +956,10 @@ where
950956
Err(AmlError::BreakOutsideOfWhile)?
951957
};
952958
if let BlockKind::While { .. } = block.kind {
959+
context.current_block = context.block_stack.pop().unwrap();
953960
break;
954961
}
955962
}
956-
context.current_block = context.block_stack.pop().unwrap();
957963
}
958964
}
959965
Opcode::Return => context.start_in_flight_op(OpInFlight::new(Opcode::Return, 1)),

0 commit comments

Comments
 (0)