Skip to content

Commit

Permalink
Use ins.argrepr for representation of operator variables
Browse files Browse the repository at this point in the history
  • Loading branch information
guyer committed Feb 22, 2024
1 parent 4bb7b84 commit f9cd267
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions fipy/variables/operatorVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ def __var(self, i, style, argDict, id, freshen):
62: "<<", 63: ">>", 64: "&", 65: "^", 66: "|", 106: "=="
}

# introduced in Python 3.11
_binary_op = {
0: "+", 1: "&", 2: "//", 3: "<<", 4: "@", 5: "*", 6: "%", 7: "|",
8: "**", 9: ">>", 10: "-", 11: "/", 12: "^"
}

def _py2kInstructions(self, bytecodes, style, argDict, id, freshen):
def _popIndex():
return bytecodes.pop(0) + bytecodes.pop(0) * 256
Expand Down Expand Up @@ -221,7 +215,7 @@ def _py3kInstructions(self, op, style, argDict, id, freshen):
# LOAD_METHOD new in Python 3.7
stack.append(stack.pop() + "." + ins.argval)
elif ins.opname == 'COMPARE_OP':
stack.append(stack.pop(-2) + " " + dis.cmp_op[ins.arg] + " " + stack.pop())
stack.append(stack.pop(-2) + " " + ins.argrepr + " " + stack.pop())
elif ins.opname == 'LOAD_GLOBAL':
# Changed in Python 3.11
stack.append(ins.argval)
Expand Down Expand Up @@ -249,7 +243,7 @@ def _py3kInstructions(self, op, style, argDict, id, freshen):
pass
elif ins.opname == 'BINARY_OP':
# New in Python 3.11
stack.append(stack.pop(-2) + " " + self._binary_op[ins.argval] + " " + stack.pop())
stack.append(stack.pop(-2) + " " + ins.argrepr + " " + stack.pop())
elif ins.opname == 'PRECALL':
# New in Python 3.11
pass
Expand Down

0 comments on commit f9cd267

Please sign in to comment.