rust-osdev/acpi

AML: Handle "if (field)"

rw-vanc opened this issue · 3 comments

In real-world AML, I have encountered if (field). This requires evaluating the field as boolean. I would like to fix this by using as_integer to evaluate the field, but as_integer takes context as an argument, and as_bool does not. Most of the occurrences of as_bool have context readily available, but there is one case where it is not (the place where I actually need it).

https://github.com/rust-osdev/acpi/blob/main/aml/src/statement.rs#L145

Can you recommend the change to this line so I can call as_bool(context)?

Fixed, ignore this issue.

As an aside, I've been questioning whether we should have a separate boolean type - afaik it's never existed in the actual spec and we just treat it as a special-cased integer type and conversions back and forth make it seamless. Lmk if you have thoughts either way, and if no objections I'll explore getting rid of it

I don't think AmlValue::Boolean is necessary. as_bool is a useful thing, but it can probably just delegate to as_integer and do self.as_integer(context)? != 0.