From 59b176c24ed2ed18e7dcc2a9d27d4ca4edd4eaf1 Mon Sep 17 00:00:00 2001 From: Connor Wood Date: Mon, 24 Jul 2017 09:09:07 +0100 Subject: [PATCH] Implemented path parent character "^" when calculating scope paths --- src/acpi/aml/namespace.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/acpi/aml/namespace.rs b/src/acpi/aml/namespace.rs index 9c7f564..8c18f1a 100644 --- a/src/acpi/aml/namespace.rs +++ b/src/acpi/aml/namespace.rs @@ -1,5 +1,6 @@ use alloc::boxed::Box; use collections::string::String; +use collections::string::ToString; use collections::vec::Vec; use core::fmt::{Debug, Formatter, Error}; @@ -174,7 +175,7 @@ impl Method { pub fn get_namespace_string(current: String, modifier_v: AmlValue) -> String { // TODO: Type error if modifier not string - let modifier = if let Ok(s) = modifier_v.get_as_string() { + let mut modifier = if let Ok(s) = modifier_v.get_as_string() { s } else { return current; @@ -192,12 +193,15 @@ pub fn get_namespace_string(current: String, modifier_v: AmlValue) -> String { return modifier; } - if modifier.starts_with("^") { - // TODO - } - let mut namespace = current.clone(); + if modifier.starts_with("^") { + while modifier.starts_with("^") { + modifier = modifier[1..].to_string(); + while namespace.pop() != Some('.') { } + } + } + if !namespace.ends_with("\\") { namespace.push('.'); }