Skip to content

Commit 25680a2

Browse files
rw-vancIsaacWoods
authored andcommitted
Add l_and parser and opcode
1 parent 066cb83 commit 25680a2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

aml/src/expression.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ where
4949
def_l_less(),
5050
def_l_less_equal(),
5151
def_l_not_equal(),
52+
def_l_and(),
5253
def_l_or(),
5354
def_mid(),
5455
def_object_type(),
@@ -305,6 +306,27 @@ where
305306
.map(|((), result)| Ok(result))
306307
}
307308

309+
fn def_l_and<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
310+
where
311+
'c: 'a,
312+
{
313+
/*
314+
* DefLAnd := 0x90 Operand Operand
315+
* Operand := TermArg => Integer
316+
*/
317+
opcode(opcode::DEF_L_AND_OP)
318+
.then(comment_scope(
319+
DebugVerbosity::AllScopes,
320+
"DefLOr",
321+
term_arg().then(term_arg()).map_with_context(|(left_arg, right_arg), context| {
322+
let left = try_with_context!(context, left_arg.as_bool());
323+
let right = try_with_context!(context, right_arg.as_bool());
324+
(Ok(AmlValue::Boolean(left && right)), context)
325+
}),
326+
))
327+
.map(|((), result)| Ok(result))
328+
}
329+
308330
fn def_l_or<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
309331
where
310332
'c: 'a,

aml/src/opcode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub const DEF_SHIFT_RIGHT: u8 = 0x7a;
6868
pub const DEF_AND_OP: u8 = 0x7b;
6969
pub const DEF_CONCAT_RES_OP: u8 = 0x84;
7070
pub const DEF_OBJECT_TYPE_OP: u8 = 0x8e;
71+
pub const DEF_L_AND_OP: u8 = 0x90;
7172
pub const DEF_L_OR_OP: u8 = 0x91;
7273
pub const DEF_L_NOT_OP: u8 = 0x92;
7374
pub const DEF_L_EQUAL_OP: u8 = 0x93;

0 commit comments

Comments
 (0)