From 278a39621524480a6e71faf3eb78331176c8a582 Mon Sep 17 00:00:00 2001 From: Ron Williams Date: Sat, 18 Feb 2023 19:14:30 -0800 Subject: [PATCH] Add l_and parser and opcode --- aml/src/expression.rs | 22 ++++++++++++++++++++++ aml/src/opcode.rs | 1 + 2 files changed, 23 insertions(+) diff --git a/aml/src/expression.rs b/aml/src/expression.rs index 81c2070c..888657a5 100644 --- a/aml/src/expression.rs +++ b/aml/src/expression.rs @@ -49,6 +49,7 @@ where def_l_less(), def_l_less_equal(), def_l_not_equal(), + def_l_and(), def_l_or(), def_mid(), def_object_type(), @@ -305,6 +306,27 @@ where .map(|((), result)| Ok(result)) } +fn def_l_and<'a, 'c>() -> impl Parser<'a, 'c, AmlValue> +where + 'c: 'a, +{ + /* + * DefLAnd := 0x90 Operand Operand + * Operand := TermArg => Integer + */ + opcode(opcode::DEF_L_AND_OP) + .then(comment_scope( + DebugVerbosity::AllScopes, + "DefLOr", + term_arg().then(term_arg()).map_with_context(|(left_arg, right_arg), context| { + let left = try_with_context!(context, left_arg.as_bool()); + let right = try_with_context!(context, right_arg.as_bool()); + (Ok(AmlValue::Boolean(left && right)), context) + }), + )) + .map(|((), result)| Ok(result)) +} + fn def_l_or<'a, 'c>() -> impl Parser<'a, 'c, AmlValue> where 'c: 'a, diff --git a/aml/src/opcode.rs b/aml/src/opcode.rs index 14198c73..b5f1a6f1 100644 --- a/aml/src/opcode.rs +++ b/aml/src/opcode.rs @@ -68,6 +68,7 @@ pub const DEF_SHIFT_RIGHT: u8 = 0x7a; pub const DEF_AND_OP: u8 = 0x7b; pub const DEF_CONCAT_RES_OP: u8 = 0x84; pub const DEF_OBJECT_TYPE_OP: u8 = 0x8e; +pub const DEF_L_AND_OP: u8 = 0x90; pub const DEF_L_OR_OP: u8 = 0x91; pub const DEF_L_NOT_OP: u8 = 0x92; pub const DEF_L_EQUAL_OP: u8 = 0x93;