line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#new value class! |
2
|
|
|
|
|
|
|
package Language::Farnsworth::Value; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1614
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
43
|
use Language::Farnsworth::Error; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Data::Dumper; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Scalar::Util qw/weaken/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub setref |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
my $ref = shift; |
16
|
|
|
|
|
|
|
$self->{_ref} = $ref; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub sethomescope |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
my $scope = shift; #Farnsworth::Variables type |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
unless ($self->{_homescope}) |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
$self->{_homescope} = $scope; |
27
|
|
|
|
|
|
|
weaken $self->{_homescope}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub gethomescope |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
return $_[0]->{_homescope}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getref |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
return $self->{_ref}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub istype |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
my $allow = shift; #type to allow! |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return ref($self) =~ /\Q$allow/i; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub type |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
return "Value (BUG)"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ismediumtype |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
my $allow = shift; #type to allow! |
59
|
|
|
|
|
|
|
$allow ||= ""; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
if ($self->isa("Language::Farnsworth::Value::Array") && $allow ne "Array") |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
return 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ($self->isa("Language::Farnsworth::Value::Boolean") && $allow ne "Boolean") |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ($self->isa("Language::Farnsworth::Value::String") && $allow ne "String") |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif ($self->isa("Language::Farnsworth::Value::Date") && $allow ne "Date") |
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
return 1; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
# promoting Lambda to a High type, so that it can capture the multiplication with other types |
78
|
|
|
|
|
|
|
# elsif ($self->isa("Language::Farnsworth::Value::Lambda") && $allow ne "Lambda") |
79
|
|
|
|
|
|
|
# { |
80
|
|
|
|
|
|
|
# return 1; |
81
|
|
|
|
|
|
|
# } |
82
|
|
|
|
|
|
|
elsif ($self->isa("Language::Farnsworth::Value::Undef") && $allow ne "Undef") |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
return 1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub conforms |
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
my $comparator = shift; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
if (ref($self) ne ref($comparator)) |
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
return 0; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
if (ref($self) eq "Language::Farnsworth::Value::Pari") |
102
|
|
|
|
|
|
|
{ |
103
|
|
|
|
|
|
|
my $ret = $self->getdimen()->compare($comparator->getdimen()); |
104
|
|
|
|
|
|
|
return 1 if ($comparator->isvalueone()); #read the sentinal value |
105
|
|
|
|
|
|
|
return $ret; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else |
108
|
|
|
|
|
|
|
{ |
109
|
|
|
|
|
|
|
return 1; #for now? |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub clone |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
my $self = shift; |
117
|
|
|
|
|
|
|
my $class = ref($self); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $newself = {}; |
120
|
|
|
|
|
|
|
$newself->{$_} = $self->{$_} for (keys %$self); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
bless $newself, $class; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$newself->setref(undef); |
125
|
|
|
|
|
|
|
$newself; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub getpari |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
#error("Attempting to use "); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub getarray |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub getarrayref |
138
|
|
|
|
|
|
|
{ |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub getstring |
142
|
|
|
|
|
|
|
{ |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |