blib/lib/Zuzu/Value/Object.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 2 / 2 totaltotal 92.8% 39 / 42 CC 3 SCAR 5.2
CC
3
Cov
94%
run_demolish_hook
3.0
__ANON__
1.1
BEGIN
1.0
CRAP 1.7
« blib/lib/Zuzu.pm ↑ Summary blib/lib/Zuzu/AST/Stmt/Continue.pm »
1 package Zuzu::Value::Object;
2  
3 70 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 70 our $VERSION = '0.007002';
6  
7 70 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 70 has 'class' => ( is => 'rw' );
10 70 has 'slots' => ( is => 'rw' );
11 70 has 'const' => ( is => 'rw' );
12 0 ▶has 'types' => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
13 2824 ▶has 'weak' => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
14 70 has 'demolish_hook' => ( is => 'rw' );
15  
16 92 ▶sub is_truthy { 1 }
Subroutine is_truthy: called CC=1 SCAR=0.0
Pod documented
17  
18 428 ▶sub run_demolish_hook {
Subroutine run_demolish_hook: called CC=3 SCAR=11.0
Pod documented
19 428 my ( $self ) = @_;
20  
21 428 my $hook = $self->demolish_hook;
22 428 ▶ return if ref($hook) ne 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $hook ne "CODE" 421 7 428
23 7 $self->demolish_hook(undef);
24  
25 7 local $@;
26 7 ▶ eval { $hook->($self); 1 } or return;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &$hook($self); 1 } } or return 7 0 7
27  
28 7 return;
29 }
30  
31 427 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
32 427 my ( $self ) = @_;
33  
34 427 $self->run_demolish_hook;
35  
36 427 return;
37 }
38  
39 =pod
40  
41 =head1 NAME
42  
43 Zuzu::Value::Object - runtime value class for class instances
44  
45 =head1 DESCRIPTION
46  
47 Represents an instantiated object with class reference and slot
48 storage.
49  
50 =head1 INHERITANCE
51  
52 Inherits from C<Moo::Object>.
53  
54 =head1 ROLES
55  
56 None.
57  
58 =head1 ATTRIBUTES
59  
60 =head2 class
61  
62 Type: B<InstanceOf["Zuzu::Value::Class"]>.
63  
64 Class value used for method dispatch and inheritance checks.
65  
66 =head2 slots
67  
68 Type: B<HashRef>.
69  
70 Storage for instance members and class constants copied to object.
71  
72 =head2 const
73  
74 Type: B<HashRef[Bool]>.
75  
76 Per-slot const flags enforcing assignment restrictions.
77  
78 =head1 METHODS
79  
80 =head2 is_truthy
81  
82 Returns this runtime value's truthiness in ZuzuScript.
83  
84 =head2 run_demolish_hook
85  
86 Runs and clears the optional lifecycle cleanup callback.
87  
88 =head2 DESTROY
89  
90 Runs the optional lifecycle cleanup callback before this object is
91 garbage collected.
92  
93 =head1 SEE ALSO
94  
95 Subclasses: none in this distribution.
96  
97 =head1 COPYRIGHT AND LICENCE
98  
99 B<< Zuzu::Value::Object >> is copyright Toby Inkster.
100  
101 It is free software; you may redistribute it and/or modify it under
102 the terms of either the Artistic License 1.0 or the GNU General Public
103 License version 2.
104  
105 =cut
106  
107 70 1;
« blib/lib/Zuzu.pm ↑ Summary blib/lib/Zuzu/AST/Stmt/Continue.pm »