Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: src/trusted/validator_arm/dgen_core.py

Issue 10949006: Change table data_processing_immediate to use the new notation. Also (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator_arm/dgen_core.py
===================================================================
--- src/trusted/validator_arm/dgen_core.py (revision 9758)
+++ src/trusted/validator_arm/dgen_core.py (working copy)
@@ -29,7 +29,8 @@
merge rows/actions of the table.
"""
if (isinstance(value, BitExpr) or isinstance(value, SymbolTable) or
- isinstance(value, Row) or isinstance(value, DecoderAction)):
+ isinstance(value, Row) or isinstance(value, DecoderAction) or
+ isinstance(value, RuleRestrictions)):
return value.neutral_repr()
elif isinstance(value, list):
return [ neutral_repr(v) for v in value ]
@@ -1234,9 +1235,6 @@
self.restrictions = restrictions[:]
self.other = other
- def __hash__(self):
- return sum([hash(r) for r in self.restrictions]) + hash(self.other)
-
def IsEmpty(self):
return not self.restrictions and not self.other
@@ -1248,16 +1246,28 @@
rep = ''
if self.restrictions:
for r in self.restrictions:
- rep += '& ' + r
+ rep += '& %s' % r
rep += ' '
if self.other:
rep += ('& other: %s' % self.other)
return rep
+ def neutral_repr(self):
+ """Returns a normalized neutral representation of the rule restrictions."""
+ rep = ''
+ if self.restrictions:
+ for r in self.restrictions:
+ rep += '& %s' % neutral_repr(r)
+ rep += ' '
+ if self.other:
+ rep += ('& other: %s' % self.other)
+ return rep
+
+ def __hash__(self):
+ return hash(self.neutral_repr())
+
def __cmp__(self, v):
- value = cmp(self.other, v.other)
- if value != 0: return value
- return cmp(self.restrictions, v.restrictions)
+ return cmp(self.neutral_repr(), neutral_repr(v))
TABLE_FORMAT="""
Table %s

Powered by Google App Engine
This is Rietveld 408576698