Skip to content

Commit 33b41f6

Browse files
committed
aml: support DefIncrement, DefDecrement
1 parent dea87c4 commit 33b41f6

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

aml/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ impl Interpreter {
9696
}
9797
}
9898
}
99+
Opcode::Increment | Opcode::Decrement => {
100+
let [Argument::Object(operand)] = &op.arguments[..] else { panic!() };
101+
let Object::Integer(operand) = operand.gain_mut() else { panic!() };
102+
103+
let new_value = match op.op {
104+
Opcode::Increment => operand.wrapping_add(1),
105+
Opcode::Decrement => operand.wrapping_sub(1),
106+
_ => unreachable!(),
107+
};
108+
109+
*operand = new_value;
110+
}
99111
Opcode::Name => {
100112
let [Argument::Namestring(name), Argument::Object(object)] = &op.arguments[..] else {
101113
panic!()
@@ -624,7 +636,7 @@ impl Interpreter {
624636
}
625637

626638
Opcode::Divide => context.start_in_flight_op(OpInFlight::new(Opcode::Divide, 4)),
627-
Opcode::Increment | Opcode::Decrement => context.start_in_flight_op(OpInFlight::new(opcode, 2)),
639+
Opcode::Increment | Opcode::Decrement => context.start_in_flight_op(OpInFlight::new(opcode, 1)),
628640
Opcode::Not => context.start_in_flight_op(OpInFlight::new(Opcode::Not, 2)),
629641
Opcode::FindSetLeftBit | Opcode::FindSetRightBit => {
630642
context.start_in_flight_op(OpInFlight::new(opcode, 2))

tests/external.asl

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/inc.asl renamed to tests/incdec.asl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DefinitionBlock("inc.aml", "DSDT", 1, "RSACPI", "INCDEC", 1) {
1+
DefinitionBlock("incdec.aml", "DSDT", 1, "RSACPI", "INCDEC", 1) {
22
Name(X, 0)
33
X++
44
X++

0 commit comments

Comments
 (0)