Skip to content

Commit 7a42ae3

Browse files
committed
Clean some IL commands
1 parent 1617ba5 commit 7a42ae3

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

il_cmds/compare.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def _fix_either_literal64(self, arg1_spot, arg2_spot, regs,
7070
else:
7171
return arg1_spot, arg2_spot
7272

73+
# Value to output when the two operands are equal
74+
equal_value = None
75+
76+
# Value to output when the two operands are not equal
77+
not_equal_value = None
7378

7479
def make_asm(self, spotmap, home_spots, get_reg, asm_code): # noqa D102
7580
regs = []
@@ -108,8 +113,8 @@ class NotEqualCmp(_GeneralEqualCmp):
108113
109114
"""
110115

111-
equal_value = "0"
112-
not_equal_value = "1"
116+
equal_value = 0
117+
not_equal_value = 1
113118

114119

115120
class EqualCmp(_GeneralEqualCmp):
@@ -120,5 +125,5 @@ class EqualCmp(_GeneralEqualCmp):
120125
121126
"""
122127

123-
equal_value = "1"
124-
not_equal_value = "0"
128+
equal_value = 1
129+
not_equal_value = 0

il_cmds/control.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ def make_asm(self, spotmap, home_spots, get_reg, asm_code): # noqa D102
4545
asm_code.add(asm_cmds.Jmp(self.label))
4646

4747

48-
class _GeneralJumpZero(ILCommand):
48+
class _GeneralJump(ILCommand):
4949
"""General class for jumping to a label based on condition."""
5050

51+
# ASM command to output for this jump IL command.
52+
# (asm_cmds.Je for JumpZero and asm_cmds.Jne for JumpNotZero)
53+
asm_cmd = None
54+
5155
def __init__(self, cond, label): # noqa D102
5256
self.cond = cond
5357
self.label = label
@@ -76,13 +80,13 @@ def make_asm(self, spotmap, home_spots, get_reg, asm_code): # noqa D102
7680
asm_code.add(self.command(self.label))
7781

7882

79-
class JumpZero(_GeneralJumpZero):
83+
class JumpZero(_GeneralJump):
8084
"""Jumps to a label if given condition is zero."""
8185

8286
command = asm_cmds.Je
8387

8488

85-
class JumpNotZero(_GeneralJumpZero):
89+
class JumpNotZero(_GeneralJump):
8690
"""Jumps to a label if given condition is zero."""
8791

8892
command = asm_cmds.Jne

0 commit comments

Comments
 (0)