Mercurial > hg > Others > Rakudo
annotate src/core.c/Backtrace.pm6 @ 0:c341f82e7ad7 default tip
Rakudo branch in cr.ie.u-ryukyu.ac.jp
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 26 Dec 2019 16:50:27 +0900 |
parents | |
children |
rev | line source |
---|---|
0
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 my class Exception { ... } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 my class Backtrace { ... } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 my class CompUnit::RepositoryRegistry is repr('Uninstantiable') { ... } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 my class Backtrace::Frame { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 has Str $.file; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 has Int $.line; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 has Mu $.code; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 has Str $.subname; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 method !SET-SELF($!file,$!line,\code,$!subname) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 $!code := code; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 self |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 multi method new(Backtrace::Frame: \file,\line,\code,\subname) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 nqp::create(self)!SET-SELF(file,line,code,subname) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 multi method new(Backtrace::Frame: |c) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 self.bless(|c) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 method subtype(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 my $s = $!code.^name.lc.split('+', 2).cache[0]; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 $s eq 'mu' ?? '' !! $s; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 method package(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 $.code.package; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 multi method Str(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 my $s = self.subtype; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 $s ~= ' ' if $s.chars; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 my $text = " in {$s}$.subname at {$.file} line $.line\n"; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 if Backtrace.RAKUDO_VERBOSE_STACKFRAME -> $extra { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 my $io = $!file.IO; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 if $io.e { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 my @lines = $io.lines; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 my $from = max $!line - $extra, 1; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 my $to = min $!line + $extra, +@lines; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 for $from..$to -> $line { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 my $star = $line == $!line ?? '*' !! ' '; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 $text ~= "$line.fmt('%5d')$star @lines[$line - 1]\n"; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 $text ~= "\n"; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 $text; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 method is-hidden(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 nqp::if( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 nqp::can($!code,"is-hidden-from-backtrace"), |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 $!code.is-hidden-from-backtrace, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 False |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 ) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 method is-routine(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 nqp::hllbool(nqp::istype($!code,Routine)) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 method is-setting(Backtrace::Frame:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 $!file.starts-with("SETTING::") |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 #?if jvm |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 || $!file ~~ / "CORE." \w+ ".setting" $ / |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 #?endif |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 #?if !jvm |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 || $!file ~~ / "CORE." \w+ ".setting.{ Rakudo::Internals.PRECOMP-EXT }" $ / |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 #?endif |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 || $!file.ends-with(".nqp") |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 my class Backtrace { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 has Mu $!bt; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 has Mu $!frames; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 has Int $!bt-next; # next bt index to vivify |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 my $RAKUDO_VERBOSE_STACKFRAME := nqp::null; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 method RAKUDO_VERBOSE_STACKFRAME() { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 nqp::ifnull( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 $RAKUDO_VERBOSE_STACKFRAME, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 $RAKUDO_VERBOSE_STACKFRAME := |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 (%*ENV<RAKUDO_VERBOSE_STACKFRAME> // 0).Int |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 ) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 method !SET-SELF($!bt,$!bt-next) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 $!frames := nqp::list; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 self |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 multi method new() { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 try X::AdHoc.new(:payload("Died")).throw; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 nqp::create(self)!SET-SELF( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 nqp::backtrace(nqp::getattr(nqp::decont($!),Exception,'$!ex')), |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 1) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 multi method new(Int:D $offset) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 try X::AdHoc.new(:payload("Died")).throw; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 nqp::create(self)!SET-SELF( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 nqp::backtrace(nqp::getattr(nqp::decont($!),Exception,'$!ex')), |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 1 + $offset) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 multi method new(Mu \ex) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 nqp::create(self)!SET-SELF( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 ex.^name eq 'BOOTException' |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 ?? nqp::backtrace(nqp::decont(ex)) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 !! nqp::backtrace(nqp::getattr(nqp::decont(ex),Exception,'$!ex')), |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 0) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 multi method new(Mu \ex, Int:D $offset) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 nqp::create(self)!SET-SELF( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 ex.^name eq 'BOOTException' |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 ?? nqp::backtrace(nqp::decont(ex)) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 !! nqp::backtrace(nqp::getattr(nqp::decont(ex),Exception,'$!ex')), |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 $offset) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 # note that backtraces are nqp::list()s, marshalled to us as a List |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 multi method new(List:D $bt) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 nqp::create(self)!SET-SELF($bt,0) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 multi method new(List:D $bt, Int:D $offset) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 nqp::create(self)!SET-SELF($bt,$offset) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 method AT-POS($pos) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 return nqp::atpos($!frames,$pos) if nqp::existspos($!frames,$pos); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 my int $elems = $!bt.elems; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 return Nil if $!bt-next >= $elems; # bt-next can init > elems |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 my int $todo = $pos - nqp::elems($!frames) + 1; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 return Nil if $todo < 1; # in case absurd $pos passed |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 while $!bt-next < $elems { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 my $frame := $!bt.AT-POS($!bt-next++); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 my $sub := $frame<sub>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 next unless defined $sub; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 my Mu $do := nqp::getattr(nqp::decont($sub), ForeignCode, '$!do'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 next if nqp::isnull($do); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 my $annotations := $frame<annotations>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 next unless $annotations; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 my $file := $annotations<file>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 next unless $file; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 if CompUnit::RepositoryRegistry.file-for-spec($file) -> $path { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 $file := $path.absolute; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 next if $file.ends-with('BOOTSTRAP.nqp') |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 || $file.ends-with('QRegex.nqp') |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 || $file.ends-with('Perl6/Ops.nqp'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 if $file.ends-with('NQPHLL.nqp') || $file.ends-with('NQPHLL.moarvm') { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 # This could mean we're at the end of the interesting backtrace, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 # or it could mean that we're in something like sprintf (which |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 # uses an NQP grammar to parse the format string). |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 while $!bt-next < $elems { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 my $frame := $!bt.AT-POS($!bt-next++); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 my $annotations := $frame<annotations>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 next unless $annotations; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 my $file := $annotations<file>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 next unless $file; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 if $file.starts-with('SETTING::') { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 $!bt-next--; # re-visit this frame |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 last; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 next; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 my $line := $annotations<line>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 next unless $line; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 my $name := nqp::p6box_s(nqp::getcodename($do)); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 if $name eq 'handle-begin-time-exceptions' { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 $!bt-next = $elems; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 last; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 my $code; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 try { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 $code := nqp::getcodeobj($do); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 $code := Any unless nqp::istype($code, Mu); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 }; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 nqp::push($!frames, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 Backtrace::Frame.new( |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 $file, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 $line.Int, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 $code, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 $name.starts-with("_block") ?? '<anon>' !! $name, |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 ) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 ); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 last unless $todo = $todo - 1; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 # found something |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 if nqp::existspos($!frames,$pos) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 nqp::atpos($!frames,$pos); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 # we've reached the end, don't show the last <unit-outer> if there is one |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 else { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 nqp::pop($!frames) if $!frames; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 Nil; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 method next-interesting-index(Backtrace:D: |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 Int $idx is copy = 0, :$named, :$noproto, :$setting) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 ++$idx; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 while self.AT-POS($idx++) -> $cand { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 next if $cand.is-hidden; # hidden is never interesting |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 next if $noproto # no proto's please |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 && nqp::can($cand,"is_dispatcher") |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 && $cand.code.is_dispatcher; # if a dispatcher |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 next if !$setting # no settings please |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 && $cand.is-setting; # and in setting |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 my $n := $cand.subname; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 next if $named && !$n; # only want named ones and no name |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 next if $n eq '<unit-outer>'; # outer calling context |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 return $idx - 1; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 Nil; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 method outer-caller-idx(Backtrace:D: Int $startidx) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 if self.AT-POS($startidx).code -> $start { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 my %outers; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 my $current = $start.outer; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 while $current.DEFINITE { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 %outers{$current.static_id} = $start; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 $current = $current.outer; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 my @outers; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 my $i = $startidx; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 while self.AT-POS($i++) -> $cand { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 my $code = $cand.code; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248 next unless $code.DEFINITE && %outers{$code.static_id}.DEFINITE; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 @outers.push: $i - 1; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 last if $cand.is-routine; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 @outers; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 else { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257 $startidx.list; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
258 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
261 method nice(Backtrace:D: :$oneline) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262 my $setting = %*ENV<RAKUDO_BACKTRACE_SETTING>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 try { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 my @frames; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265 my Int $i = self.next-interesting-index(-1); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 while $i.defined { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
267 $i = self.next-interesting-index($i, :$setting) if $oneline; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 last unless $i.defined; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
269 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 my $prev = self.AT-POS($i); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 if $prev.is-routine { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 @frames.push: $prev; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 } else { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274 my @outer_callers := self.outer-caller-idx($i); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 my $target_idx = @outer_callers.keys.grep({self.AT-POS($i).code.^isa(Routine)})[0]; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 $target_idx ||= @outer_callers[0] || $i; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 my $current = self.AT-POS($target_idx); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 @frames.append: $current.clone(line => $prev.line); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 $i = $target_idx; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 last if $oneline; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 $i = self.next-interesting-index($i, :$setting); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
283 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284 CATCH { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 default { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 return "<Internal error while creating backtrace: $_.message() $_.backtrace.full().\n" |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 ~ "Please report this as a bug (mail to rakudobug@perl.org)\n", |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288 ~ "and re-run with the --ll-exception command line option\n" |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 ~ "to get more information about your error>"; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292 @frames.join; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 multi method gist(Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 my $els := +self.list; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 'Backtrace(' ~ $els ~ ' frame' ~ 's' x ($els != 1) ~ ')' |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300 multi method Str(Backtrace:D:) { self.nice } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 multi method flat(Backtrace:D:) { self.list } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 multi method map(Backtrace:D: &block) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 my $pos = 0; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 gather while self.AT-POS($pos++) -> $cand { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 take block($cand); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
308 multi method first(Backtrace:D: Mu $test) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
309 my $pos = 0; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
310 while self.AT-POS($pos++) -> $cand { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
311 return-rw $cand if $cand ~~ $test; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
312 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313 Nil; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
314 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 multi method list(Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 self.AT-POS(1_000_000); # will stop when no more frames to be found |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
317 nqp::p6bindattrinvres(nqp::create(List), List, '$!reified', $!frames) |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
318 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
319 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
320 method first-none-setting-line(Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
321 (self.first({ !.is-hidden && !.is-setting }) // "\n").Str; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
322 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
323 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
324 method concise(Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
325 (self.grep({ !.is-hidden && .is-routine && !.is-setting }) // "\n").join; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
326 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
327 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
328 method full(Backtrace:D:) { self.list.join } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
329 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
330 method summary(Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
331 (self.grep({ !.is-hidden && (.is-routine || !.is-setting)}) // "\n").join; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
332 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
333 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
334 method is-runtime (Backtrace:D:) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
335 my $bt = $!bt; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
336 for $bt.keys { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
337 my $p6sub := $bt[$_]<sub>; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
338 if nqp::istype($p6sub, ForeignCode) { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
339 try { |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
340 my Mu $sub := nqp::getattr(nqp::decont($p6sub), ForeignCode, '$!do'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 my str $name = nqp::getcodename($sub); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342 return True if nqp::iseq_s($name, 'THREAD-ENTRY'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
343 return True if nqp::iseq_s($name, 'eval'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
344 return True if nqp::iseq_s($name, 'print_control'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
345 return False if nqp::iseq_s($name, 'compile'); |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
347 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
348 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
349 False; |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
350 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
351 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
352 } |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
353 |
c341f82e7ad7
Rakudo branch in cr.ie.u-ryukyu.ac.jp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 # vim: ft=perl6 expandtab sw=4 |