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

  1. package sun.tools.tree;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.Hashtable;
  5. import sun.tools.asm.Assembler;
  6. import sun.tools.java.CompilerError;
  7. import sun.tools.java.Constants;
  8. import sun.tools.java.Environment;
  9. import sun.tools.java.Type;
  10.  
  11. public abstract class AssignOpExpression extends BinaryAssignExpression {
  12.    protected Type itype;
  13.    final int NOINC = Integer.MAX_VALUE;
  14.  
  15.    public AssignOpExpression(int var1, int var2, Expression var3, Expression var4) {
  16.       super(var1, var2, var3, var4);
  17.    }
  18.  
  19.    final void selectType(Environment var1, Context var2, int var3) {
  20.       Type var4 = null;
  21.       switch (super.op) {
  22.          case 5:
  23.             if (super.left.type == Type.tString) {
  24.                super.type = this.itype = Type.tString;
  25.                return;
  26.             }
  27.          case 2:
  28.          case 3:
  29.          case 4:
  30.          case 6:
  31.             if ((var3 & 128) != 0) {
  32.                this.itype = Type.tDouble;
  33.             } else if ((var3 & 64) != 0) {
  34.                this.itype = Type.tFloat;
  35.             } else if ((var3 & 32) != 0) {
  36.                this.itype = Type.tLong;
  37.             } else {
  38.                this.itype = Type.tInt;
  39.             }
  40.             break;
  41.          case 7:
  42.          case 8:
  43.          case 9:
  44.             var4 = Type.tInt;
  45.             if ((var3 & 32) != 0) {
  46.                this.itype = Type.tLong;
  47.             } else {
  48.                this.itype = Type.tInt;
  49.             }
  50.             break;
  51.          case 10:
  52.          case 11:
  53.          case 12:
  54.             if ((var3 & 1) != 0) {
  55.                this.itype = Type.tBoolean;
  56.             } else if ((var3 & 32) != 0) {
  57.                this.itype = Type.tLong;
  58.             } else {
  59.                this.itype = Type.tInt;
  60.             }
  61.             break;
  62.          default:
  63.             throw new CompilerError("Bad assignOp type: " + super.op);
  64.       }
  65.  
  66.       if (var4 == null) {
  67.          var4 = this.itype;
  68.       }
  69.  
  70.       super.right = ((Node)this).convert(var1, var2, var4, super.right);
  71.       super.type = super.left.type;
  72.    }
  73.  
  74.    int getIncrement() {
  75.       if (super.left.op == 60 && super.type.isType(4) && super.right.op == 65 && (super.op == 5 || super.op == 6) && ((IdentifierExpression)super.left).field.isLocal()) {
  76.          int var1 = ((IntExpression)super.right).value;
  77.          if (super.op == 6) {
  78.             var1 = -var1;
  79.          }
  80.  
  81.          if (var1 == (short)var1) {
  82.             return var1;
  83.          }
  84.       }
  85.  
  86.       return Integer.MAX_VALUE;
  87.    }
  88.  
  89.    public Vset checkValue(Environment var1, Context var2, Vset var3, Hashtable var4) {
  90.       var3 = super.left.checkAssignOp(var1, var2, var3, var4, this);
  91.       var3 = super.right.checkValue(var1, var2, var3, var4);
  92.       int var5 = super.left.type.getTypeMask() | super.right.type.getTypeMask();
  93.       if ((var5 & 8192) != 0) {
  94.          return var3;
  95.       } else {
  96.          this.selectType(var1, var2, var5);
  97.          if (!super.type.isType(13)) {
  98.             ((Node)this).convert(var1, var2, this.itype, super.left);
  99.          }
  100.  
  101.          return var3;
  102.       }
  103.    }
  104.  
  105.    public Expression inlineValue(Environment var1, Context var2) {
  106.       super.left = super.left.inlineValue(var1, var2);
  107.       super.right = super.right.inlineValue(var1, var2);
  108.       return this;
  109.    }
  110.  
  111.    public Expression copyInline(Context var1) {
  112.       AssignOpExpression var2 = (AssignOpExpression)((Node)this).clone();
  113.       var2.left = super.left.copyInline(var1);
  114.       var2.right = super.right.copyInline(var1);
  115.       return var2;
  116.    }
  117.  
  118.    public int costInline(int var1, Environment var2, Context var3) {
  119.       return this.getIncrement() != Integer.MAX_VALUE ? 2 : 3 + super.costInline(var1, var2, var3);
  120.    }
  121.  
  122.    void code(Environment var1, Context var2, Assembler var3, boolean var4) {
  123.       int var5 = this.getIncrement();
  124.       if (var5 != Integer.MAX_VALUE) {
  125.          int var8 = ((LocalField)((IdentifierExpression)super.left).field).number;
  126.          int[] var7 = new int[]{var8, var5};
  127.          var3.add(super.where, 132, var7);
  128.          if (var4) {
  129.             super.left.codeValue(var1, var2, var3);
  130.          }
  131.  
  132.       } else {
  133.          int var6 = super.left.codeLValue(var1, var2, var3);
  134.          ((Expression)this).codeDup(var1, var2, var3, var6, 0);
  135.          super.left.codeLoad(var1, var2, var3);
  136.          ((Expression)this).codeConversion(var1, var2, var3, super.left.type, this.itype);
  137.          super.right.codeValue(var1, var2, var3);
  138.          ((BinaryExpression)this).codeOperation(var1, var2, var3);
  139.          ((Expression)this).codeConversion(var1, var2, var3, this.itype, super.type);
  140.          if (var4) {
  141.             ((Expression)this).codeDup(var1, var2, var3, super.type.stackSize(), var6);
  142.          }
  143.  
  144.          super.left.codeStore(var1, var2, var3);
  145.       }
  146.    }
  147.  
  148.    public void codeValue(Environment var1, Context var2, Assembler var3) {
  149.       this.code(var1, var2, var3, true);
  150.    }
  151.  
  152.    public void code(Environment var1, Context var2, Assembler var3) {
  153.       this.code(var1, var2, var3, false);
  154.    }
  155.  
  156.    public void print(PrintStream var1) {
  157.       var1.print("(" + Constants.opNames[super.op] + " ");
  158.       super.left.print(var1);
  159.       var1.print(" ");
  160.       super.right.print(var1);
  161.       var1.print(")");
  162.    }
  163. }
  164.