Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
peephole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
peephole
Commits
a6dfda54
Commit
a6dfda54
authored
Dec 29, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied pep8.
parent
4ccad119
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
src/statement.py
src/statement.py
+2
-1
tests/test_statement.py
tests/test_statement.py
+16
-21
No files found.
src/statement.py
View file @
a6dfda54
...
@@ -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
...
...
tests/test_statement.py
View file @
a6dfda54
...
@@ -95,23 +95,18 @@ class TestStatement(unittest.TestCase):
...
@@ -95,23 +95,18 @@ class TestStatement(unittest.TestCase):
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'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment