home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / tools / tree / IntegerExpression.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  1.3 KB  |  56 lines

  1. package sun.tools.tree;
  2.  
  3. import sun.tools.asm.Assembler;
  4. import sun.tools.java.Environment;
  5. import sun.tools.java.Type;
  6.  
  7. public class IntegerExpression extends ConstantExpression {
  8.    int value;
  9.  
  10.    IntegerExpression(int var1, int var2, Type var3, int var4) {
  11.       super(var1, var2, var3);
  12.       this.value = var4;
  13.    }
  14.  
  15.    public boolean fitsType(Environment var1, Context var2, Type var3) {
  16.       switch (var3.getTypeCode()) {
  17.          case 1:
  18.             if (this.value != (byte)this.value) {
  19.                return false;
  20.             }
  21.  
  22.             return true;
  23.          case 2:
  24.             if (this.value != (char)this.value) {
  25.                return false;
  26.             }
  27.  
  28.             return true;
  29.          case 3:
  30.             if (this.value != (short)this.value) {
  31.                return false;
  32.             }
  33.  
  34.             return true;
  35.          default:
  36.             return super.fitsType(var1, var2, var3);
  37.       }
  38.    }
  39.  
  40.    public Object getValue() {
  41.       return new Integer(this.value);
  42.    }
  43.  
  44.    public boolean equals(int var1) {
  45.       return this.value == var1;
  46.    }
  47.  
  48.    public boolean equalsDefault() {
  49.       return this.value == 0;
  50.    }
  51.  
  52.    public void codeValue(Environment var1, Context var2, Assembler var3) {
  53.       var3.add(super.where, 18, new Integer(this.value));
  54.    }
  55. }
  56.