File Coverage

blib/lib/Language/P/Toy/Value/Subroutine.pm
Criterion Covered Total %
statement 29 32 90.6
branch n/a
condition 2 2 100.0
subroutine 9 12 75.0
pod 1 4 25.0
total 41 50 82.0


line stmt bran cond sub pod time code
1             package Language::P::Toy::Value::Subroutine;
2              
3 100     100   606 use strict;
  100         389  
  100         3636  
4 100     100   525 use warnings;
  100         194  
  100         3043  
5 100     100   535 use base qw(Language::P::Toy::Value::Code);
  100         192  
  100         68462  
6              
7             __PACKAGE__->mk_ro_accessors( qw(name) );
8              
9 0     0 0 0 sub type { 6 }
10 2     2 0 6 sub is_subroutine { 1 }
11              
12             sub new {
13 41     41 1 513 my( $class, $args ) = @_;
14 41         261 my $self = $class->SUPER::new( $args );
15              
16             # for @_
17 41   100     245 $self->{stack_size} ||= 1;
18              
19 41         91 return $self;
20             }
21              
22             sub call {
23 2846     2846 0 4535 my( $self, $runtime, $pc, $context ) = @_;
24 2846         3253 my $args = pop @{$runtime->{_stack}};
  2846         5166  
25              
26 2846         9587 $self->SUPER::call( $runtime, $pc, $context );
27              
28 2846         5706 my( $stack, $frame ) = ( $runtime->{_stack}, $runtime->{_frame} );
29              
30 2846         7697 $stack->[$frame - 3] = $args;
31             }
32              
33             package Language::P::Toy::Value::Subroutine::Stub;
34              
35 100     100   768 use strict;
  100         213  
  100         3090  
36 100     100   612 use warnings;
  100         184  
  100         3190  
37 100     100   525 use base qw(Language::P::Toy::Value::Subroutine);
  100         896  
  100         14066  
38              
39 0     0     sub call { Carp::confess( "Called subroutine stub" ) }
40 0     0     sub is_defined { 0 }
41              
42             1;