Adds support for IS_OP opcode
Mentioned in: - #190 - #191 - #195
This commit is contained in:
11
ASTree.cpp
11
ASTree.cpp
@@ -1104,6 +1104,17 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
|||||||
stack.push(new ASTBinary(left, right, ASTBinary::BIN_IP_MAT_MULTIPLY));
|
stack.push(new ASTBinary(left, right, ASTBinary::BIN_IP_MAT_MULTIPLY));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Pyc::IS_OP_A:
|
||||||
|
{
|
||||||
|
PycRef<ASTNode> right = stack.top();
|
||||||
|
stack.pop();
|
||||||
|
PycRef<ASTNode> 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_FALSE_A:
|
||||||
case Pyc::JUMP_IF_TRUE_A:
|
case Pyc::JUMP_IF_TRUE_A:
|
||||||
case Pyc::JUMP_IF_FALSE_OR_POP_A:
|
case Pyc::JUMP_IF_FALSE_OR_POP_A:
|
||||||
|
BIN
tests/compiled/is_op.3.9.pyc
Normal file
BIN
tests/compiled/is_op.3.9.pyc
Normal file
Binary file not shown.
9
tests/input/is_op.py
Normal file
9
tests/input/is_op.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
a = 10
|
||||||
|
b = 10
|
||||||
|
|
||||||
|
if a is b:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if a is not b:
|
||||||
|
pass
|
||||||
|
|
9
tests/tokenized/is_op.txt
Normal file
9
tests/tokenized/is_op.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
a = 10 <EOL>
|
||||||
|
b = 10 <EOL>
|
||||||
|
if a is b : <EOL>
|
||||||
|
<INDENT>
|
||||||
|
pass <EOL>
|
||||||
|
<OUTDENT>
|
||||||
|
if a is not b : <EOL>
|
||||||
|
<INDENT>
|
||||||
|
pass <EOL>
|
Reference in New Issue
Block a user