diff --git a/ASTree.cpp b/ASTree.cpp index c92480e..d6ee5c6 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -1104,6 +1104,17 @@ PycRef BuildFromCode(PycRef code, PycModule* mod) stack.push(new ASTBinary(left, right, ASTBinary::BIN_IP_MAT_MULTIPLY)); } break; + case Pyc::IS_OP_A: + { + PycRef right = stack.top(); + stack.pop(); + PycRef left = stack.top(); + stack.pop(); + // The operand will be 0 for 'is' and 1 for 'is not'. + // Map those back to the appropriate values in ASTCompare::op_str() + stack.push(new ASTCompare(left, right, operand ? 9 : 8)); + } + break; case Pyc::JUMP_IF_FALSE_A: case Pyc::JUMP_IF_TRUE_A: case Pyc::JUMP_IF_FALSE_OR_POP_A: diff --git a/tests/compiled/is_op.3.9.pyc b/tests/compiled/is_op.3.9.pyc new file mode 100644 index 0000000..964fb30 Binary files /dev/null and b/tests/compiled/is_op.3.9.pyc differ diff --git a/tests/input/is_op.py b/tests/input/is_op.py new file mode 100644 index 0000000..d7dcfbb --- /dev/null +++ b/tests/input/is_op.py @@ -0,0 +1,9 @@ +a = 10 +b = 10 + +if a is b: + pass + +if a is not b: + pass + diff --git a/tests/tokenized/is_op.txt b/tests/tokenized/is_op.txt new file mode 100644 index 0000000..fead02e --- /dev/null +++ b/tests/tokenized/is_op.txt @@ -0,0 +1,9 @@ +a = 10 +b = 10 +if a is b : + +pass + +if a is not b : + +pass