| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Devel::TypeCheck::Type::Eta; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Devel::TypeCheck::Type::Eta - Glob type representation |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Devel::TypeCheck::Type::Eta; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Eta represents a glob type in Perl. This inherits from the |
|
14
|
|
|
|
|
|
|
Devel::TypeCheck::Type class. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
753
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
7
|
use Devel::TypeCheck::Type; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
51
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Devel::TypeCheck::Util; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
492
|
|
|
23
|
1
|
|
|
1
|
|
3698
|
use Devel::TypeCheck::Type::TRef; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1499
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @ISA = qw(Devel::TypeCheck::Type); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# **** INSTANCE **** |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
|
30
|
0
|
|
|
0
|
1
|
|
my ($name, $kappa, $omicron, $chi, $zeta) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if ($kappa->type != Devel::TypeCheck::Type::M() && |
|
33
|
|
|
|
|
|
|
$kappa->subtype->type != Devel::TypeCheck::Type::K()) { |
|
34
|
0
|
|
|
|
|
|
carp("Impossible included type ", $kappa->type, " for scalar (kappa) part of Eta\n"); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
0
|
|
|
|
if (defined($omicron) && $omicron->type != Devel::TypeCheck::Type::M() && |
|
|
|
|
0
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$omicron->subtype->type != Devel::TypeCheck::Type::O()) { |
|
39
|
0
|
|
|
|
|
|
carp("Impossible included type ", $omicron->type, " for array (omicron) part of Eta\n"); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
|
if (defined($chi) && $chi->type != Devel::TypeCheck::Type::M() && |
|
|
|
|
0
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$chi->subtype->type != Devel::TypeCheck::Type::X()) { |
|
44
|
0
|
|
|
|
|
|
carp("Impossible included type ", $chi->type, " for hash (chi) part of Eta\n"); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if (defined($zeta) && $zeta->type != Devel::TypeCheck::Type::M() && |
|
|
|
|
0
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$zeta->subtype->type != Devel::TypeCheck::Type::Z()) { |
|
49
|
0
|
|
|
|
|
|
carp("Impossible included type ", $zeta->type, " for CV (zeta) part of Eta\n"); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $this = {}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
bless($this, $name); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$this->{'K'} = $kappa; $this->setSV; |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$this->{'O'} = $omicron; $this->setAV; |
|
|
0
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$this->{'X'} = $chi; $this->setHV; |
|
|
0
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$this->{'Z'} = $zeta; $this->setCV; |
|
|
0
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$this->{'subtype'} = undef; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $this; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub type { |
|
67
|
0
|
|
|
0
|
1
|
|
return Devel::TypeCheck::Type::H(); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub str { |
|
71
|
0
|
|
|
0
|
1
|
|
my ($this, $env) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my @str; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
for my $i ('IO') { |
|
76
|
0
|
0
|
|
|
|
|
if ($this->_getGeneric($i)) { |
|
77
|
0
|
|
|
|
|
|
push(@str, "<$i>"); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $str; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ($#str >= 0) { |
|
84
|
0
|
|
|
|
|
|
$str = join(";", @str); |
|
85
|
|
|
|
|
|
|
} else { |
|
86
|
0
|
|
|
|
|
|
$str = "..."; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return ("H:$str;" . $this->derefKappa->str($env) . ";" . $this->derefOmicron->str($env) . ";" . $this->derefChi->str($env) . ";" . $this->derefZeta->str($env)); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub derefKappa { |
|
93
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
94
|
0
|
|
|
|
|
|
return $this->{'K'}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub derefOmicron { |
|
98
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
99
|
0
|
|
|
|
|
|
return $this->{'O'}; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub derefChi { |
|
103
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
104
|
0
|
|
|
|
|
|
return $this->{'X'}; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub derefZeta { |
|
108
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
109
|
0
|
|
|
|
|
|
return $this->{'Z'}; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub deref { |
|
113
|
0
|
|
|
0
|
1
|
|
confess("This is an error, and should be converted to a derefKappa (probably)"); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _setGeneric { |
|
117
|
0
|
|
|
0
|
|
|
my ($this, $value) = @_; |
|
118
|
0
|
|
|
|
|
|
$this->{$value} = TRUE; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _getGeneric { |
|
122
|
0
|
|
|
0
|
|
|
my ($this, $value) = @_; |
|
123
|
0
|
0
|
|
|
|
|
if (exists($this->{$value})) { |
|
124
|
0
|
|
|
|
|
|
return $this->{$value}; |
|
125
|
|
|
|
|
|
|
} else { |
|
126
|
0
|
|
|
|
|
|
return FALSE; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub setSV { |
|
131
|
0
|
|
|
0
|
0
|
|
return $_[0]->_setGeneric('SV'); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub getSV { |
|
135
|
0
|
|
|
0
|
0
|
|
return $_[0]->_getGeneric('SV'); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub setAV { |
|
139
|
0
|
|
|
0
|
0
|
|
return $_[0]->_setGeneric('AV'); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub getAV { |
|
143
|
0
|
|
|
0
|
0
|
|
return $_[0]->_getGeneric('AV'); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub setHV { |
|
147
|
0
|
|
|
0
|
0
|
|
return $_[0]->_setGeneric('HV'); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub getHV { |
|
151
|
0
|
|
|
0
|
0
|
|
return $_[0]->_getGeneric('HV'); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub setCV { |
|
155
|
0
|
|
|
0
|
0
|
|
return $_[0]->_setGeneric('CV'); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub getCV { |
|
159
|
0
|
|
|
0
|
0
|
|
return $_[0]->_getGeneric('CV'); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub setIO { |
|
163
|
0
|
|
|
0
|
0
|
|
return $_[0]->_setGeneric('IO'); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub getIO { |
|
167
|
0
|
|
|
0
|
0
|
|
return $_[0]->_getGeneric('IO'); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub occurs { |
|
171
|
0
|
|
|
0
|
0
|
|
my ($this, $that, $env) = @_; |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
0
|
|
|
|
return (($this->derefKappa->occurs($that, $env) || |
|
174
|
|
|
|
|
|
|
$this->derefOmicron->occurs($that, $env) || |
|
175
|
|
|
|
|
|
|
$this->derefChi->occurs($that, $env))); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub unify { |
|
179
|
0
|
|
|
0
|
0
|
|
my ($this, $that, $env) = @_; |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
if ($this->type == $that->type) { |
|
182
|
0
|
0
|
0
|
|
|
|
if ($env->unify($this->derefKappa, $that->derefKappa) && |
|
|
|
|
0
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$env->unify($this->derefOmicron, $that->derefOmicron) && |
|
184
|
|
|
|
|
|
|
$env->unify($this->derefChi, $that->derefChi)) { |
|
185
|
0
|
|
|
|
|
|
return $this; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# Failure |
|
190
|
0
|
|
|
|
|
|
return undef; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub pretty { |
|
194
|
0
|
|
|
0
|
1
|
|
my ($this, $env) = @_; |
|
195
|
0
|
|
|
|
|
|
my @str; |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
0
|
|
|
|
|
if ($this->_getGeneric('IO')) { |
|
198
|
0
|
|
|
|
|
|
push (@str, "IO HANDLE"); |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
my $str; |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
if ($#str >= 0) { |
|
204
|
0
|
|
|
|
|
|
$str = join("; ", @str); |
|
205
|
|
|
|
|
|
|
} else { |
|
206
|
0
|
|
|
|
|
|
$str = "..."; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
return ("GLOB of ($str; " . |
|
210
|
|
|
|
|
|
|
$this->derefKappa->pretty($env) . "; " . |
|
211
|
|
|
|
|
|
|
$this->derefOmicron->pretty($env) . "; " . |
|
212
|
|
|
|
|
|
|
$this->derefChi->pretty($env) . "; " . |
|
213
|
|
|
|
|
|
|
$this->derefZeta->pretty($env) . |
|
214
|
|
|
|
|
|
|
")"); |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
TRUE; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 AUTHOR |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Gary Jackson, C<< >> |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 BUGS |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This version is specific to Perl 5.8.1. It may work with other |
|
226
|
|
|
|
|
|
|
versions that have the same opcode list and structure, but this is |
|
227
|
|
|
|
|
|
|
entirely untested. It definitely will not work if those parameters |
|
228
|
|
|
|
|
|
|
change. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
231
|
|
|
|
|
|
|
C, or through the web interface at |
|
232
|
|
|
|
|
|
|
L. |
|
233
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
234
|
|
|
|
|
|
|
your bug as I make changes. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright 2005 Gary Jackson, all rights reserved. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
241
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=cut |