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 / UnaryExpression.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  3.7 KB  |  138 lines

  1. package sun.tools.tree;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.Hashtable;
  5. import sun.tools.java.CompilerError;
  6. import sun.tools.java.Constants;
  7. import sun.tools.java.Environment;
  8. import sun.tools.java.Type;
  9.  
  10. public class UnaryExpression extends Expression {
  11.    Expression right;
  12.  
  13.    UnaryExpression(int var1, int var2, Type var3, Expression var4) {
  14.       super(var1, var2, var3);
  15.       this.right = var4;
  16.    }
  17.  
  18.    public Expression order() {
  19.       if (((Expression)this).precedence() > this.right.precedence()) {
  20.          UnaryExpression var1 = (UnaryExpression)this.right;
  21.          this.right = var1.right;
  22.          var1.right = this.order();
  23.          return var1;
  24.       } else {
  25.          return this;
  26.       }
  27.    }
  28.  
  29.    void selectType(Environment var1, Context var2, int var3) {
  30.       throw new CompilerError("selectType: " + Constants.opNames[super.op]);
  31.    }
  32.  
  33.    public Vset checkValue(Environment var1, Context var2, Vset var3, Hashtable var4) {
  34.       var3 = this.right.checkValue(var1, var2, var3, var4);
  35.       int var5 = this.right.type.getTypeMask();
  36.       this.selectType(var1, var2, var5);
  37.       if ((var5 & 8192) == 0 && super.type.isType(13)) {
  38.          var1.error(super.where, "invalid.arg", Constants.opNames[super.op]);
  39.       }
  40.  
  41.       return var3;
  42.    }
  43.  
  44.    public boolean isConstant() {
  45.       switch (super.op) {
  46.          case 35:
  47.          case 36:
  48.          case 37:
  49.          case 38:
  50.          case 55:
  51.          case 56:
  52.             return this.right.isConstant();
  53.          default:
  54.             return false;
  55.       }
  56.    }
  57.  
  58.    Expression eval(int var1) {
  59.       return this;
  60.    }
  61.  
  62.    Expression eval(long var1) {
  63.       return this;
  64.    }
  65.  
  66.    Expression eval(float var1) {
  67.       return this;
  68.    }
  69.  
  70.    Expression eval(double var1) {
  71.       return this;
  72.    }
  73.  
  74.    Expression eval(boolean var1) {
  75.       return this;
  76.    }
  77.  
  78.    Expression eval(String var1) {
  79.       return this;
  80.    }
  81.  
  82.    Expression eval() {
  83.       switch (this.right.op) {
  84.          case 61:
  85.             return this.eval(((BooleanExpression)this.right).value);
  86.          case 62:
  87.          case 63:
  88.          case 64:
  89.          case 65:
  90.             return this.eval(((IntegerExpression)this.right).value);
  91.          case 66:
  92.             return this.eval(((LongExpression)this.right).value);
  93.          case 67:
  94.             return this.eval(((FloatExpression)this.right).value);
  95.          case 68:
  96.             return this.eval(((DoubleExpression)this.right).value);
  97.          case 69:
  98.             return this.eval(((StringExpression)this.right).value);
  99.          default:
  100.             return this;
  101.       }
  102.    }
  103.  
  104.    public Expression inline(Environment var1, Context var2) {
  105.       return this.right.inline(var1, var2);
  106.    }
  107.  
  108.    public Expression inlineValue(Environment var1, Context var2) {
  109.       this.right = this.right.inlineValue(var1, var2);
  110.  
  111.       try {
  112.          return this.eval().simplify();
  113.       } catch (ArithmeticException var3) {
  114.          var1.error(super.where, "arithmetic.exception");
  115.          return this;
  116.       }
  117.    }
  118.  
  119.    public Expression copyInline(Context var1) {
  120.       UnaryExpression var2 = (UnaryExpression)((Node)this).clone();
  121.       if (this.right != null) {
  122.          var2.right = this.right.copyInline(var1);
  123.       }
  124.  
  125.       return var2;
  126.    }
  127.  
  128.    public int costInline(int var1, Environment var2, Context var3) {
  129.       return 1 + this.right.costInline(var1, var2, var3);
  130.    }
  131.  
  132.    public void print(PrintStream var1) {
  133.       var1.print("(" + Constants.opNames[super.op] + " ");
  134.       this.right.print(var1);
  135.       var1.print(")");
  136.    }
  137. }
  138.