line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
14
|
use 5.008003; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package JavaScript::Any::Context::JE; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
52
|
use Class::Tiny qw( _engine ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
206
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
13
|
|
|
|
|
|
|
with qw( JavaScript::Any::Context ); |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
77
|
use Ref::Util qw( |
16
|
|
|
|
|
|
|
is_plain_arrayref is_plain_hashref is_ref |
17
|
|
|
|
|
|
|
is_blessed_ref is_plain_coderef |
18
|
1
|
|
|
1
|
|
7
|
); |
|
1
|
|
|
|
|
3
|
|
19
|
1
|
|
|
1
|
|
596
|
use JE qw(); |
|
1
|
|
|
|
|
82701
|
|
|
1
|
|
|
|
|
297
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub BUILD { |
22
|
2
|
|
|
2
|
0
|
139
|
my $self = shift; |
23
|
2
|
|
|
|
|
5
|
my ($args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->_engine("JE"->new( |
26
|
|
|
|
|
|
|
max_ops => $args->{max_ops}, |
27
|
2
|
|
|
|
|
12
|
)); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
7033
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# delegated methods |
33
|
2
|
|
|
2
|
0
|
40
|
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
|
17
|
my $self = shift; |
38
|
2
|
|
|
|
|
6
|
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
|
|
|
|
11
|
if (is_plain_coderef($value)) { |
47
|
1
|
|
|
|
|
19
|
$self->_engine->new_function($name, $value); |
48
|
1
|
|
|
|
|
337
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
5
|
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
|
|
|
|
8
|
if (is_blessed_ref($value)) { |
60
|
0
|
|
|
|
|
0
|
...; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
|
|
|
5
|
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
|
|
|
|
8
|
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
|
|
|
|
|
77
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$self->_throw_because_bad_value($value); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|