Skip to content

Commit 09eb1e7

Browse files
Yhg1sfacebook-github-bot
authored andcommitted
Make cinderx compiler pass type checking again.
Summary: Make cinderx compiler pass type checking again. Reviewed By: DinoV Differential Revision: D81921481 fbshipit-source-id: 5c89bd0bc1eb13e0ca921e8ef89c36a469b26b32
1 parent a2a9bac commit 09eb1e7

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

cinderx/PythonLib/cinderx/compiler/flow_graph_optimizer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ def clean_basic_block(self, block: Block, prev_lineno: int) -> None:
132132
prev_lineno = instr.lineno
133133
block.insts = new_instrs
134134

135-
def jump_thread(self, instr: Instruction, target: Instruction, opname: str) -> int:
135+
def jump_thread(
136+
self, block: Block, instr: Instruction, target: Instruction, opname: str
137+
) -> int:
138+
raise NotImplementedError()
139+
140+
def get_const_loading_instrs(
141+
self, block: Block, start: int, size: int
142+
) -> list[Instruction] | None:
136143
raise NotImplementedError()
137144

138145
def opt_jump_if_false_or_pop(
@@ -985,6 +992,7 @@ def optimize_contains_is_op(
985992

986993
def make_load_const(self, instr: Instruction, const: object) -> None:
987994
if is_small_int(const):
995+
assert isinstance(const, int)
988996
instr.opname = "LOAD_SMALL_INT"
989997
instr.ioparg = instr.oparg = const
990998
else:

cinderx/PythonLib/cinderx/compiler/pyassem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,6 +2445,7 @@ def should_inline_block(self, block: Block) -> bool:
24452445

24462446
# We can only inline blocks with no line numbers.
24472447
for inst in block.insts:
2448+
# pyre-fixme[16]: Item `AST` of `AST | SrcLocation` has no attribute `lineno`.
24482449
if inst.loc.lineno >= 0:
24492450
return False
24502451
return True

cinderx/PythonLib/cinderx/compiler/pycodegen.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6019,6 +6019,7 @@ def make_with_block(self) -> Block | None:
60196019
def get_graph_flags(
60206020
self, func: FuncOrLambda | CompNode, func_args: ast.arguments, scope: Scope
60216021
) -> int:
6022+
assert isinstance(scope, FunctionScope)
60226023
flags = super().get_graph_flags(func, func_args, scope)
60236024

60246025
if scope.has_docstring:
@@ -6587,6 +6588,7 @@ def visitAttribute(self, node: ast.Attribute) -> None:
65876588
super().visitAttribute(node)
65886589

65896590
def compile_body(self, gen: CodeGenerator, node: ast.ClassDef) -> None:
6591+
assert isinstance(gen, CodeGenerator314)
65906592
if gen.findAnn(node.body):
65916593
gen.did_setup_annotations = True
65926594
gen.emit("SETUP_ANNOTATIONS")

0 commit comments

Comments
 (0)