mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
GH-122155: Track local variables between pops and pushes in cases generator (GH-122286)
This commit is contained in:
parent
46f5a4f9e1
commit
a9d56e38a0
13 changed files with 463 additions and 159 deletions
|
@ -8,7 +8,7 @@ from analyzer import (
|
|||
StackItem,
|
||||
)
|
||||
from cwriter import CWriter
|
||||
from typing import Callable, Mapping, TextIO, Iterator, Tuple
|
||||
from typing import Callable, Mapping, TextIO, Iterator
|
||||
from lexer import Token
|
||||
from stack import Stack
|
||||
|
||||
|
@ -25,7 +25,7 @@ def root_relative_path(filename: str) -> str:
|
|||
return filename
|
||||
|
||||
|
||||
def type_and_null(var: StackItem) -> Tuple[str, str]:
|
||||
def type_and_null(var: StackItem) -> tuple[str, str]:
|
||||
if var.type:
|
||||
return var.type, "NULL"
|
||||
elif var.is_array():
|
||||
|
@ -95,16 +95,23 @@ def replace_error(
|
|||
c_offset = stack.peek_offset()
|
||||
try:
|
||||
offset = -int(c_offset)
|
||||
close = ";\n"
|
||||
except ValueError:
|
||||
offset = None
|
||||
out.emit(f"{{ stack_pointer += {c_offset}; ")
|
||||
close = "; }\n"
|
||||
out.emit("goto ")
|
||||
if offset:
|
||||
out.emit(f"pop_{offset}_")
|
||||
out.emit(label)
|
||||
out.emit(close)
|
||||
offset = -1
|
||||
if offset > 0:
|
||||
out.emit(f"goto pop_{offset}_")
|
||||
out.emit(label)
|
||||
out.emit(";\n")
|
||||
elif offset == 0:
|
||||
out.emit("goto ")
|
||||
out.emit(label)
|
||||
out.emit(";\n")
|
||||
else:
|
||||
out.emit("{\n")
|
||||
stack.flush_locally(out)
|
||||
out.emit("goto ")
|
||||
out.emit(label)
|
||||
out.emit(";\n")
|
||||
out.emit("}\n")
|
||||
|
||||
|
||||
def replace_error_no_pop(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue