Merge pull request #203 from dotjrich/contains-op
Adds support for CONTAINS_OP opcode
This commit is contained in:
10
ASTree.cpp
10
ASTree.cpp
@@ -620,6 +620,16 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
|||||||
stack.push(new ASTCompare(left, right, operand));
|
stack.push(new ASTCompare(left, right, operand));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Pyc::CONTAINS_OP_A:
|
||||||
|
{
|
||||||
|
PycRef<ASTNode> right = stack.top();
|
||||||
|
stack.pop();
|
||||||
|
PycRef<ASTNode> left = stack.top();
|
||||||
|
stack.pop();
|
||||||
|
// The operand will be 0 for 'in' and 1 for 'not in'.
|
||||||
|
stack.push(new ASTCompare(left, right, operand ? ASTCompare::CMP_NOT_IN : ASTCompare::CMP_IN));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Pyc::DELETE_ATTR_A:
|
case Pyc::DELETE_ATTR_A:
|
||||||
{
|
{
|
||||||
PycRef<ASTNode> name = stack.top();
|
PycRef<ASTNode> name = stack.top();
|
||||||
|
BIN
tests/compiled/contains_op.3.9.pyc
Normal file
BIN
tests/compiled/contains_op.3.9.pyc
Normal file
Binary file not shown.
8
tests/input/contains_op.py
Normal file
8
tests/input/contains_op.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
a = 10
|
||||||
|
b = [10, 20, 30]
|
||||||
|
|
||||||
|
if a in b:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if a not in b:
|
||||||
|
pass
|
9
tests/tokenized/contains_op.txt
Normal file
9
tests/tokenized/contains_op.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
a = 10 <EOL>
|
||||||
|
b = [ 10 , 20 , 30 ] <EOL>
|
||||||
|
if a in b : <EOL>
|
||||||
|
<INDENT>
|
||||||
|
pass <EOL>
|
||||||
|
<OUTDENT>
|
||||||
|
if a not in b : <EOL>
|
||||||
|
<INDENT>
|
||||||
|
pass <EOL>
|
Reference in New Issue
Block a user