board_inspector: skip visiting DefMethod properly when unregistering symbols
The current implementation of the ConditionallyUnregisterSymbolVisitor exits upon visiting a DefMethod node without unregistering that method. As a result, methods in False branches in DSDT/SSDTs are not removed from the parsed namespace, which can lead to further confusions when these methods are referenced (e.g. a _CRS method visited by the board inspector). This patch fixes this by always visiting a DefMethod node but stops traversing its children. Tracked-On: #6287 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
5ad06e933a
commit
d58ef5e2aa
|
@ -63,15 +63,18 @@ class Visitor:
|
|||
if not fn:
|
||||
fn = getattr(self, "default", None)
|
||||
if fn:
|
||||
fn(tree)
|
||||
return fn(tree)
|
||||
else:
|
||||
return True
|
||||
|
||||
def _visit_topdown(self, tree):
|
||||
self.__visit_node(tree)
|
||||
self.depth += 1
|
||||
for child in tree.children:
|
||||
if isinstance(child, Tree):
|
||||
self.visit(child)
|
||||
self.depth -= 1
|
||||
go_on = self.__visit_node(tree)
|
||||
if go_on != False:
|
||||
self.depth += 1
|
||||
for child in tree.children:
|
||||
if isinstance(child, Tree):
|
||||
self.visit(child)
|
||||
self.depth -= 1
|
||||
|
||||
def _visit_bottomup(self, tree):
|
||||
self.depth += 1
|
||||
|
|
|
@ -38,17 +38,18 @@ class ConditionallyUnregisterSymbolVisitor(Visitor):
|
|||
self.interpreter = interpreter
|
||||
self.conditionally_hidden = False
|
||||
|
||||
self.DefName = self.__unregister(0)
|
||||
self.DefMethod = self.__unregister(1)
|
||||
self.DefDevice = self.__unregister(1)
|
||||
self.DefName = self.__unregister(0, False)
|
||||
self.DefMethod = self.__unregister(1, False)
|
||||
self.DefDevice = self.__unregister(1, True)
|
||||
|
||||
def __unregister(self, name_string_idx):
|
||||
def __unregister(self, name_string_idx, go_on):
|
||||
def f(tree):
|
||||
if self.conditionally_hidden:
|
||||
scope = tree.scope
|
||||
name = tree.children[name_string_idx].value
|
||||
realpath = self.context.realpath(scope, name)
|
||||
self.context.unregister_object(realpath)
|
||||
return go_on
|
||||
return f
|
||||
|
||||
def visit(self, tree):
|
||||
|
@ -73,7 +74,7 @@ class ConditionallyUnregisterSymbolVisitor(Visitor):
|
|||
if hasattr(tree, "DefElse") and tree.DefElse:
|
||||
self.visit(tree.DefElse)
|
||||
self.depth -= 1
|
||||
elif tree.label not in ["DefMethod"]:
|
||||
else:
|
||||
self._visit_topdown(tree)
|
||||
|
||||
class GenerateBinaryVisitor(Visitor):
|
||||
|
|
Loading…
Reference in New Issue