Commit a6dfda54 authored by Taddeus Kroes's avatar Taddeus Kroes

Applied pep8.

parent 4ccad119
...@@ -107,6 +107,7 @@ class Statement: ...@@ -107,6 +107,7 @@ class Statement:
return self.is_command() \ return self.is_command() \
and re.match('^l(w|a|b|bu|\.d|\.s)|dlw$', \ and re.match('^l(w|a|b|bu|\.d|\.s)|dlw$', \
self.name) self.name)
def is_logical(self): def is_logical(self):
"""Check if the statement is a logical operator.""" """Check if the statement is a logical operator."""
return self.is_command() and re.match('^(xor|or|and)i?$', self.name) return self.is_command() and re.match('^(xor|or|and)i?$', self.name)
...@@ -194,7 +195,7 @@ class Statement: ...@@ -194,7 +195,7 @@ class Statement:
if self.is_double_arithmetic() or self.is_set_if_less() \ if self.is_double_arithmetic() or self.is_set_if_less() \
or self.is_logical() \ or self.is_logical() \
or self.is_command(*['addu', 'subu']): or self.is_command(*['addu', 'subu']):
if not isinstance(self[2] , int): if not isinstance(self[2], int):
use.append(self[2]) use.append(self[2])
return use return use
......
...@@ -93,25 +93,20 @@ class TestStatement(unittest.TestCase): ...@@ -93,25 +93,20 @@ class TestStatement(unittest.TestCase):
self.assertTrue(S('command', 'addu', '$1', '$2', '$3').is_arith()) self.assertTrue(S('command', 'addu', '$1', '$2', '$3').is_arith())
self.assertFalse(S('command', 'foo').is_arith()) self.assertFalse(S('command', 'foo').is_arith())
self.assertFalse(S('label', 'addu').is_arith()) self.assertFalse(S('label', 'addu').is_arith())
def test_get_def(self): def test_get_def(self):
self.assertEqual(S('command', 'move', '$1', '$2').get_def(), ['$1']) self.assertEqual(S('command', 'move', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'subu', '$1', '$2').get_def(), ['$1']) self.assertEqual(S('command', 'subu', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'addu','$1','$2','$3').get_def(), ['$1']) self.assertEqual(S('command', 'addu', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'sll','$1','$2','$3').get_def(), ['$1']) self.assertEqual(S('command', 'sll', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'srl','$1','$2','$3').get_def(), ['$1']) self.assertEqual(S('command', 'srl', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'la', '$1','16($fp)').get_def(), ['$1']) self.assertEqual(S('command', 'lb', 'a', '16($fp)').get_def(), ['a'])
self.assertEqual(S('command', 'li', '$1','16($fp)').get_def(), ['$1']) self.assertEqual(S('command', 'li', 'a', '16($fp)').get_def(), ['a'])
self.assertEqual(S('command','add.d', '$1','$2','$3').get_def(),['$1']) self.assertEqual(S('command', 'add.d', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command','neg.d', '$1','$2').get_def(),['$1']) self.assertEqual(S('command', 'neg.d', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command','sub.d','$1','$2', '$3').get_def(),['$1']) self.assertEqual(S('command', 'sub.d', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command','slt', '$1','$2').get_def(),['$1']) self.assertEqual(S('command', 'slt', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command','xori', '$1','$2', '0x0000').get_def(), \ self.assertEqual(S('command', 'xori', 'a', 'b', '0x0000').get_def(),
['$1']) ['a'])
self.assertEqual(S('command','mov.d', '$1','$2').get_def(), ['$1']) self.assertEqual(S('command', 'mov.d', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command','dmfc1', '$1','$f0').get_def(), ['$1']) self.assertEqual(S('command', 'dmfc1', 'a', '$f0').get_def(), ['a'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment