line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::TypeCheck::Type::TVar; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Devel::TypeCheck::Type; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
6
|
use Devel::TypeCheck::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
345
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Devel::TypeCheck::Type::TVar - Methods to inherit for types that allow |
12
|
|
|
|
|
|
|
type variables as subtypes. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Devel::TypeCheck::Type::TVar; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@ISA = (... Devel::TypeCheck::Type::TVar ...) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This type overrides the unify method from Devel::TypeCheck::Type to |
23
|
|
|
|
|
|
|
allow for having a type variable as a subtype. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Inherits from Devel::TypeCheck::Type. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
our @ISA = qw(Devel::TypeCheck::Type); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# **** INSTANCE **** |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub unify { |
33
|
0
|
|
|
0
|
0
|
|
my ($this, $that, $env) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$this = $env->find($this); |
36
|
0
|
|
|
|
|
|
$that = $env->find($that); |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ($this->type == $that->type) { |
39
|
|
|
|
|
|
|
# If a subtype is VAR, then we need to go back to the main |
40
|
|
|
|
|
|
|
# unify() |
41
|
0
|
0
|
0
|
|
|
|
if ($this->subtype->type == Devel::TypeCheck::Type::VAR() || |
42
|
|
|
|
|
|
|
$that->subtype->type == Devel::TypeCheck::Type::VAR()) { |
43
|
0
|
|
|
|
|
|
return $env->unify($this->subtype, $that->subtype); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
|
return $this->subtype->unify($that->subtype, $env); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
|
return undef; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub type { |
53
|
0
|
|
|
0
|
1
|
|
croak("Method &type not implemented for abstract class Devel::TypeCheck::Type::TVar"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
TRUE; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Gary Jackson, C<< >> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 BUGS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This version is specific to Perl 5.8.1. It may work with other |
65
|
|
|
|
|
|
|
versions that have the same opcode list and structure, but this is |
66
|
|
|
|
|
|
|
entirely untested. It definitely will not work if those parameters |
67
|
|
|
|
|
|
|
change. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
70
|
|
|
|
|
|
|
C, or through the web interface at |
71
|
|
|
|
|
|
|
L. |
72
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
73
|
|
|
|
|
|
|
your bug as I make changes. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Copyright 2005 Gary Jackson, all rights reserved. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
80
|
|
|
|
|
|
|
under the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |