Documentation for method code assembled from the following pages:

Class: CallFrame §

From CallFrame

(CallFrame) method code §

method code()

Return the callable code for the current block. When called on the object returned by callframe(0), this will be the same value found in &?BLOCK.

my $frame;
for ^3 { FIRST $frame = callframesay $_ * 3 };
say $frame.code()

The $frame variable will hold the Code for the block inside the loop in this case.

Class: Backtrace::Frame §

From Backtrace::Frame

(Backtrace::Frame) method code §

Defined as:

method code(Backtrace::Frame:D)

Returns the code object into which .file and .line point, if available.

my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.code;