line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
23
|
use 5.008003; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package JavaScript::Any::Context::JE; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
9
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
11
|
1
|
|
|
1
|
|
90
|
use Class::Tiny qw( _engine ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
12
|
1
|
|
|
1
|
|
271
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
73
|
|
13
|
|
|
|
|
|
|
with qw( JavaScript::Any::Context ); |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
75
|
use Ref::Util qw( |
16
|
|
|
|
|
|
|
is_plain_arrayref is_plain_hashref is_ref |
17
|
|
|
|
|
|
|
is_blessed_ref is_plain_coderef |
18
|
1
|
|
|
1
|
|
14
|
); |
|
1
|
|
|
|
|
3
|
|
19
|
1
|
|
|
1
|
|
736
|
use JE qw(); |
|
1
|
|
|
|
|
92978
|
|
|
1
|
|
|
|
|
258
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub BUILD { |
22
|
2
|
|
|
2
|
0
|
136
|
my $self = shift; |
23
|
2
|
|
|
|
|
6
|
my ($args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->_engine("JE"->new( |
26
|
|
|
|
|
|
|
max_ops => $args->{max_ops}, |
27
|
2
|
|
|
|
|
10
|
)); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
6659
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# delegated methods |
33
|
2
|
|
|
2
|
0
|
39
|
sub eval { shift->_engine->eval(@_) } |
34
|
0
|
|
|
0
|
0
|
0
|
sub max_ops { shift->_engine->max_ops(@_) } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub define { |
37
|
2
|
|
|
2
|
0
|
20
|
my $self = shift; |
38
|
2
|
|
|
|
|
5
|
my ($name, $value) = @_; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
10
|
$self->_throw_if_bad_name($name); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# XXX |
43
|
|
|
|
|
|
|
# need to install a wrapper |
44
|
|
|
|
|
|
|
# to process params and return values |
45
|
|
|
|
|
|
|
|
46
|
2
|
100
|
|
|
|
15
|
if (is_plain_coderef($value)) { |
47
|
1
|
|
|
|
|
18
|
$self->_engine->new_function($name, $value); |
48
|
1
|
|
|
|
|
295
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
3
|
if (is_plain_hashref($value)) { |
52
|
0
|
|
|
|
|
0
|
...; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
4
|
if (is_plain_arrayref($value)) { |
56
|
0
|
|
|
|
|
0
|
...; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
4
|
if (is_blessed_ref($value)) { |
60
|
0
|
|
|
|
|
0
|
...; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
|
|
|
8
|
if ($self->is_true($value)) { |
64
|
0
|
|
|
|
|
0
|
$self->_engine->prop({ name => $name, value => $self->_engine->true }); |
65
|
0
|
|
|
|
|
0
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
1
|
50
|
|
|
|
6
|
if ($self->is_false($value)) { |
69
|
0
|
|
|
|
|
0
|
$self->_engine->prop({ name => $name, value => $self->_engine->false }); |
70
|
0
|
|
|
|
|
0
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
5
|
if ($self->is_null($value)) { |
74
|
0
|
|
|
|
|
0
|
$self->_engine->prop({ name => $name, value => $self->_engine->null }); |
75
|
0
|
|
|
|
|
0
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
1
|
50
|
|
|
|
3
|
if (not is_ref($value)) { |
79
|
1
|
|
|
|
|
23
|
$self->_engine->prop({ name => $name, value => $self->_engine->upgrade($value) }); |
80
|
1
|
|
|
|
|
84
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$self->_throw_because_bad_value($value); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|