File: interp_backtrace_enhancer.raku

package info (click to toggle)
moarvm 2024.09%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 43,548 kB
  • sloc: cpp: 378,682; ansic: 293,618; perl: 8,274; java: 2,682; python: 1,296; makefile: 816; sh: 292
file content (26 lines) | stat: -rwxr-xr-x 646 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env perl6

my $interp_c_file = $*PROGRAM-NAME.IO.parent.parent.child('src').child('core').child('interp.c');

my $cur_op = 'before_dispatch';

my %lines_to_op;

for $interp_c_file.lines.kv -> $lineno, $line {
    if $line ~~ / ^ \s* 'OP(' $<opname>=<[a..z A..Z \- \_ 0..9]>+ '):' / {
        $cur_op = $<opname>;
    }

    elsif $line ~~ / ^ \s* 'default:' / {
        $cur_op ~= "_or_after_dispatch";
    }

    %lines_to_op{$lineno} = $cur_op;
}

for lines() -> $_ is copy {
    $_ .= subst(rx/'interp.c:' $<lineno>=<[0..9]>+ /,
            -> $/ { "interp.c:{$<lineno>} ({%lines_to_op{$<lineno>}})" },
            :g);
    .say;
}