Commit a6dfda54 authored by Taddeus Kroes's avatar Taddeus Kroes

Applied pep8.

parent 4ccad119
......@@ -107,6 +107,7 @@ class Statement:
return self.is_command() \
and re.match('^l(w|a|b|bu|\.d|\.s)|dlw$', \
self.name)
def is_logical(self):
"""Check if the statement is a logical operator."""
return self.is_command() and re.match('^(xor|or|and)i?$', self.name)
......@@ -194,7 +195,7 @@ class Statement:
if self.is_double_arithmetic() or self.is_set_if_less() \
or self.is_logical() \
or self.is_command(*['addu', 'subu']):
if not isinstance(self[2] , int):
if not isinstance(self[2], int):
use.append(self[2])
return use
......
......@@ -95,23 +95,18 @@ class TestStatement(unittest.TestCase):
self.assertFalse(S('label', 'addu').is_arith())
def test_get_def(self):
self.assertEqual(S('command', 'move', '$1', '$2').get_def(), ['$1'])
self.assertEqual(S('command', 'subu', '$1', '$2').get_def(), ['$1'])
self.assertEqual(S('command', 'addu','$1','$2','$3').get_def(), ['$1'])
self.assertEqual(S('command', 'sll','$1','$2','$3').get_def(), ['$1'])
self.assertEqual(S('command', 'srl','$1','$2','$3').get_def(), ['$1'])
self.assertEqual(S('command', 'la', '$1','16($fp)').get_def(), ['$1'])
self.assertEqual(S('command', 'li', '$1','16($fp)').get_def(), ['$1'])
self.assertEqual(S('command','add.d', '$1','$2','$3').get_def(),['$1'])
self.assertEqual(S('command','neg.d', '$1','$2').get_def(),['$1'])
self.assertEqual(S('command','sub.d','$1','$2', '$3').get_def(),['$1'])
self.assertEqual(S('command','slt', '$1','$2').get_def(),['$1'])
self.assertEqual(S('command','xori', '$1','$2', '0x0000').get_def(), \
['$1'])
self.assertEqual(S('command','mov.d', '$1','$2').get_def(), ['$1'])
self.assertEqual(S('command','dmfc1', '$1','$f0').get_def(), ['$1'])
self.assertEqual(S('command', 'move', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'subu', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'addu', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'sll', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'srl', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'lb', 'a', '16($fp)').get_def(), ['a'])
self.assertEqual(S('command', 'li', 'a', '16($fp)').get_def(), ['a'])
self.assertEqual(S('command', 'add.d', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'neg.d', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'sub.d', 'a', 'b', 'c').get_def(), ['a'])
self.assertEqual(S('command', 'slt', 'a', 'b').get_def(), ['a'])
self.assertEqual(S('command', 'xori', 'a', 'b', '0x0000').get_def(),
['a'])
self.assertEqual(S('command', 'mov.d', 'a', 'b').get_def(), ['a'])
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