| 1 | package Language::Farnsworth::Output; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use overload '""' => \&tostring, "eq" => \&eq; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Language::Farnsworth::Error; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | our %combos; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | our %displays; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | #these primarily are used for display purposes | ||||||||||||||||||||||||||||||||||||||||||
| 16 | sub addcombo | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 260 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addcombo: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 260 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 260 | my $value = shift; #this is a valueless list of dimensions | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 260 | $combos{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | #this returns the name of the combo that matches the current dimensions of a Language::Farnsworth::Value::Pari | ||||||||||||||||||||||||||||||||||||||||||
| 25 | sub findcombo | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 274 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findcombo: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 274 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 274 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 274 | for my $combo (keys %combos) | |||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | #print "TRY COMBO: $combo\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 17638 | my $cv = $combos{$combo}; #grab the value | |||||||||||||||||||||||||||||||||||||||||
| 34 | 17638 | ▶ | return $combo if ($value->getdimen()->compare($cv->getdimen())); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 258 | return undef; #none found | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | #this sets a display for a combo first, then for a dimension | ||||||||||||||||||||||||||||||||||||||||||
| 41 | sub setdisplay | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setdisplay: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $name = shift; #this only works on things created by =!= or |||, i might try to extend that later but i don't think i need to, since you can just create a name with ||| when you need it | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $branch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | #I SHOULD CHECK FOR THE NAME!!!!! | ||||||||||||||||||||||||||||||||||||||||||
| 48 | #print Dumper($name, $branch); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if (exists($combos{$name})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $displays{$name} = $branch; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | else | ||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | error "No such dimension/combination as $name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | sub getdisplay | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 137 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getdisplay: called CC=5 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 137 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 137 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 137 | debug 2, "GETDISP: ",$name, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 137 | ▶ | if (defined($name) && exists($displays{$name})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and exists $Language::Farnsworth::Output::displays{$name}
MC/DC0%0/2
defined $name and exists $Language::Farnsworth::Output::displays{$name}
defined $name
exists $Language::Farnsworth::Output::displays{$name}
Truth table66%2/3
A and B
A= defined $nameB= exists $Language::Farnsworth::Output::displays{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | debug 4, "GETDISP:", (Dumper($displays{$name})), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (ref($displays{$name}) eq "Fetch" && $displays{$name}[0] eq "undef") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $Language::Farnsworth::Output::displays{$name} eq "Fetch" and $Language::Farnsworth::Output::displays{$name}[0] eq "undef"
MC/DC0%0/2
ref $Language::Farnsworth::Output::displays{$name} eq "Fetch" and $Language::Farnsworth::Output::displays{$name}[0] eq "undef"
ref $Language::Farnsworth::Output::displays{$name} eq "Fetch"
$Language::Farnsworth::Output::displays{$name}[0] eq "undef"
Truth table0%0/3
A and B
A= ref $Language::Farnsworth::Output::displays{$name} eq "Fetch"B= $Language::Farnsworth::Output::displays{$name}[0] eq "undef"
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $displays{$name}; #guess i'll just do the rest in there? | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 137 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 90 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 90 | shift; #remove the class | |||||||||||||||||||||||||||||||||||||||||
| 84 | 90 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 90 | $self->{units} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 90 | $self->{obj} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 90 | $self->{eval} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | #warn Dumper($self->{obj}); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | #when we get an error, pass it through, HACK, this is a HACK! the code needs to handle these directly but i need to rewrite the code for output anyway | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 90 | ▶ | error $self->{obj} if ref($self->{obj}) =~ /Language::Farnsworth::Error/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | #warn Dumper($self->{obj}); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 84 | ▶ | error "Attempting to make output class of non Language::Farnsworth::Value" unless ref($self->{obj}) =~ /Language::Farnsworth::Value/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 84 | ▶ | error "Forgot to add \$eval to params!" unless ref($self->{eval}) eq "Language::Farnsworth::Evaluate"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 84 | bless $self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | sub tostring | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 84 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tostring: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 84 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 84 | my $value = $self->{obj}; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 84 | return $self->getoutstring($value); | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | sub eq | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 84 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eq: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 84 | my $one = shift; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 84 | my $two = shift; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 84 | my $order = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 84 | my $string = $one->tostring(); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 84 | return $string eq $two; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | #this takes a set of dimensions and returns what to display | ||||||||||||||||||||||||||||||||||||||||||
| 121 | sub getoutstring | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 160 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getoutstring: called CC=21 SCAR=39.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 160 | my $self = shift; #i'll implement this later too | |||||||||||||||||||||||||||||||||||||||||
| 124 | # my $dimen = shift; #i take a Language::Farnsworth::Dimension object! | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 160 | my $value = shift; #the value so we can stringify it | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 160 | my @returns; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 160 | ▶ | if (defined($value->{outmagic})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if (ref($value->{outmagic}[1]) eq "Language::Farnsworth::Value::String") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | #ok we were given a string! | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $number = $value->{outmagic}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $string = $value->{outmagic}[1]; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $self->getoutstring($number) . " ".$string->getstring(); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | ▶ | elsif (exists($value->{outmagic}[0]) && (ref($value->{outmagic}[0]) ne "Language::Farnsworth::Value::Array")) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $value->{"outmagic"}[0] and ref $value->{"outmagic"}[0] ne "Language::Farnsworth::Value::Array"
MC/DC0%0/2
exists $value->{"outmagic"}[0] and ref $value->{"outmagic"}[0] ne "Language::Farnsworth::Value::Array"
exists $value->{"outmagic"}[0]
ref $value->{"outmagic"}[0] ne "Language::Farnsworth::Value::Array"
Truth table0%0/3
A and B
A= exists $value->{"outmagic"}[0]B= ref $value->{"outmagic"}[0] ne "Language::Farnsworth::Value::Array"
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | #ok we were given a value without the string | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $number = $value->{outmagic}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $self->getoutstring($number); | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | else | ||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | print Dumper($value); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | error "Unhandled output magic, this IS A BUG!"; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | elsif (ref($value) eq "Language::Farnsworth::Value::Boolean") | ||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return $value ? "True" : "False" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | #these should do something! | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | elsif (ref($value) eq "Language::Farnsworth::Value::String") | ||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | #I NEED FUNCTIONS TO HANDLE ESCAPING AND UNESCAPING!!!! | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | my $val = $value->getstring(); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 8 | $val =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | $val =~ s/"/\\"/g; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | return '"'.$val.'"'; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | elsif (ref($value) eq "Language::Farnsworth::Value::Array") | ||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 14 | my @array; #this will be used to build the output | |||||||||||||||||||||||||||||||||||||||||
| 166 | 14 | for my $v ($value->getarray()) | |||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | #print Dumper($v); | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 76 | push @array, $self->getoutstring($v); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | return '['.(join ' , ', @array).']'; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | elsif (ref($value) eq "Language::Farnsworth::Value::Date") | ||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | return $value->getdate()->strftime("# %F %H:%M:%S.%3N %Z #");#UnixDate($value->{pari}, "# %C #"); #output in ISO format for now | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | elsif (ref($value) eq "Language::Farnsworth::Value::Lambda") | ||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | return $value->tostring(); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | elsif (ref($value) eq "Language::Farnsworth::Value::Undef") | ||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return "undef"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | elsif (ref($value) eq "HASH") | ||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | warn "RED ALERT!!!! WE've got a BAD CASE HERE. We've got an UNBLESSED HASH"; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | warn Dumper($value); | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return "undef"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif (my $disp = $self->getdisplay($self->findcombo($value))) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | #$disp should now contain the branches to be used on the RIGHT side of the -> | ||||||||||||||||||||||||||||||||||||||||||
| 196 | #wtf do i put on the left? i'm going to send over the Language::Farnsworth::Value, this generates a warning but i can remove that after i decide that its correct | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | print "SUPERDISPLAY:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $branch = bless [$value, $disp], 'Trans'; | |||||||||||||||||||||||||||||||||||||||||
| 200 | #print Dumper($branch); | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $newvalue = eval {$self->{eval}->evalbranch($branch);}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return $self->getoutstring($newvalue); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | else | ||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 137 | my $dimen = $value->getdimen(); | |||||||||||||||||||||||||||||||||||||||||
| 207 | #added a sort so its stable, i'll need this... | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | for my $d (sort {$a cmp $b} keys %{$dimen->{dimen}}) | |||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 15 | my $exp = ""; | |||||||||||||||||||||||||||||||||||||||||
| 211 | #print Dumper($dimen->{dimen}, $exp); | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 15 | my $dv = "".($dimen->{dimen}{$d}); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 15 | my $realdv = "".(0.0+$dimen->{dimen}{$d}); #use this for comparing below, that way i can keep rational exponents when possible | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 15 | $dv =~ s/([.]\d+?)0+$/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 15 | $dv =~ s/E/e/; #make floating points clearer | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | ▶ | $exp = "^".($dv =~ /^[\d\.]+$/? $dv :"(".$dv.")") unless ($realdv eq "1"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 15 | push @returns, $self->{units}->getdimen($d).$exp; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 137 | ▶ | if (my $combo = $self->findcombo($value)) #this should be a method? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | push @returns, "/* $combo */"; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 137 | my $prec = Math::Pari::setprecision(); | |||||||||||||||||||||||||||||||||||||||||
| 230 | 137 | Math::Pari::setprecision(15); #set it to 15? | |||||||||||||||||||||||||||||||||||||||||
| 231 | 137 | my $pv = "".(Math::Pari::pari_print($value->getpari())); | |||||||||||||||||||||||||||||||||||||||||
| 232 | 137 | my $parenflag = $pv =~ /^[\d\.e]+$/i; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 137 | my $rational = $pv =~ m|/|; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 137 | $pv =~ s/E/e/; #make floating points clearer | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 137 | ▶ | if ($pv =~ m|/|) #check for rationality | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $nv = "".Math::Pari::pari_print($value->getpari() * 1.0); #attempt to force a floating value | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $nv =~ s/([.]\d+?)0+$/$1/ ; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $pv .= " /* apx ($nv) */"; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 137 | ▶ | $pv = ($parenflag? $pv :"(".$pv.")"); #check if its a simple value, or complex, if it is complex, add parens | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 137 | $pv =~ s/([.]\d+?)0+$/$1/ ; | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 137 | Math::Pari::setprecision($prec); #restore it before calcs | |||||||||||||||||||||||||||||||||||||||||
| 248 | 137 | return $pv." ".join " ", @returns; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | sub makevalue | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makevalue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | error "MAKEVALUE WAS CALLED!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 258 | __END__ | ||||||||||||||||||||||||||||||||||||||||||