@@ -214,6 +214,7 @@ impl Interpreter {
214
214
const DEF_ELSE_OP : u8 = 0xa1 ;
215
215
// TODO: maybe need to handle error here
216
216
if context. peek ( ) ? == DEF_ELSE_OP {
217
+ context. next ( ) ?;
217
218
let _else_length = context. pkglength ( ) ?;
218
219
}
219
220
}
@@ -400,11 +401,12 @@ impl Interpreter {
400
401
// Check for an else-branch, and skip over it
401
402
// TODO: if we run out of stream here, it might just be an IfOp at the
402
403
// end I think?
403
- let start_pc = context. current_block . pc ;
404
404
const DEF_ELSE_OP : u8 = 0xa1 ;
405
405
if context. peek ( ) ? == DEF_ELSE_OP {
406
- let else_length = context. pkglength ( ) ? - ( context. current_block . pc - start_pc) ;
407
- context. current_block . pc += else_length;
406
+ context. next ( ) ?;
407
+ let start_pc = context. current_block . pc ;
408
+ let else_length = context. pkglength ( ) ?;
409
+ context. current_block . pc += else_length - ( context. current_block . pc - start_pc) ;
408
410
}
409
411
410
412
continue ;
@@ -754,8 +756,7 @@ impl Interpreter {
754
756
1 ,
755
757
) ) ;
756
758
}
757
- // TODO: maybe should be a normal error instead
758
- Opcode :: Else => panic ! ( "Unexpected DefElseOp without corresponding DefIfElseOp" ) ,
759
+ Opcode :: Else => return Err ( AmlError :: ElseFoundWithoutCorrespondingIf ) ,
759
760
Opcode :: While => todo ! ( ) ,
760
761
Opcode :: Noop => { }
761
762
Opcode :: Return => context. start_in_flight_op ( OpInFlight :: new ( Opcode :: Return , 1 ) ) ,
@@ -1347,6 +1348,7 @@ pub enum AmlError {
1347
1348
ObjectDoesNotExist ( AmlName ) ,
1348
1349
1349
1350
NoCurrentOp ,
1351
+ ElseFoundWithoutCorrespondingIf ,
1350
1352
1351
1353
MethodArgCountIncorrect ,
1352
1354
0 commit comments