MCPcopy Index your code
hub / github.com/RustPython/RustPython / emit_format_validation

Method emit_format_validation

crates/codegen/src/compile.rs:1415–1457  ·  view source on GitHub ↗

Emit format parameter validation for annotation scope if format > VALUE_WITH_FAKE_GLOBALS (2): raise NotImplementedError

(&mut self)

Source from the content-addressed store, hash-verified

1413 /// Emit format parameter validation for annotation scope
1414 /// if format > VALUE_WITH_FAKE_GLOBALS (2): raise NotImplementedError
1415 fn emit_format_validation(&mut self) -> CompileResult<()> {
1416 // Load format parameter (first local variable, index 0)
1417 emit!(
1418 self,
1419 Instruction::LoadFast {
1420 var_num: oparg::VarNum::from_u32(0)
1421 }
1422 );
1423
1424 // Load VALUE_WITH_FAKE_GLOBALS constant (2)
1425 self.emit_load_const(ConstantData::Integer { value: 2.into() });
1426
1427 // Compare: format > 2
1428 emit!(
1429 self,
1430 Instruction::CompareOp {
1431 opname: ComparisonOperator::Greater
1432 }
1433 );
1434
1435 // Jump to body if format <= 2 (comparison is false)
1436 let body_block = self.new_block();
1437 emit!(self, Instruction::PopJumpIfFalse { delta: body_block });
1438
1439 // Raise NotImplementedError
1440 emit!(
1441 self,
1442 Instruction::LoadCommonConstant {
1443 idx: bytecode::CommonConstant::NotImplementedError
1444 }
1445 );
1446 emit!(
1447 self,
1448 Instruction::RaiseVarargs {
1449 argc: bytecode::RaiseKind::Raise
1450 }
1451 );
1452
1453 // Body label - continue with annotation evaluation
1454 self.switch_to_block(body_block);
1455
1456 Ok(())
1457 }
1458
1459 /// Push a new fblock
1460 // = compiler_push_fblock

Callers 4

compile_statementMethod · 0.80

Calls 3

emit_load_constMethod · 0.80
new_blockMethod · 0.80
switch_to_blockMethod · 0.80

Tested by

no test coverage detected