line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2011-2021 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
169
|
use v5.26; |
|
15
|
|
|
|
|
45
|
|
7
|
15
|
|
|
15
|
|
84
|
use Object::Pad 0.44; |
|
15
|
|
|
|
|
151
|
|
|
15
|
|
|
|
|
65
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Tangence::Meta::Property 0.28; |
10
|
|
|
|
|
|
|
class Tangence::Meta::Property :strict(params); |
11
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
5277
|
use Syntax::Keyword::Match; |
|
15
|
|
|
|
|
2257
|
|
|
15
|
|
|
|
|
102
|
|
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
845
|
use Tangence::Constants; |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
13581
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C - structure representing one C property |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This data structure object stores information about one L class |
23
|
|
|
|
|
|
|
property. Once constructed, such objects are immutable. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$property = Tangence::Meta::Property->new( %args ) |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns a new instance initialised by the given arguments. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 8 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item class => Tangence::Meta::Class |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Reference to the containing class |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item name => STRING |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Name of the property |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item dimension => INT |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Dimension of the property, as one of the C constants from |
50
|
|
|
|
|
|
|
L. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item type => STRING |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The element type as a L reference. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item smashed => BOOL |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Optional. If true, marks that the property is smashed. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
1
|
1
|
419
|
has $class :param :weak :reader; |
|
1
|
|
|
|
|
4
|
|
65
|
124
|
|
|
124
|
1
|
1729
|
has $name :param :reader; |
|
124
|
|
|
|
|
331
|
|
66
|
480
|
|
|
480
|
1
|
753
|
has $dimension :param :reader; |
|
480
|
|
|
|
|
1316
|
|
67
|
272
|
|
|
272
|
1
|
488
|
has $type :param :reader; |
|
272
|
|
|
|
|
842
|
|
68
|
192
|
|
|
192
|
1
|
286
|
has $smashed :param :reader = 0; |
|
192
|
|
|
|
|
486
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 ACCESSORS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 class |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$class = $property->class |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns the class the property is a member of |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 name |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$name = $property->name |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the name of the class |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 dimension |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$dimension = $property->dimension |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns the dimension as one of the C constants. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 type |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$type = $property->type |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the element type as a L reference. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 overall_type |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$type = $property->overall_type |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the type of the entire collection as a L |
111
|
|
|
|
|
|
|
reference. For scalar types this will be the element type. For dict types this |
112
|
|
|
|
|
|
|
will be a hash of the array type. For array, queue and objset types this will |
113
|
|
|
|
|
|
|
a list of the element type. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
has $_overall_type; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
method overall_type |
120
|
90
|
|
|
90
|
1
|
191
|
{ |
121
|
90
|
|
66
|
|
|
279
|
return $_overall_type ||= do { |
122
|
61
|
|
|
|
|
159
|
my $type = $self->type; |
123
|
61
|
|
|
|
|
155
|
my $dim = $self->dimension; |
124
|
|
|
|
|
|
|
match( $dim : == ) { |
125
|
|
|
|
|
|
|
case( DIM_SCALAR ) { |
126
|
30
|
|
|
|
|
162
|
$type; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
case( DIM_HASH ) { |
129
|
4
|
|
|
|
|
19
|
$self->make_type( dict => $type ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
case( DIM_ARRAY ), case( DIM_QUEUE ), case( DIM_OBJSET ) { |
132
|
27
|
|
|
|
|
149
|
$self->make_type( list => $type ); |
133
|
|
|
|
|
|
|
} |
134
|
61
|
100
|
100
|
|
|
363
|
default { |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
die "Unrecognised dimension $dim for ->overall_type"; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 smashed |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$smashed = $property->smashed |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns true if the property is smashed. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# For subclasses to override if required |
150
|
|
|
|
|
|
|
method make_type |
151
|
0
|
|
|
0
|
0
|
|
{ |
152
|
0
|
|
|
|
|
|
return Tangence::Meta::Type->make( @_ ); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Paul Evans |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
0x55AA; |
162
|
|
|
|
|
|
|
|