line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
2
|
|
|
2
|
|
145968
|
use v5.10; |
|
2
|
|
|
|
|
10
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
32
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
6
|
use feature 'state'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
239
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Context::Singleton; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = v1.0.5; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
11
|
use parent 'Exporter::Tiny'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
11
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
3402
|
use Sub::Install qw(); |
|
2
|
|
|
|
|
1450
|
|
|
2
|
|
|
|
|
31
|
|
14
|
2
|
|
|
2
|
|
806
|
use Variable::Magic qw(); |
|
2
|
|
|
|
|
1777
|
|
|
2
|
|
|
|
|
38
|
|
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
676
|
use Context::Singleton::Frame; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
898
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT = keys %{ _by_frame_class_accessors () }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _by_frame_class_accessors { |
21
|
80
|
|
|
80
|
|
126
|
my ($frame_class) = @_; |
22
|
80
|
|
100
|
|
|
226
|
$frame_class //= 'Context::Singleton::Frame'; |
23
|
|
|
|
|
|
|
|
24
|
80
|
|
|
|
|
81
|
state %cache; |
25
|
|
|
|
|
|
|
|
26
|
80
|
|
66
|
|
|
250
|
return $cache{$frame_class} //= do { |
27
|
3
|
|
|
|
|
13
|
my $current_frame = $frame_class->new; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $restore_context_wizard = Variable::Magic::wizard |
30
|
4
|
|
|
4
|
|
4113
|
free => sub { $current_frame = $current_frame->parent; 1 }, |
|
4
|
|
|
|
|
37
|
|
31
|
3
|
|
|
|
|
14
|
; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $frame = sub (&) { |
34
|
4
|
|
|
4
|
|
16410
|
Variable::Magic::cast my $guard => $restore_context_wizard; |
35
|
4
|
|
|
|
|
14
|
$current_frame = $current_frame->new; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
9
|
$_[0]->(); |
38
|
3
|
|
|
|
|
93
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
+{ |
41
|
5
|
|
|
5
|
|
501
|
contrive => sub { $current_frame->contrive (@_) }, |
42
|
7
|
|
|
7
|
|
13936
|
current_frame => sub { $current_frame }, |
43
|
5
|
|
|
5
|
|
3733
|
deduce => sub { $current_frame->deduce (@_) }, |
44
|
|
|
|
|
|
|
frame => $frame, |
45
|
3
|
|
|
3
|
|
625
|
is_deduced => sub { $current_frame->is_deduced (@_) }, |
46
|
6
|
|
|
6
|
|
486
|
load_rules => sub { $current_frame->load_rules (@_) }, |
47
|
5
|
|
|
5
|
|
20
|
proclaim => sub { $current_frame->proclaim (@_) }, |
48
|
0
|
|
|
0
|
|
0
|
trigger => sub { $current_frame->trigger (@_) }, |
49
|
3
|
|
|
3
|
|
9986
|
try_deduce => sub { $current_frame->try_deduce (@_) }, |
50
|
3
|
|
|
|
|
46
|
}; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _exporter_expand_sub { |
55
|
73
|
|
|
73
|
|
3491
|
my ($class, $name, $args, $globals) = @_; |
56
|
|
|
|
|
|
|
|
57
|
73
|
|
|
|
|
145
|
return $name => _by_frame_class_accessors ($globals->{frame_class})->{$name}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub import { |
61
|
9
|
|
|
9
|
|
7820
|
my ($class, @params) = @_; |
62
|
|
|
|
|
|
|
|
63
|
9
|
100
|
|
|
|
27
|
my $globals = Ref::Util::is_hashref ($params[0]) |
64
|
|
|
|
|
|
|
? shift @params |
65
|
|
|
|
|
|
|
: {} |
66
|
|
|
|
|
|
|
; |
67
|
|
|
|
|
|
|
|
68
|
9
|
|
100
|
|
|
59
|
$globals->{into} //= scalar caller; |
69
|
|
|
|
|
|
|
|
70
|
9
|
|
|
|
|
60
|
$class->SUPER::import ($globals, @params); |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
13
|
_by_frame_class_accessors ($globals->{frame_class})->{load_rules}->(@{ $globals->{load_path} }) |
73
|
9
|
100
|
|
|
|
1893
|
if $globals->{load_path}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |