[meta-python] Use named predicates for x86 encodings instead of anonymous predicates;

And generate those in a deterministic order that the Rust crate can
reproduce easily.
This commit is contained in:
Benjamin Bouvier
2019-04-15 16:51:15 +02:00
parent 5cd0724fef
commit 6a25354520
3 changed files with 27 additions and 11 deletions

View File

@@ -229,16 +229,25 @@ class SettingGroup(object):
.format(self, SettingGroup._current))
SettingGroup._current = None
if globs:
# Ensure that named predicates are ordered in a deterministic way
# that the Rust crate may simply reproduce, by pushing entries into
# a vector that we'll sort by name later.
named_predicates = []
for name, obj in globs.items():
if isinstance(obj, Setting):
assert obj.name is None, obj.name
obj.name = name
if isinstance(obj, Predicate):
self.named_predicates[name] = obj
named_predicates.append((name, obj))
if isinstance(obj, Preset):
assert obj.name is None, obj.name
obj.name = name
named_predicates.sort(key=lambda x: x[0])
for (name, obj) in named_predicates:
self.named_predicates[name] = obj
self.layout()
@staticmethod