Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pop bug, make all AsmNode hashable

pop bug: pop was using repr on its operand
AsmNode: nodes hash on their str(node) value now
  • Loading branch information...
commit 9300551a930b463dea21e5309b1cd5e01c669acf 1 parent 2eb28c4
@cantora authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 pyc_asm_nodes.py
View
16 pyc_asm_nodes.py
@@ -15,6 +15,16 @@ def __repr__(self):
return fmt % tup
def __eq__(self, other):
+ return str(self).__eq__(str(other))
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __hash__(self):
+ return str(self).__hash__()
+
+"""
+ def __eq__(self, other):
if type(other) is type(self):
return self.__dict__ == other.__dict__
else:
@@ -22,6 +32,7 @@ def __eq__(self, other):
def __ne__(self, other):
return not __eq__(self, other)
+"""
class Operand:
@@ -193,7 +204,7 @@ def __init__(self, operand):
self.write_operand('operand', operand)
def __str__(self):
- return self.inst_join(["pop", repr(self.operand)])
+ return self.inst_join(["pop", str(self.operand)])
class Neg(Inst):
@@ -238,6 +249,7 @@ def __init__(self, name, needs_reg=False):
def __str__(self):
return self.name
+"""
def __eq__(self, other):
return str(self).__eq__(str(other))
@@ -246,7 +258,7 @@ def __ne__(self, other):
def __hash__(self):
return str(self).__hash__()
-
+"""
class Register(Var):
def __init__(self, name):
Please sign in to comment.
Something went wrong with that request. Please try again.