| 1 | package Language::MinCaml::Node; | ||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 6 | ▶ | use base qw(Class::Accessor::Fast Exporter); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 6 | __PACKAGE__->mk_accessors(qw(kind children)); | |||||||||||
| 6 | |||||||||||||
| 7 | 6 | our @EXPORT = qw(Node_Unit Node_Bool Node_Int Node_Float Node_Tuple | |||||||||||
| 8 | Node_Array Node_Var Node_Not Node_Neg Node_Add Node_Sub | ||||||||||||
| 9 | Node_FNeg Node_FAdd Node_FSub Node_FMul Node_FDiv | ||||||||||||
| 10 | Node_Eq Node_LE Node_If Node_Let Node_LetRec Node_App | ||||||||||||
| 11 | Node_LetTuple Node_Get Node_Put); | ||||||||||||
| 12 | |||||||||||||
| 13 | 6 | for my $routine_name (@EXPORT){ | |||||||||||
| 14 | 150 | my $kind = $routine_name; | |||||||||||
| 15 | 150 | $kind =~ s/^Node_//; | |||||||||||
| 16 | 0 | ▶ | my $routine = sub { __PACKAGE__->new($kind, @_); }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 17 | 6 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 150 | *{$routine_name} = $routine; | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 5 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 22 | 5 | my($class, $kind, @children) = @_; | |||||||||||
| 23 | 5 | return bless { kind => $kind, children => \@children }, $class; | |||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 4 | ▶ | sub to_str { | ||||||||||
|
Subroutine
to_str: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 27 | 4 | my($self, $depth) = @_; | |||||||||||
| 28 | 4 | ▶ | $depth ||= 0; | ||||||||||
|
Condition100%2/2
$depth ||= 0
MC/DC100%1/1
$depth ||= 0
$depth
Truth table100%2/2
A
A= $depth
| |||||||||||||
| 29 | 4 | my $content = "\t" x $depth . "$self->{kind}\n"; | |||||||||||
| 30 | |||||||||||||
| 31 | 4 | for my $child (@{$self->{children}}) { | |||||||||||
| 32 | 6 | ▶ | if (ref($child) eq __PACKAGE__) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 1 | $content .= $child->to_str($depth + 1); | |||||||||||
| 34 | } | ||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 4 | $content; | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 6 | 1; | |||||||||||