Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change BackTrace handling a bit: collect all the information, and onl…
…y filter on strintification
  • Loading branch information
moritz committed Jul 7, 2011
1 parent 1dc9308 commit 32ab8d4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/BackTrace.pm
@@ -1,15 +1,16 @@
my $*VERBOSE_BACKTRACE = False;
class BackTraceLine {
has Str $.file;
has Int $.line;
has Mu $.code;
has Str $.subname;
has $.subtype;

method subtype { $!code.WHAT.perl.lc }

multi method Str(BackTraceLine:D:) {
my $s = $.subname // '<anon>';
my $what = lc $.subtype.perl;
" in $what $s at {$.file}:$.line"
" in $.subtype $.subname at {$.file}:$.line"
}

method is-routine { $!code ~~ Routine }
}

class BackTrace is List {
Expand All @@ -20,8 +21,6 @@ class BackTrace is List {
next if pir::isnull($bt[$_]<sub>);
my Mu $p6sub =
pir::perl6_code_object_from_parrot_sub__PP($bt[$_]<sub>);
next if !$*VERBOSE_BACKTRACE && !$p6sub.defined;
next if !$*VERBOSE_BACKTRACE && !$p6sub ~~ Routine;
my $line = $bt[$_]<annotations><line>;
my $file = $bt[$_]<annotations><file>;
my $subname = nqp::p6box_s($bt[$_]<sub>);
Expand All @@ -30,12 +29,16 @@ class BackTrace is List {
:$line,
:$file,
:$subname,
:subtype($p6sub.WHAT),
:code($p6sub),
);
}
$new;
}

method concise() {
self.grep({ .is-routine }).join("\n") ~ "\n"
}

multi method Str(BackTrace:D:) {
self.join("\n") ~ "\n"
}
Expand Down

0 comments on commit 32ab8d4

Please sign in to comment.