board_inspector: try mroe type convertions when evaluating branch conditions
In commite5ba06cbe8
("board_inspector: a workaround to an incorrect interpretation") a workaround is introduced to check the data type of predicate operands. That commit assumes that both operands must be exactly integers, which is not usually the case as operation fields or strings can also be used in predicates. This patch applies the following conversions on both operands when evaluating a predicate: 1. Try converting both operands to integers 2. If either conversion in step 1 fails, try regarding both operands as strings. 3. If either operand is not a string, return the default result (i.e. False). Fixes:e5ba06cbe8
("board_inspector: a workaround to an incorrect interpretation") Tracked-On: #6287 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
25cabe14db
commit
4cb0d95fc0
|
@ -398,10 +398,13 @@ class ConcreteInterpreter(Interpreter):
|
|||
#
|
||||
# As a workaround, check if both the left and right hand sides are integers first. If either is not the case,
|
||||
# the condition is evaluated to False.
|
||||
if isinstance(lhs, Integer) and isinstance(rhs, Integer):
|
||||
res = Integer(op(lhs.get(), rhs.get()))
|
||||
else:
|
||||
res = Integer(0)
|
||||
try:
|
||||
res = Integer(op(lhs.to_integer().get(), rhs.to_integer().get()))
|
||||
except NotImplementedError:
|
||||
if isinstance(lhs, String) and isinstance(rhs, String):
|
||||
res = Integer(op(lhs.get(), rhs.get()))
|
||||
else:
|
||||
res = Integer(0)
|
||||
if len(tree.children) >= 3:
|
||||
target = self.interpret(tree.children[2])
|
||||
if target:
|
||||
|
|
Loading…
Reference in New Issue