Skip to content

Commit

Permalink
do not use a nested class for Backtrace::Frame (take 2)
Browse files Browse the repository at this point in the history
mostly so that .WHAT gives the full name

Now without infinite recursion in the backtrace printer
(contains a workaround for RT #114034)
  • Loading branch information
moritz committed Jul 9, 2012
1 parent 9315e50 commit d8e7b66
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/core/Backtrace.pm
@@ -1,28 +1,30 @@
my class Exception { ... } my class Exception { ... }


my class Backtrace { ... }


my class Backtrace is List { my class Backtrace::Frame {
class Frame { has Str $.file;
has Str $.file; has Int $.line;
has Int $.line; has Mu $.code;
has Mu $.code; has Str $.subname;
has Str $.subname;

method subtype(Frame:D:) {
my $s = $!code.^name.lc.split('+', 2)[0];
$s eq 'mu' ?? '' !! $s;
}


multi method Str(Backtrace::Frame:D:) { method subtype(Backtrace::Frame:D:) {
my $s = self.subtype; my $s = $!code.^name.lc.split('+', 2)[0];
$s ~= ' ' if $s.chars; $s eq 'mu' ?? '' !! $s;
" in {$s}$.subname at {$.file}:$.line\n" }
}


method is-hidden(Frame:D:) { $!code.?is_hidden_from_backtrace } multi method Str(Backtrace::Frame:D:) {
method is-routine(Frame:D:) { $!code ~~ Routine } my $s = self.subtype;
method is-setting(Frame:D:) { $!file eq 'src/gen/CORE.setting' } $s ~= ' ' if $s.chars;
" in {$s}$.subname at {$.file}:$.line\n"
} }

method is-hidden(Backtrace::Frame:D:) { $!code.?is_hidden_from_backtrace }
method is-routine(Backtrace::Frame:D:) { $!code ~~ Routine }
method is-setting(Backtrace::Frame:D:) { $!file eq 'src/gen/CORE.setting' }
}

my class Backtrace is List {
proto method new(|$) {*} proto method new(|$) {*}


multi method new(Exception $e, Int $offset = 0) { multi method new(Exception $e, Int $offset = 0) {
Expand Down

0 comments on commit d8e7b66

Please sign in to comment.