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

Method to_instrumented

crates/compiler-core/src/bytecode/instruction.rs:475–502  ·  view source on GitHub ↗

Map a base opcode to its INSTRUMENTED_* variant. Returns `None` if this opcode has no instrumented counterpart. # Panics (debug) Panics if called on an already-instrumented opcode.

(self)

Source from the content-addressed store, hash-verified

473 /// # Panics (debug)
474 /// Panics if called on an already-instrumented opcode.
475 pub fn to_instrumented(self) -> Option<Self> {
476 debug_assert!(
477 !self.is_instrumented(),
478 "to_instrumented called on already-instrumented opcode {self:?}"
479 );
480 Some(match self {
481 Self::Resume { .. } => Self::InstrumentedResume,
482 Self::ReturnValue => Self::InstrumentedReturnValue,
483 Self::YieldValue { .. } => Self::InstrumentedYieldValue,
484 Self::Call { .. } => Self::InstrumentedCall,
485 Self::CallKw { .. } => Self::InstrumentedCallKw,
486 Self::CallFunctionEx => Self::InstrumentedCallFunctionEx,
487 Self::LoadSuperAttr { .. } => Self::InstrumentedLoadSuperAttr,
488 Self::JumpForward { .. } => Self::InstrumentedJumpForward,
489 Self::JumpBackward { .. } => Self::InstrumentedJumpBackward,
490 Self::ForIter { .. } => Self::InstrumentedForIter,
491 Self::EndFor => Self::InstrumentedEndFor,
492 Self::EndSend => Self::InstrumentedEndSend,
493 Self::PopJumpIfTrue { .. } => Self::InstrumentedPopJumpIfTrue,
494 Self::PopJumpIfFalse { .. } => Self::InstrumentedPopJumpIfFalse,
495 Self::PopJumpIfNone { .. } => Self::InstrumentedPopJumpIfNone,
496 Self::PopJumpIfNotNone { .. } => Self::InstrumentedPopJumpIfNotNone,
497 Self::NotTaken => Self::InstrumentedNotTaken,
498 Self::PopIter => Self::InstrumentedPopIter,
499 Self::EndAsyncFor => Self::InstrumentedEndAsyncFor,
500 _ => return None,
501 })
502 }
503
504 /// Map an INSTRUMENTED_* opcode back to its base variant.
505 /// Returns `None` for non-instrumented opcodes, and also for

Callers 1

instrument_codeFunction · 0.80

Calls 1

SomeClass · 0.50

Tested by

no test coverage detected