Add a predicate_leafs() method.
This collects all of the leaf predicates that go into a compound predicate. Current leaf predicates are: - Settings for ISA predicates, and - FieldPredicates for instruction predicates.
This commit is contained in:
@@ -41,6 +41,9 @@ class Setting(object):
|
||||
"""
|
||||
return self.group
|
||||
|
||||
def predicate_leafs(self, leafs):
|
||||
leafs.add(self)
|
||||
|
||||
|
||||
class BoolSetting(Setting):
|
||||
"""
|
||||
|
||||
@@ -68,6 +68,13 @@ class Predicate(object):
|
||||
def predicate_context(self):
|
||||
return self.context
|
||||
|
||||
def predicate_leafs(self, leafs):
|
||||
"""
|
||||
Collect all leaf predicates into the `leafs` set.
|
||||
"""
|
||||
for part in self.parts:
|
||||
part.predicate_leafs(leafs)
|
||||
|
||||
|
||||
class And(Predicate):
|
||||
"""
|
||||
@@ -164,6 +171,9 @@ class FieldPredicate(object):
|
||||
"""
|
||||
return self.field.format
|
||||
|
||||
def predicate_leafs(self, leafs):
|
||||
leafs.add(self)
|
||||
|
||||
def rust_predicate(self, prec):
|
||||
"""
|
||||
Return a string of Rust code that evaluates this predicate.
|
||||
|
||||
Reference in New Issue
Block a user