[system] / trunk / pg / lib / Parser / UOP / minus.pm Repository:
ViewVC logotype

View of /trunk/pg/lib/Parser/UOP/minus.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2607 - (download) (as text) (annotate)
Sat Aug 14 11:26:49 2004 UTC (15 years, 3 months ago) by dpvc
File size: 714 byte(s)
Allow unary + and - to work on infinities.

    1 #########################################################################
    2 #
    3 #  Implements unary minus
    4 #
    5 package Parser::UOP::minus;
    6 use strict; use vars qw(@ISA);
    7 @ISA = qw(Parser::UOP);
    8 
    9 #
   10 #  Check that the operand is OK.
   11 #
   12 sub _check {
   13   my $self = shift;
   14   return if ($self->checkInfinite);
   15   return if ($self->checkString);
   16   return if ($self->checkList);
   17   return if ($self->checkNumber);
   18   $self->{type} = {%{$self->{op}->typeRef}};
   19 }
   20 
   21 #
   22 #  Negate the operand.
   23 #
   24 sub _eval {-($_[1])}
   25 
   26 #
   27 #  Remove double negatives.
   28 #
   29 sub _reduce {
   30   my $self = shift; my $op = $self->{op};
   31   $self = $op->{op} if ($op->isNeg);
   32   return $self;
   33 }
   34 
   35 #########################################################################
   36 
   37 1;
   38 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9