[system] / trunk / pg / lib / Value.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Value.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5000 Revision 5001
315# 315#
316# Returns the package name for the specificied Value object class 316# Returns the package name for the specificied Value object class
317# (as specified by the context's {value} hash, or "Value::name"). 317# (as specified by the context's {value} hash, or "Value::name").
318# 318#
319sub Package { 319sub Package {
320 my $self = shift; my $class = shift; my $context = $self->context; 320 my $self = shift; my $class = shift;
321 my $context = (Value::isContext($_[0]) ? shift : $self->context);
321 return $context->{value}{$class} if defined $context->{value}{$class}; 322 return $context->{value}{$class} if defined $context->{value}{$class};
322 return "Value::$class" if defined @{"Value::${class}::ISA"}; 323 return "Value::$class" if defined @{"Value::${class}::ISA"};
323 Value::Error("No such package 'Value::%s'",$class) unless $_[0]; 324 Value::Error("No such package 'Value::%s'",$class) unless $_[0];
324} 325}
325 326
481 if (isFormula($x)) { 482 if (isFormula($x)) {
482 $formula->{context} = $x->{context}, $processed = 1 unless $processed; 483 $formula->{context} = $x->{context}, $processed = 1 unless $processed;
483 $formula->{variables} = {%{$formula->{variables}},%{$x->{variables}}}; 484 $formula->{variables} = {%{$formula->{variables}},%{$x->{variables}}};
484 push(@f,$x->{tree}->copy($formula)); 485 push(@f,$x->{tree}->copy($formula));
485 } else { 486 } else {
486 push(@f,$formula->{context}{parser}{Value}->new($formula,$x)); 487 push(@f,$formula->Item("Value")->new($formula,$x));
487 } 488 }
488 } 489 }
489 return (@f); 490 return (@f);
490} 491}
491 492
501 my $open = $list->{'open'}; 502 my $open = $list->{'open'};
502 my $close = $list->{'close'}; 503 my $close = $list->{'close'};
503 my $paren = $open; $paren = 'list' if $self->classMatch('List'); 504 my $paren = $open; $paren = 'list' if $self->classMatch('List');
504 my $formula = $self->Package("Formula")->blank($context); 505 my $formula = $self->Package("Formula")->blank($context);
505 my @coords = Value::toFormula($formula,@{$values}); 506 my @coords = Value::toFormula($formula,@{$values});
506 $formula->{tree} = $formula->{context}{parser}{List}->new($formula,[@coords],0, 507 $formula->{tree} = $formula->Item("List")->new($formula,[@coords],0,
507 $formula->{context}{parens}{$paren},$coords[0]->typeRef,$open,$close); 508 $formula->{context}{parens}{$paren},$coords[0]->typeRef,$open,$close);
508 $formula->{autoFormula} = 1; # mark that this was generated automatically 509 $formula->{autoFormula} = 1; # mark that this was generated automatically
509 return $formula; 510 return $formula;
510} 511}
511 512
871 @p = ("'".$self->{open}."'",@p,"'".$self->{close}."'") if $self->classMatch('Interval'); 872 @p = ("'".$self->{open}."'",@p,"'".$self->{close}."'") if $self->classMatch('Interval');
872 if ($matrix) { 873 if ($matrix) {
873 $perl = join(',',@p); 874 $perl = join(',',@p);
874 $perl = '['.$perl.']' if $mtype > 0; 875 $perl = '['.$perl.']' if $mtype > 0;
875 } else { 876 } else {
876 $perl = 'new '.ref($self).'('.join(',',@p).')'; 877 $perl = ref($self).'->new('.join(',',@p).')';
877 $perl = "($perl)->with(open=>'$self->{open}',close=>'$self->{close}')" 878 $perl = "($perl)->with(open=>'$self->{open}',close=>'$self->{close}')"
878 if $self->classMatch('List') && $self->{open}.$self->{close} ne '()'; 879 if $self->classMatch('List') && $self->{open}.$self->{close} ne '()';
879 $perl = '('.$perl.')' if $parens == 1; 880 $perl = '('.$perl.')' if $parens == 1;
880 } 881 }
881 return $perl; 882 return $perl;

Legend:
Removed from v.5000  
changed lines
  Added in v.5001

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9