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

Method to_base

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

Map an INSTRUMENTED_* opcode back to its base variant. Returns `None` for non-instrumented opcodes, and also for `InstrumentedLine` / `InstrumentedInstruction` which are event-layer placeholders without a fixed base opcode (the real opcode is stored in `CoMonitoringData`). The returned base opcode uses `Arg::marker()` for typed fields — only the opcode byte matters since `replace_op` preserves th

(self)

Source from the content-addressed store, hash-verified

510 /// The returned base opcode uses `Arg::marker()` for typed fields —
511 /// only the opcode byte matters since `replace_op` preserves the arg byte.
512 pub const fn to_base(self) -> Option<Self> {
513 Some(match self {
514 Self::InstrumentedResume => Self::Resume {
515 context: Arg::marker(),
516 },
517 Self::InstrumentedReturnValue => Self::ReturnValue,
518 Self::InstrumentedYieldValue => Self::YieldValue { arg: Arg::marker() },
519 Self::InstrumentedCall => Self::Call {
520 argc: Arg::marker(),
521 },
522 Self::InstrumentedCallKw => Self::CallKw {
523 argc: Arg::marker(),
524 },
525 Self::InstrumentedCallFunctionEx => Self::CallFunctionEx,
526 Self::InstrumentedLoadSuperAttr => Self::LoadSuperAttr {
527 namei: Arg::marker(),
528 },
529 Self::InstrumentedJumpForward => Self::JumpForward {
530 delta: Arg::marker(),
531 },
532 Self::InstrumentedJumpBackward => Self::JumpBackward {
533 delta: Arg::marker(),
534 },
535 Self::InstrumentedForIter => Self::ForIter {
536 delta: Arg::marker(),
537 },
538 Self::InstrumentedEndFor => Self::EndFor,
539 Self::InstrumentedEndSend => Self::EndSend,
540 Self::InstrumentedPopJumpIfTrue => Self::PopJumpIfTrue {
541 delta: Arg::marker(),
542 },
543 Self::InstrumentedPopJumpIfFalse => Self::PopJumpIfFalse {
544 delta: Arg::marker(),
545 },
546 Self::InstrumentedPopJumpIfNone => Self::PopJumpIfNone {
547 delta: Arg::marker(),
548 },
549 Self::InstrumentedPopJumpIfNotNone => Self::PopJumpIfNotNone {
550 delta: Arg::marker(),
551 },
552 Self::InstrumentedNotTaken => Self::NotTaken,
553 Self::InstrumentedPopIter => Self::PopIter,
554 Self::InstrumentedEndAsyncFor => Self::EndAsyncFor,
555 _ => return None,
556 })
557 }
558
559 /// Map a specialized opcode back to its adaptive (base) variant.
560 /// `_PyOpcode_Deopt`

Callers 3

is_instrumentedMethod · 0.45
deoptimizeMethod · 0.45
cache_entriesMethod · 0.45

Calls 1

SomeClass · 0.50

Tested by

no test coverage detected