MCPcopy Index your code
hub / github.com/python/cpython / stmt_has_jump_on_unpredictable_path

Function stmt_has_jump_on_unpredictable_path

Tools/cases_generator/analyzer.py:921–948  ·  view source on GitHub ↗
(stmt: Stmt, branches_seen: int)

Source from the content-addressed store, hash-verified

919 return predict, seen
920
921def stmt_has_jump_on_unpredictable_path(stmt: Stmt, branches_seen: int) -> tuple[bool, int]:
922 if isinstance(stmt, BlockStmt):
923 return stmt_has_jump_on_unpredictable_path_body(stmt.body, branches_seen)
924 elif isinstance(stmt, SimpleStmt):
925 for tkn in stmt.contents:
926 if tkn.text == "JUMPBY":
927 return True, branches_seen
928 return False, branches_seen
929 elif isinstance(stmt, IfStmt):
930 predict, seen = stmt_has_jump_on_unpredictable_path(stmt.body, branches_seen)
931 if stmt.else_body:
932 predict_else, seen_else = stmt_has_jump_on_unpredictable_path(stmt.else_body, branches_seen)
933 return predict != predict_else, seen + seen_else + 1
934 return predict, seen + 1
935 elif isinstance(stmt, MacroIfStmt):
936 predict, seen = stmt_has_jump_on_unpredictable_path_body(stmt.body, branches_seen)
937 if stmt.else_body:
938 predict_else, seen_else = stmt_has_jump_on_unpredictable_path_body(stmt.else_body, branches_seen)
939 return predict != predict_else, seen + seen_else
940 return predict, seen
941 elif isinstance(stmt, ForStmt):
942 unpredictable, branches_seen = stmt_has_jump_on_unpredictable_path(stmt.body, branches_seen)
943 return unpredictable, branches_seen + 1
944 elif isinstance(stmt, WhileStmt):
945 unpredictable, branches_seen = stmt_has_jump_on_unpredictable_path(stmt.body, branches_seen)
946 return unpredictable, branches_seen + 1
947 else:
948 assert False, f"Unexpected statement type {stmt}"
949
950
951def compute_properties(op: parser.CodeDef) -> Properties:

Callers 2

compute_propertiesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…