-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-93691: Compiler's code-gen passes location around instead of holding it on the global compiler state #98001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ecfa12e
082625c
c50ff36
091266f
8fd667d
c7764ce
498e98b
f8d061b
0df1e0c
e09f741
80393a3
8e7acf6
5418bb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1652,10 +1652,6 @@ cfg_builder_addop_j(cfg_builder *g, struct location loc, | |
| #define ADDOP_INPLACE(C, LOC, BINOP) \ | ||
| RETURN_IF_FALSE(addop_binary((C), (LOC), (BINOP), true)) | ||
|
|
||
| /* VISIT and VISIT_SEQ takes an ASDL type as their second argument. They use | ||
| the ASDL name to synthesize the name of the C type and the visit function. | ||
| */ | ||
|
|
||
| #define ADD_YIELD_FROM(C, LOC, await) \ | ||
| RETURN_IF_FALSE(compiler_add_yield_from((C), (LOC), (await))) | ||
|
|
||
|
|
@@ -1665,6 +1661,10 @@ cfg_builder_addop_j(cfg_builder *g, struct location loc, | |
| #define ADDOP_YIELD(C, LOC) \ | ||
| RETURN_IF_FALSE(addop_yield((C), (LOC))) | ||
|
|
||
| /* VISIT and VISIT_SEQ takes an ASDL type as their second argument. They use | ||
| the ASDL name to synthesize the name of the C type and the visit function. | ||
| */ | ||
|
|
||
| #define VISIT(C, TYPE, V) {\ | ||
| if (!compiler_visit_ ## TYPE((C), (V))) \ | ||
| return 0; \ | ||
|
|
@@ -3307,6 +3307,18 @@ compiler_continue(struct compiler *c, struct location loc) | |
| } | ||
|
|
||
|
|
||
| static struct location | ||
| last_location_in_body(asdl_stmt_seq *stmts) | ||
| { | ||
| for (int i = asdl_seq_LEN(stmts) - 1; i >= 0; i++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WIndows warning. Use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this? There are a few other for loops with int variable in this file, I don't know if they need to change too. |
||
| struct location loc = LOC((stmt_ty)asdl_seq_GET(stmts, i)); | ||
| if (loc.lineno > 0) { | ||
| return loc; | ||
| } | ||
| } | ||
| return NO_LOCATION; | ||
| } | ||
|
|
||
| /* Code generated for "try: <body> finally: <finalbody>" is as follows: | ||
|
|
||
| SETUP_FINALLY L | ||
|
|
@@ -3362,6 +3374,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s) | |
| ADDOP(c, NO_LOCATION, POP_BLOCK); | ||
| compiler_pop_fblock(c, FINALLY_TRY, body); | ||
| VISIT_SEQ(c, stmt, s->v.Try.finalbody); | ||
|
|
||
| ADDOP_JUMP(c, NO_LOCATION, JUMP, exit); | ||
| /* `finally` block */ | ||
|
|
||
|
|
@@ -3374,6 +3387,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s) | |
| if (!compiler_push_fblock(c, loc, FINALLY_END, end, NO_LABEL, NULL)) | ||
| return 0; | ||
| VISIT_SEQ(c, stmt, s->v.Try.finalbody); | ||
| loc = last_location_in_body(s->v.Try.finalbody); | ||
| compiler_pop_fblock(c, FINALLY_END, end); | ||
|
|
||
| ADDOP_I(c, loc, RERAISE, 0); // CHANGED | ||
|
iritkatriel marked this conversation as resolved.
Outdated
|
||
|
|
@@ -3412,6 +3426,7 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s) | |
| ADDOP(c, NO_LOCATION, POP_BLOCK); | ||
| compiler_pop_fblock(c, FINALLY_TRY, body); | ||
| VISIT_SEQ(c, stmt, s->v.TryStar.finalbody); | ||
|
|
||
| ADDOP_JUMP(c, NO_LOCATION, JUMP, exit); | ||
|
|
||
| /* `finally` block */ | ||
|
|
@@ -3425,6 +3440,8 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s) | |
| return 0; | ||
| } | ||
| VISIT_SEQ(c, stmt, s->v.TryStar.finalbody); | ||
| loc = last_location_in_body(s->v.Try.finalbody); | ||
|
|
||
| compiler_pop_fblock(c, FINALLY_END, end); | ||
| ADDOP_I(c, loc, RERAISE, 0); // CHANGED | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.