line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Statistics::R::REXP::Environment; |
2
|
|
|
|
|
|
|
# ABSTRACT: an R environment |
3
|
|
|
|
|
|
|
$Statistics::R::REXP::Environment::VERSION = '1.0002'; |
4
|
17
|
|
|
17
|
|
53822
|
use 5.010; |
|
17
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
90
|
use Scalar::Util qw(refaddr blessed); |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
865
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
470
|
use Class::Tiny::Antlers qw(-default around); |
|
17
|
|
|
|
|
3332
|
|
|
17
|
|
|
|
|
84
|
|
9
|
17
|
|
|
17
|
|
2354
|
use namespace::clean; |
|
17
|
|
|
|
|
9442
|
|
|
17
|
|
|
|
|
80
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Statistics::R::REXP'; |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
4110
|
use constant sexptype => 'ENVSXP'; |
|
17
|
|
|
|
|
42
|
|
|
17
|
|
|
|
|
1811
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has frame => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
{ } |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has enclosure => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use overload |
28
|
17
|
|
|
17
|
|
3207
|
'""' => sub { 'environment '. shift->name }; |
|
17
|
|
|
4
|
|
2768
|
|
|
17
|
|
|
|
|
123
|
|
|
4
|
|
|
|
|
17
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub BUILDARGS { |
32
|
475
|
|
|
475
|
0
|
24522
|
my $class = shift; |
33
|
475
|
100
|
|
|
|
1673
|
if ( scalar @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
34
|
2
|
50
|
66
|
|
|
17
|
if ( ref $_[0] eq 'HASH' ) { |
|
|
100
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return $_[0]; |
36
|
|
|
|
|
|
|
} elsif ( blessed $_[0] && $_[0]->isa('Statistics::R::REXP::Environment') ) { |
37
|
|
|
|
|
|
|
# copy constructor from another environment |
38
|
1
|
|
|
|
|
22
|
return { frame => $_[0]->frame, |
39
|
|
|
|
|
|
|
enclosure => $_[0]->enclosure }; |
40
|
|
|
|
|
|
|
} |
41
|
1
|
|
|
|
|
9
|
die "Single parameters to new() must be a HASH data" |
42
|
|
|
|
|
|
|
." or a Statistics::R::REXP::Environment object => ". $_[0] ."\n"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif ( @_ % 2 ) { |
45
|
1
|
|
|
|
|
8
|
die "The new() method for $class expects a hash reference or a key/value list." |
46
|
|
|
|
|
|
|
. " You passed an odd number of arguments\n"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
472
|
|
|
|
|
1400
|
return {@_}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub BUILD { |
55
|
472
|
|
|
472
|
0
|
7456
|
my ($self, $args) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Required attribute type |
58
|
|
|
|
|
|
|
die "Attribute 'frame' must be a reference to a hash of REXPs" if ref($self->frame) ne 'HASH' || |
59
|
472
|
100
|
66
|
|
|
7556
|
grep { ! (blessed($_) && $_->isa('Statistics::R::REXP')) } values(%{$self->frame}); |
|
580
|
|
66
|
|
|
3546
|
|
|
472
|
|
|
|
|
8849
|
|
60
|
|
|
|
|
|
|
|
61
|
471
|
100
|
66
|
|
|
9401
|
die "Attribute 'enclosure' must be an instance of Environment" if defined $self->enclosure && |
|
|
|
100
|
|
|
|
|
62
|
|
|
|
|
|
|
!(blessed($self->enclosure) && $self->enclosure->isa('Statistics::R::REXP::Environment')); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
around _eq => sub { |
67
|
|
|
|
|
|
|
my $orig = shift; |
68
|
|
|
|
|
|
|
return unless $orig->(@_); |
69
|
|
|
|
|
|
|
my ($self, $obj) = (shift, shift); |
70
|
|
|
|
|
|
|
Statistics::R::REXP::_compare_deeply($self->frame, $obj->frame) && |
71
|
|
|
|
|
|
|
Statistics::R::REXP::_compare_deeply($self->enclosure, $obj->enclosure) |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub name { |
76
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
77
|
|
|
|
|
|
|
($self->attributes && exists $self->attributes->{name}) ? |
78
|
|
|
|
|
|
|
$self->attributes->{name} : |
79
|
1
|
50
|
33
|
|
|
20
|
'0x' . sprintf('%x', refaddr $self) |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub to_pl { |
84
|
4
|
|
|
4
|
1
|
1614
|
die "Environments do not have a native Perl representation" |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; # End of Statistics::R::REXP::Environment |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |