Code/Expression.pm

filter: Statementstmt 46.1% 12 / 26 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 37.7% 17 / 45 CC 7 SCAR 31.9
CC
7
Cov
32%
command
42.0
output
6.0
BEGIN
1.0
CRAP 24.3
« Code/Condition.pm ↑ Summary Code/Function.pm »
1 package JavaScript::Code::Expression;
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use vars qw[ $VERSION ];
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw[
Subroutine BEGIN: called CC=1 SCAR=0.0
6 JavaScript::Code::Accessor
7 JavaScript::Code::Value
8 2 ];
9
10 2 __PACKAGE__->mk_ro_accessors(qw[ tree ]);
11
12 2 $VERSION = '0.08';
13
14 =head1 NAME
15
16 JavaScript::Code::Expression - A JavaScript Expression
17
18 =head1 DESCRIPTION
19
20 A Expression Class
21
22 =head1 METHODS
23
24 =head2 $self->command( )
25
26 =cut
27
28 0 ▶sub command {
Subroutine command: not called CC=6 SCAR=37.4
Pod documented
29 0 my ( $self, $op, $left, $right ) = @_;
30
31 0 my $class = 'JavaScript::Code::Expression::Op::' . $op;
32 0 eval "require $class";
33 0 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
34
35 0 my $tree;
36 0 ▶ if ( $class->unary ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->unary) { } 0 0 0
37
38 0 ▶ $tree = $class->new(
Branch: 1 branch
BranchTrueFalseTotal
$left->isa('JavaScript::Code::Expression') ? : 0 0 0
39 $left->isa('JavaScript::Code::Expression')
40 ? $left->tree
41 : JavaScript::Code::Expression::Op::Term->new( $left->clone )
42 );
43
44 }
45 else {
46
47 0 ▶ $tree = $class->new(
Branch: 2 branches
BranchTrueFalseTotal
$left->isa('JavaScript::Code::Expression') ? : 0 0 0
$right->isa('JavaScript::Code::Expression') ? : 0 0 0
48 $left->isa('JavaScript::Code::Expression') ? $left->tree
49 : JavaScript::Code::Expression::Op::Term->new( $left->clone ),
50 $right->isa('JavaScript::Code::Expression') ? $right->tree
51 : JavaScript::Code::Expression::Op::Term->new( $right->clone )
52 );
53 }
54
55 0 $self->{tree} = $tree;
56
57 0 return $self;
58 }
59
60 =head2 $self->tree( )
61
62 Returns a tree of L<JavaScript::Code::Expression::Op>'s
63
64 =cut
65
66 =head2 $self->output( )
67
68 =cut
69
70 0 ▶sub output {
Subroutine output: not called CC=2 SCAR=17.9
Pod documented
71 0 my ($self) = @_;
72
73 0 my $tree = $self->tree;
74 0 ▶ return '' unless defined $tree;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tree 0 0 0
75 0 return $tree->output;
76 }
77
78 =head1 SEE ALSO
79
80 L<JavaScript::Code>
81
82 =head1 AUTHOR
83
84 Sascha Kiefer, C<esskar@cpan.org>
85
86 =head1 LICENSE
87
88 This library is free software, you can redistribute it and/or modify it under
89 the same terms as Perl itself.
90
91 =cut
92
93 2 1;
« Code/Condition.pm ↑ Summary Code/Function.pm »