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

Method error_if

Tools/cases_generator/generators_common.py:236–269  ·  view source on GitHub ↗
(
        self,
        tkn: Token,
        tkn_iter: TokenIterator,
        uop: CodeSection,
        storage: Storage,
        inst: Instruction | None,
    )

Source from the content-addressed store, hash-verified

234 return f"{self.jump_prefix}JUMP_TO_LABEL(error);"
235
236 def error_if(
237 self,
238 tkn: Token,
239 tkn_iter: TokenIterator,
240 uop: CodeSection,
241 storage: Storage,
242 inst: Instruction | None,
243 ) -> bool:
244 lparen = next(tkn_iter)
245 assert lparen.kind == "LPAREN"
246 first_tkn = tkn_iter.peek()
247 unconditional = always_true(first_tkn)
248 if unconditional:
249 next(tkn_iter)
250 next(tkn_iter) # RPAREN
251 self.out.start_line()
252 else:
253 self.out.emit_at("if ", tkn)
254 self.emit(lparen)
255 emit_to(self.out, tkn_iter, "RPAREN")
256 self.out.emit(") {\n")
257 next(tkn_iter) # Semi colon
258 storage.clear_inputs("at ERROR_IF")
259
260 c_offset = storage.stack.sp_offset()
261 try:
262 offset = int(c_offset)
263 except ValueError:
264 offset = -1
265 self.out.emit(self.goto_error(offset, storage))
266 self.out.emit("\n")
267 if not unconditional:
268 self.out.emit("}\n")
269 return not unconditional
270
271 def tier1_to_tier2(
272 self,

Callers

nothing calls this directly

Calls 9

emitMethod · 0.95
goto_errorMethod · 0.95
always_trueFunction · 0.85
emit_toFunction · 0.85
start_lineMethod · 0.80
emit_atMethod · 0.80
clear_inputsMethod · 0.80
sp_offsetMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected