board_inspector: always defer parsing of method bodies

The current ACPI AML parser can generate incorrect AST if a DSDT/SSDT
satisfies the following:

  1. The body of a method invokes a NameString that is defined later.

  2. Before that method the same NameString is also defined but in an outer
     scope and with a different number of parameter.

Since method bodies hardly define any further symbol that is referenced
outside the method itself, this patch forces the parsing of method bodies
to be deferred to the second pass when all symbols have been declared.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao
2021-07-16 21:15:11 +08:00
committed by wenlingz
parent 60920bb905
commit d325966612

View File

@@ -293,6 +293,14 @@ class SequenceFactory(Factory):
factory.parse(context, child)
tree.append_child(child)
else:
# It is likely that a method body has forward definitions, while typically it does not define
# symbols that are referred later. Thus always defer the parsing of method bodies to the second
# phase.
#
# In second phase the labels of sequence factories always have the ".deferred" suffix. Thus it is
# safe to check self.label against "DefMethod" here.
if elem == "TermList" and self.label == "DefMethod":
raise DeferLater(self.label, [elem])
factory = globals()[elem]
child = Tree()
factory.parse(context, child)