mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
board_inspector: fix unregisteration of conditionally disabled objects
The current ConditionallyUnregisterSymbolVisitor has the following two issues. 1. The visitor will crash when a DefIfElse node is not fully parsed due to failed deferred expansion. 2. Nested DefIfElse of disabled blocks are still checked and one of its branch may still take effect. This patch fixes those issues by checking the predicates of a DefIfElse block only when conditionally_hidden is False and check existence of TermList and DefElse clauses. Tracked-On: #6298 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
35edd7804a
commit
a5f5ed0865
@ -46,24 +46,26 @@ class ConditionallyUnregisterSymbolVisitor(Visitor):
|
||||
return f
|
||||
|
||||
def visit_topdown(self, tree):
|
||||
if tree.label == "DefIfElse":
|
||||
if not self.conditionally_hidden and tree.label == "DefIfElse":
|
||||
self.context.change_scope(tree.scope)
|
||||
cond = self.interpreter.interpret(tree.children[1]).get()
|
||||
self.context.pop_scope()
|
||||
|
||||
self.depth += 1
|
||||
if cond:
|
||||
self.visit_topdown(tree.children[2])
|
||||
if len(tree.children) == 4:
|
||||
if hasattr(tree, "TermList"):
|
||||
self.visit_topdown(tree.TermList)
|
||||
if hasattr(tree, "DefElse") and tree.DefElse:
|
||||
self.conditionally_hidden = True
|
||||
self.visit_topdown(tree.children[3])
|
||||
self.visit_topdown(tree.DefElse)
|
||||
self.conditionally_hidden = False
|
||||
else:
|
||||
if hasattr(tree, "TermList"):
|
||||
self.conditionally_hidden = True
|
||||
self.visit_topdown(tree.children[2])
|
||||
self.visit_topdown(tree.TermList)
|
||||
self.conditionally_hidden = False
|
||||
if len(tree.children) == 4:
|
||||
self.visit_topdown(tree.children[3])
|
||||
if hasattr(tree, "DefElse") and tree.DefElse:
|
||||
self.visit_topdown(tree.DefElse)
|
||||
self.depth -= 1
|
||||
elif tree.label not in ["DefMethod"]:
|
||||
super().visit_topdown(tree)
|
||||
|
Loading…
Reference in New Issue
Block a user