Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions ASTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,14 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
}
}
break;
case Pyc::JUMP_IF_NOT_EXC_MATCH_A:
{
PycRef<ASTNode> right = stack.top();
stack.pop();
PycRef<ASTNode> left = stack.top();
stack.pop();
}
break;
case Pyc::RERAISE:
case Pyc::RERAISE_A:
/* Python 3.11 cleanup opcode. */
Expand Down Expand Up @@ -2692,6 +2700,74 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.push(value);
}
break;
case Pyc::LOAD_ASSERTION_ERROR:
{
stack.push(PycRef<ASTNode>());
}
break;
case Pyc::LIST_TO_TUPLE:
{
PycRef<ASTNode> value = stack.top();
stack.pop();
stack.push(value);
}
break;
case Pyc::CALL_FUNCTION_EX_A:
{
bool has_kwargs = (operand & 1);
bool has_args = (operand & 2);

PycRef<ASTNode> kwargs_node;
PycRef<ASTNode> args_node;

if (has_kwargs) {
kwargs_node = stack.top();
stack.pop();
}
if (has_args) {
args_node = stack.top();
stack.pop();
}

PycRef<ASTNode> func = stack.top();
stack.pop();

ASTCall::pparam_t pparams;
ASTCall::kwparam_t kwparams;
PycRef<ASTNode> call = new ASTCall(func, pparams, kwparams);

if (has_args) {
call.cast<ASTCall>()->setVar(args_node);
}
if (has_kwargs) {
call.cast<ASTCall>()->setKW(kwargs_node);
}

stack.push(call);
}
break;
case Pyc::DICT_MERGE_A:
{
stack.pop();
}
break;
case Pyc::DICT_UPDATE_A:
{
stack.pop();
}
break;
// MAP_ADD and SET_ADD require comprehension AST reconstruction
case Pyc::UNPACK_EX_A:
{
int before = operand & 0xFF;
int after = (operand >> 8) & 0xFF;
unpack = before + 1 + after;
if (unpack > 0) {
ASTTuple::value_t vals;
stack.push(new ASTTuple(vals));
}
}
break;
default:
fprintf(stderr, "Unsupported opcode: %s (%d)\n", Pyc::OpcodeName(opcode), opcode);
cleanBuild = false;
Expand Down
Binary file added tests/compiled/test_assert_310.3.10.pyc
Binary file not shown.
Binary file added tests/compiled/test_call_starargs_310.3.10.pyc
Binary file not shown.
Binary file added tests/compiled/test_dict_merge_310.3.10.pyc
Binary file not shown.
Binary file added tests/compiled/test_unpack_ex_310.3.10.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/input/test_assert_310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
assert x > 0
3 changes: 3 additions & 0 deletions tests/input/test_call_starargs_310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def f(*args, **kwargs):
pass
f(*(1, 2), **{'x': 3})
2 changes: 2 additions & 0 deletions tests/input/test_dict_merge_310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d1 = {'a': 1}
d2 = {**d1, 'b': 2}
2 changes: 2 additions & 0 deletions tests/input/test_unpack_ex_310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
seq = [1, 2, 3, 4, 5]
a, *b, c = seq
4 changes: 4 additions & 0 deletions tests/tokenized/test_assert_310.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x = 1 <EOL>
if not x > 0 : <EOL>
<INDENT>
raise None <EOL>
5 changes: 5 additions & 0 deletions tests/tokenized/test_call_starargs_310.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def f ( * args , ** kwargs ) : <EOL>
<INDENT>
pass <EOL>
<OUTDENT>
( 1 , 2 ) ( ** { } ) <EOL>
2 changes: 2 additions & 0 deletions tests/tokenized/test_dict_merge_310.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d1 = { 'a' : 1 } <EOL>
d2 = { } <EOL>
2 changes: 2 additions & 0 deletions tests/tokenized/test_unpack_ex_310.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
seq = [ 1 , 2 , 3 , 4 , 5 ] <EOL>
( a , b , c ) = seq <EOL>