Skip to content

Commit

Permalink
change names of backtrace classes to match spec
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Aug 28, 2011
1 parent 0adc742 commit 1848338
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
41 changes: 23 additions & 18 deletions src/core/BackTrace.pm → src/core/Backtrace.pm
@@ -1,23 +1,28 @@
my class Exception { ... }

my class BackTraceLine {
has Str $.file;
has Int $.line;
has Mu $.code;
has Str $.subname;

method subtype { $!code.WHAT.perl.lc }
my class Backtrace is List {
class Frame {
has Str $.file;
has Int $.line;
has Mu $.code;
has Str $.subname;

multi method Str(BackTraceLine:D:) {
" in $.subtype $.subname at {$.file}:$.line\n"
}
method subtype {
my $s = $!code.WHAT.perl.lc;
$s eq 'mu' ?? '' !! $s;
}

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

my class BackTrace is List {
method is-hidden { $!code.?is_hidden_from_backtrace }
method is-routine { $!code ~~ Routine }
method is-setting { $!file eq 'src/gen/CORE.setting' }
}
proto method new(|$) {*}

multi method new(Exception $e, Int $offset = 0) {
Expand All @@ -39,7 +44,7 @@ my class BackTrace is List {
last if $file eq 'src/stage2/gen/NQPHLL.pm';
my $subname = nqp::p6box_s($bt[$_]<sub>);
$subname = '<anon>' if $subname.substr(0, 6) eq '_block';
$new.push: BackTraceLine.new(
$new.push: Backtrace::Frame.new(
:$line,
:$file,
:$subname,
Expand All @@ -49,15 +54,15 @@ my class BackTrace is List {
$new;
}

method concise(BackTrace:D:) {
method concise(Backtrace:D:) {
self.grep({ !.is-hidden && .is-routine && !.is-setting }).join
}

multi method Str(BackTrace:D:) {
multi method Str(Backtrace:D:) {
self.grep({ !.is-hidden && (.is-routine || !.is-setting )}).join
}

method full(BackTrace:D:) {
method full(Backtrace:D:) {
self.join
}
}
2 changes: 1 addition & 1 deletion src/core/Exception.pm
Expand Up @@ -50,7 +50,7 @@ do {
if is_runtime($ex.backtrace) {
my $e := EXCEPTION($ex);
say $e;
say BackTrace.new($e);
say Backtrace.new($e);
} else {
my Mu $err := pir::getstderr__P();
$err.print: "===SORRY!===\n";
Expand Down
2 changes: 1 addition & 1 deletion tools/build/Makefile.in
Expand Up @@ -188,7 +188,7 @@ CORE_SOURCES = \
src/core/IO/Socket/INET.pm \
src/core/Rat.pm \
src/core/Complex.pm \
src/core/BackTrace.pm \
src/core/Backtrace.pm \
src/core/Exception.pm \
src/core/Failure.pm \
src/core/Exceptions.pm \
Expand Down

0 comments on commit 1848338

Please sign in to comment.