line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::SymbolicX::Calculator::Command::Insertion; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
3
|
use Params::Util qw/_INSTANCE/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
25
|
use base 'Math::SymbolicX::Calculator::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
396
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
13
|
0
|
|
0
|
|
|
|
my $class = ref($proto)||$proto; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my %args = @_; |
16
|
0
|
|
|
|
|
|
my $self = bless { |
17
|
|
|
|
|
|
|
symbol => $args{symbol}, |
18
|
|
|
|
|
|
|
what => $args{what}, |
19
|
|
|
|
|
|
|
} => $class; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _execute { |
25
|
0
|
|
|
0
|
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my $c = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $sym = $self->{symbol}; |
29
|
0
|
|
|
|
|
|
my $what = $self->{what}; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $func = $c->{stash}{$sym}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if (_INSTANCE($func, 'Math::Symbolic::Custom::Transformation')) { |
34
|
0
|
|
|
|
|
|
return "Cannot insert into a transformation '$sym'"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my @vars; |
38
|
0
|
0
|
0
|
|
|
|
if (not defined $what or $what eq '*') { |
39
|
0
|
|
|
|
|
|
@vars = $func->signature(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
0
|
|
|
|
|
|
@vars = ($what); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
@vars = |
46
|
|
|
|
|
|
|
grep { |
47
|
0
|
|
|
|
|
|
exists $c->{stash}{$_} |
48
|
|
|
|
|
|
|
and not _INSTANCE( |
49
|
|
|
|
|
|
|
$c->{stash}{$_}, |
50
|
|
|
|
|
|
|
'Math::Symbolic::Custom::Transformation' |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
@vars; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self->_insert_into($c, $func, \@vars); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$c->{stash}{$sym} = $func; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return($sym, '==', $func); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _insert_into { |
63
|
0
|
|
|
0
|
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my $c = shift; |
65
|
0
|
|
|
|
|
|
my $func = shift; |
66
|
0
|
|
|
|
|
|
my $vars = shift; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my %vars; |
69
|
0
|
|
|
|
|
|
foreach (@$vars) { |
70
|
0
|
|
|
|
|
|
$vars{$_} = $c->{stash}{$_}->new; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$func->implement(%vars); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |