Add string conversions for predicates and encodings.
This is just used for printing better comments in generated code.
This commit is contained in:
@@ -65,6 +65,14 @@ class Predicate(object):
|
||||
(p.predicate_context() for p in parts))
|
||||
assert self.context, "Incompatible predicate parts"
|
||||
|
||||
def __str__(self):
|
||||
s = '{}({})'.format(
|
||||
type(self).__name__,
|
||||
' ,'.join(map(str, self.parts)))
|
||||
if self.name:
|
||||
s = '{}={}'.format(self.name, s)
|
||||
return s
|
||||
|
||||
def predicate_context(self):
|
||||
return self.context
|
||||
|
||||
@@ -164,6 +172,10 @@ class FieldPredicate(object):
|
||||
self.function = function
|
||||
self.args = args
|
||||
|
||||
def __str__(self):
|
||||
args = (self.field.name,) + tuple(map(str, self.args))
|
||||
return '{}({})'.format(self.function, ', '.join(args))
|
||||
|
||||
def predicate_context(self):
|
||||
"""
|
||||
This predicate can be evaluated in the context of an instruction
|
||||
|
||||
Reference in New Issue
Block a user