| 1 | package Util::Underscore::CallStackFrame; | ||||||||||
| 2 | |||||||||||
| 3 | #ABSTRACT: object-oriented wrapper for "caller" builtin | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | ## no critic (RequireFinalReturn) | ||||||||||
| 11 | # reason: performance and terse code. | ||||||||||
| 12 | # All methods are supposed to return something. | ||||||||||
| 13 | |||||||||||
| 14 | ## no critic (ProhibitMagicNumbers) | ||||||||||
| 15 | # reason: the "caller" builtin is full of magic numbers. | ||||||||||
| 16 | # This class wraps them so that users don't have to deal with them. | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | sub of { | ||||||||||
| 20 | 46 | ▶ | my ($class, $level) = @_; | ||||||||
|
Subroutine
of: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | |||||||||||
| 22 | package DB; ## no critic (ProhibitMUltiplePackages) | ||||||||||
| 23 | 46 | my @caller = CORE::caller($level + 1); | |||||||||
| 24 | 46 | ▶ | return if not @caller; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 43 | push @caller, [@DB::args]; ## no critic (ProhibitPackageVars) | |||||||||
| 26 | 43 | return bless \@caller => $class; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | ## no critic (ProhibitBuiltinHomonyms) | ||||||||||
| 31 | 1 | ▶ | sub package { shift()->[0] } | ||||||||
|
Subroutine
package: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | sub file { shift()->[1] } | ||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 12 | ▶ | sub line { shift()->[2] } | ||||||||
|
Subroutine
line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | 21 | ▶ | sub subroutine { shift()->[3] } | ||||||||
|
Subroutine
subroutine: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | sub has_args { | ||||||||||
| 44 | 3 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
has_args: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | 3 | ▶ | $self->[4] && $self->[11]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 4 | ▶ | sub wantarray { shift()->[5] } | ||||||||
|
Subroutine
wantarray: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | sub is_eval { | ||||||||||
| 53 | 7 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
is_eval: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 7 | ▶ | if ($self->[3] eq '(eval)') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 6 | my $accessor_object = [ @{$self}[ 6, 7 ] ]; | |||||||||
| 56 | 6 | bless $accessor_object => 'Util::Underscore::CallStackFrame::_Eval'; | |||||||||
| 57 | 6 | return $accessor_object; | |||||||||
| 58 | } | ||||||||||
| 59 | else { | ||||||||||
| 60 | 1 | return !!0; | |||||||||
| 61 | } | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | { | ||||||||||
| 65 | ## no critic (ProhibitMUltiplePackages) | ||||||||||
| 66 | package Util::Underscore::CallStackFrame::_Eval; | ||||||||||
| 67 | |||||||||||
| 68 | 2 | ▶ | sub source { shift()->[0] } | ||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
| |||||||||||
| 69 | |||||||||||
| 70 | 2 | ▶ | sub is_require { shift()->[1] } | ||||||||
|
Subroutine
is_require: called CC=1 SCAR=0.0
| |||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | |||||||||||
| 74 | 2 | ▶ | sub is_require { shift()->[7] } | ||||||||
|
Subroutine
is_require: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub hints { shift()->[8] } | ||||||||
|
Subroutine
hints: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub bitmask { shift()->[9] } | ||||||||
|
Subroutine
bitmask: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | sub hinthash { shift()->[10] } | ||||||||
|
Subroutine
hinthash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 84 | |||||||||||
| 85 | 2 | 1; | |||||||||
| 86 | |||||||||||
| 87 | __END__ | ||||||||||