line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::TypeCheck::Type::Zeta; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1525
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Devel::TypeCheck::Type; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
8
|
use Devel::TypeCheck::Type::TSub; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
7
|
use Devel::TypeCheck::Type::TVar; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
5
|
use Devel::TypeCheck::Util; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
696
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Devel::TypeCheck::Type::Zeta - Code values (CVs) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Devel::TypeCheck::Type::Zeta; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Zeta represents code values (CVs). A CV takes a list as an argument |
22
|
|
|
|
|
|
|
and returns a value. Thus, Zeta is typed as a tuple of a parameter |
23
|
|
|
|
|
|
|
list and a return value. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
our @ISA = qw(Devel::TypeCheck::Type); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# **** CLASS **** |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub type { |
31
|
0
|
|
|
0
|
1
|
|
return Devel::TypeCheck::Type::Z(); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# **** INSTANCE **** |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
|
my ($name, $param, $return) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $this = {}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# if (defined($param) && |
42
|
|
|
|
|
|
|
# ($param->type != Devel::TypeCheck::Type::M() || |
43
|
|
|
|
|
|
|
# ($param->type == Devel::TypeCheck::Type::M() && |
44
|
|
|
|
|
|
|
# $param->subtype->type != Devel::TypeCheck::Type::O()))) { |
45
|
|
|
|
|
|
|
# confess("Impossible type ", $param->type, " for parameter part of Zeta"); |
46
|
|
|
|
|
|
|
# } |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$this->{'param'} = $param; |
49
|
0
|
|
|
|
|
|
$this->{'return'} = $return; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return bless($this, $name); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub str { |
55
|
0
|
|
|
0
|
1
|
|
my ($this, $env) = @_; |
56
|
0
|
|
|
|
|
|
return "Z:(" . $this->derefParam->str($env) . ")->(" . $this->derefReturn->str($env) . ")"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub pretty { |
60
|
0
|
|
|
0
|
1
|
|
my ($this, $env) = @_; |
61
|
0
|
|
|
|
|
|
return "FUNCTION: (" . |
62
|
|
|
|
|
|
|
$this->derefParam->pretty($env) . |
63
|
|
|
|
|
|
|
") -> (" . |
64
|
|
|
|
|
|
|
$this->derefReturn->pretty($env) . |
65
|
|
|
|
|
|
|
")"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub derefParam { |
69
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
70
|
0
|
|
|
|
|
|
return $this->{'param'}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub derefReturn { |
74
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
75
|
0
|
|
|
|
|
|
return $this->{'return'}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub unify { |
79
|
0
|
|
|
0
|
0
|
|
my ($this, $that, $env) = @_; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$this = $env->find($this); |
82
|
0
|
|
|
|
|
|
$that = $env->find($that); |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ($this->type == $that->type) { |
85
|
0
|
|
|
|
|
|
my $param = $env->unify($this->derefParam, $that->derefParam); |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if (defined($param)) { |
88
|
0
|
|
|
|
|
|
my $return = $env->unify($this->derefReturn, $that->derefReturn); |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if (defined($return)) { |
91
|
0
|
|
|
|
|
|
return $this; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return undef; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub subtype { |
100
|
0
|
|
|
0
|
1
|
|
return undef; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub occurs { |
104
|
0
|
|
|
0
|
0
|
|
my ($this, $that, $env) = @_; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
0
|
|
|
|
return ($this->derefParam->occurs($that, $env) || |
107
|
|
|
|
|
|
|
$this->derefReturn->occurs($that, $env)); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
TRUE; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Gary Jackson, C<< >> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 BUGS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This version is specific to Perl 5.8.1. It may work with other |
119
|
|
|
|
|
|
|
versions that have the same opcode list and structure, but this is |
120
|
|
|
|
|
|
|
entirely untested. It definitely will not work if those parameters |
121
|
|
|
|
|
|
|
change. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
124
|
|
|
|
|
|
|
C, or through the web interface at |
125
|
|
|
|
|
|
|
L. |
126
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
127
|
|
|
|
|
|
|
your bug as I make changes. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2005 Gary Jackson, all rights reserved. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the same terms as Perl itself. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |