home *** CD-ROM | disk | FTP | other *** search
- package sun.tools.tree;
-
- import java.io.PrintStream;
- import java.util.Hashtable;
- import sun.tools.asm.Assembler;
- import sun.tools.java.CompilerError;
- import sun.tools.java.Constants;
- import sun.tools.java.Environment;
- import sun.tools.java.Type;
-
- public abstract class AssignOpExpression extends BinaryAssignExpression {
- protected Type itype;
- final int NOINC = Integer.MAX_VALUE;
-
- public AssignOpExpression(int var1, int var2, Expression var3, Expression var4) {
- super(var1, var2, var3, var4);
- }
-
- final void selectType(Environment var1, Context var2, int var3) {
- Type var4 = null;
- switch (super.op) {
- case 5:
- if (super.left.type == Type.tString) {
- super.type = this.itype = Type.tString;
- return;
- }
- case 2:
- case 3:
- case 4:
- case 6:
- if ((var3 & 128) != 0) {
- this.itype = Type.tDouble;
- } else if ((var3 & 64) != 0) {
- this.itype = Type.tFloat;
- } else if ((var3 & 32) != 0) {
- this.itype = Type.tLong;
- } else {
- this.itype = Type.tInt;
- }
- break;
- case 7:
- case 8:
- case 9:
- var4 = Type.tInt;
- if ((var3 & 32) != 0) {
- this.itype = Type.tLong;
- } else {
- this.itype = Type.tInt;
- }
- break;
- case 10:
- case 11:
- case 12:
- if ((var3 & 1) != 0) {
- this.itype = Type.tBoolean;
- } else if ((var3 & 32) != 0) {
- this.itype = Type.tLong;
- } else {
- this.itype = Type.tInt;
- }
- break;
- default:
- throw new CompilerError("Bad assignOp type: " + super.op);
- }
-
- if (var4 == null) {
- var4 = this.itype;
- }
-
- super.right = ((Node)this).convert(var1, var2, var4, super.right);
- super.type = super.left.type;
- }
-
- int getIncrement() {
- if (super.left.op == 60 && super.type.isType(4) && super.right.op == 65 && (super.op == 5 || super.op == 6) && ((IdentifierExpression)super.left).field.isLocal()) {
- int var1 = ((IntExpression)super.right).value;
- if (super.op == 6) {
- var1 = -var1;
- }
-
- if (var1 == (short)var1) {
- return var1;
- }
- }
-
- return Integer.MAX_VALUE;
- }
-
- public Vset checkValue(Environment var1, Context var2, Vset var3, Hashtable var4) {
- var3 = super.left.checkAssignOp(var1, var2, var3, var4, this);
- var3 = super.right.checkValue(var1, var2, var3, var4);
- int var5 = super.left.type.getTypeMask() | super.right.type.getTypeMask();
- if ((var5 & 8192) != 0) {
- return var3;
- } else {
- this.selectType(var1, var2, var5);
- if (!super.type.isType(13)) {
- ((Node)this).convert(var1, var2, this.itype, super.left);
- }
-
- return var3;
- }
- }
-
- public Expression inlineValue(Environment var1, Context var2) {
- super.left = super.left.inlineValue(var1, var2);
- super.right = super.right.inlineValue(var1, var2);
- return this;
- }
-
- public Expression copyInline(Context var1) {
- AssignOpExpression var2 = (AssignOpExpression)((Node)this).clone();
- var2.left = super.left.copyInline(var1);
- var2.right = super.right.copyInline(var1);
- return var2;
- }
-
- public int costInline(int var1, Environment var2, Context var3) {
- return this.getIncrement() != Integer.MAX_VALUE ? 2 : 3 + super.costInline(var1, var2, var3);
- }
-
- void code(Environment var1, Context var2, Assembler var3, boolean var4) {
- int var5 = this.getIncrement();
- if (var5 != Integer.MAX_VALUE) {
- int var8 = ((LocalField)((IdentifierExpression)super.left).field).number;
- int[] var7 = new int[]{var8, var5};
- var3.add(super.where, 132, var7);
- if (var4) {
- super.left.codeValue(var1, var2, var3);
- }
-
- } else {
- int var6 = super.left.codeLValue(var1, var2, var3);
- ((Expression)this).codeDup(var1, var2, var3, var6, 0);
- super.left.codeLoad(var1, var2, var3);
- ((Expression)this).codeConversion(var1, var2, var3, super.left.type, this.itype);
- super.right.codeValue(var1, var2, var3);
- ((BinaryExpression)this).codeOperation(var1, var2, var3);
- ((Expression)this).codeConversion(var1, var2, var3, this.itype, super.type);
- if (var4) {
- ((Expression)this).codeDup(var1, var2, var3, super.type.stackSize(), var6);
- }
-
- super.left.codeStore(var1, var2, var3);
- }
- }
-
- public void codeValue(Environment var1, Context var2, Assembler var3) {
- this.code(var1, var2, var3, true);
- }
-
- public void code(Environment var1, Context var2, Assembler var3) {
- this.code(var1, var2, var3, false);
- }
-
- public void print(PrintStream var1) {
- var1.print("(" + Constants.opNames[super.op] + " ");
- super.left.print(var1);
- var1.print(" ");
- super.right.print(var1);
- var1.print(")");
- }
- }
-