Call function in the predicates module.

When generating Rust code for an instruction predicate, call the corresponding
function in the predicates module, using a qualified name.

We don't have methods corresponding to the predicates.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-25 14:24:02 -07:00
parent b788ab8020
commit 5f6859f0d9

View File

@@ -155,13 +155,13 @@ class FieldPredicate(object):
An instruction predicate that performs a test on a single `FormatField`. An instruction predicate that performs a test on a single `FormatField`.
:param field: The `FormatField` to be tested. :param field: The `FormatField` to be tested.
:param method: Boolean predicate method to call. :param function: Boolean predicate function to call.
:param args: Arguments for the predicate method. :param args: Additional arguments for the predicate function.
""" """
def __init__(self, field, method, args): def __init__(self, field, function, args):
self.field = field self.field = field
self.method = method self.function = function
self.args = args self.args = args
def predicate_context(self): def predicate_context(self):
@@ -178,10 +178,9 @@ class FieldPredicate(object):
""" """
Return a string of Rust code that evaluates this predicate. Return a string of Rust code that evaluates this predicate.
""" """
return '{}.{}({})'.format( # Prepend `field` to the predicate function arguments.
self.field.rust_name(), args = (self.field.rust_name(),) + tuple(map(str, self.args))
self.method, return 'predicates::{}({})'.format(self.function, ', '.join(args))
', '.join(self.args))
class IsSignedInt(FieldPredicate): class IsSignedInt(FieldPredicate):