Home | History | Annotate | Download | only in value
      1 /*
      2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
      3  *             of Java bytecode.
      4  *
      5  * Copyright (c) 2002-2013 Eric Lafortune (eric (at) graphics.cornell.edu)
      6  *
      7  * This program is free software; you can redistribute it and/or modify it
      8  * under the terms of the GNU General Public License as published by the Free
      9  * Software Foundation; either version 2 of the License, or (at your option)
     10  * any later version.
     11  *
     12  * This program is distributed in the hope that it will be useful, but WITHOUT
     13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
     15  * more details.
     16  *
     17  * You should have received a copy of the GNU General Public License along
     18  * with this program; if not, write to the Free Software Foundation, Inc.,
     19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     20  */
     21 package proguard.evaluation.value;
     22 
     23 /**
     24  * This LongValue represents the result of a binary operation on two long
     25  * values.
     26  *
     27  * @author Eric Lafortune
     28  */
     29 final class CompositeLongValue extends SpecificLongValue
     30 {
     31     public static final byte ADD                  = '+';
     32     public static final byte SUBTRACT             = '-';
     33     public static final byte MULTIPLY             = '*';
     34     public static final byte DIVIDE               = '/';
     35     public static final byte REMAINDER            = '%';
     36     public static final byte SHIFT_LEFT           = '<';
     37     public static final byte SHIFT_RIGHT          = '>';
     38     public static final byte UNSIGNED_SHIFT_RIGHT = '}';
     39     public static final byte AND                  = '&';
     40     public static final byte OR                   = '|';
     41     public static final byte XOR                  = '^';
     42 
     43 
     44     private final LongValue longValue1;
     45     private final byte      operation;
     46     private final Value     longValue2;
     47 
     48 
     49     /**
     50      * Creates a new composite long value of the two given long values
     51      * and the given operation.
     52      */
     53     public CompositeLongValue(LongValue longValue1,
     54                               byte      operation,
     55                               Value     longValue2)
     56     {
     57         this.longValue1 = longValue1;
     58         this.operation  = operation;
     59         this.longValue2 = longValue2;
     60     }
     61 
     62 
     63     // Implementations for Object.
     64 
     65     public boolean equals(Object object)
     66     {
     67         return this == object ||
     68                super.equals(object) &&
     69                this.longValue1.equals(((CompositeLongValue)object).longValue1) &&
     70                this.operation      == ((CompositeLongValue)object).operation   &&
     71                this.longValue2.equals(((CompositeLongValue)object).longValue2);
     72     }
     73 
     74 
     75     public int hashCode()
     76     {
     77         return super.hashCode() ^
     78                longValue1.hashCode() ^
     79                longValue2.hashCode();
     80     }
     81 
     82 
     83     public String toString()
     84     {
     85         return "("+longValue1+((char)operation)+longValue2+")";
     86     }
     87 }