|
@@ -1,15 +1,6 @@
|
|
|
-use crate::{
|
|
|
- misc::ArgNum,
|
|
|
- namespace::AmlName,
|
|
|
- parser::Parser,
|
|
|
- pkg_length::PkgLength,
|
|
|
- term_object::term_list,
|
|
|
- AmlContext,
|
|
|
- AmlError,
|
|
|
-};
|
|
|
+use crate::{misc::ArgNum, namespace::AmlName, AmlError};
|
|
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
|
|
use bit_field::BitField;
|
|
|
-use log::{error, info};
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
pub enum RegionSpace {
|
|
@@ -218,55 +209,6 @@ impl AmlValue {
|
|
|
_ => Err(AmlError::IncompatibleValueConversion),
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /// If this value is a control method, invoke it. Returns `AmlError::IncompatibleValueConversion` if this
|
|
|
- /// is not a method.
|
|
|
- pub fn invoke(&self, context: &mut AmlContext, args: Args, scope: AmlName) -> Result<AmlValue, AmlError> {
|
|
|
- if let AmlValue::Method { flags, ref code } = self {
|
|
|
- /*
|
|
|
- * First, set up the state we expect to enter the method with, but clearing local
|
|
|
- * variables to "null" and setting the arguments.
|
|
|
- */
|
|
|
- context.current_scope = scope;
|
|
|
- context.current_args = Some(args);
|
|
|
- context.local_0 = None;
|
|
|
- context.local_1 = None;
|
|
|
- context.local_2 = None;
|
|
|
- context.local_3 = None;
|
|
|
- context.local_4 = None;
|
|
|
- context.local_5 = None;
|
|
|
- context.local_6 = None;
|
|
|
- context.local_7 = None;
|
|
|
-
|
|
|
- let return_value =
|
|
|
- match term_list(PkgLength::from_raw_length(code, code.len() as u32)).parse(code, context) {
|
|
|
- // If the method doesn't return a value, we implicitly return `0`
|
|
|
- Ok((remaining, context, result)) => Ok(AmlValue::Integer(0)),
|
|
|
- Err((remaining, context, AmlError::Return(result))) => Ok(result),
|
|
|
- Err((remaining, context, err)) => {
|
|
|
- error!("Failed to execute control method: {:?}", err);
|
|
|
- Err(err)
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /*
|
|
|
- * Now clear the state.
|
|
|
- */
|
|
|
- context.current_args = None;
|
|
|
- context.local_0 = None;
|
|
|
- context.local_1 = None;
|
|
|
- context.local_2 = None;
|
|
|
- context.local_3 = None;
|
|
|
- context.local_4 = None;
|
|
|
- context.local_5 = None;
|
|
|
- context.local_6 = None;
|
|
|
- context.local_7 = None;
|
|
|
-
|
|
|
- return_value
|
|
|
- } else {
|
|
|
- Err(AmlError::IncompatibleValueConversion)
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/// A control method can take up to 7 arguments, each of which can be an `AmlValue`.
|