|
1 | 1 | use crate::{ |
2 | 2 | expression::{def_buffer, def_package, expression_opcode}, |
3 | 3 | misc::{arg_obj, local_obj}, |
4 | | - name_object::{name_seg, name_string}, |
| 4 | + name_object::{name_seg, name_string, target, Target}, |
5 | 5 | namespace::{AmlName, LevelType}, |
6 | 6 | opcode::{self, ext_opcode, opcode}, |
7 | 7 | parser::{ |
@@ -851,6 +851,34 @@ where |
851 | 851 | .discard_result() |
852 | 852 | } |
853 | 853 |
|
| 854 | +pub fn def_cond_ref_of<'a, 'c>() -> impl Parser<'a, 'c, AmlValue> |
| 855 | +where |
| 856 | + 'c: 'a, |
| 857 | +{ |
| 858 | + /* |
| 859 | + * DefCondRefOf := ExtOpPrefix 0x12 NameString Target => boolean |
| 860 | + */ |
| 861 | + ext_opcode(opcode::EXT_DEF_COND_REF_OF_OP) |
| 862 | + .then(comment_scope( |
| 863 | + DebugVerbosity::Scopes, |
| 864 | + "DefCondRefOf", |
| 865 | + name_string().then(target()).map_with_context(|(source, target), context| { |
| 866 | + let handle = context.namespace.search(&source, &context.current_scope); |
| 867 | + let result = AmlValue::Boolean(handle.is_ok()); |
| 868 | + log::error!("{:?} was {}found", &source, if handle.is_ok() { "" } else { "not " }); |
| 869 | + if let Ok((_name, _handle)) = handle { |
| 870 | + match target { |
| 871 | + Target::Null => { /* just return the result of the check */ } |
| 872 | + _ => todo!(), |
| 873 | + } |
| 874 | + |
| 875 | + } |
| 876 | + (Ok(result), context) |
| 877 | + }), |
| 878 | + )) |
| 879 | + .map(|((), result)| Ok(result)) |
| 880 | +} |
| 881 | + |
854 | 882 | pub fn term_arg<'a, 'c>() -> impl Parser<'a, 'c, AmlValue> |
855 | 883 | where |
856 | 884 | 'c: 'a, |
|
0 commit comments