1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.JavaCompiler; 28 import org.aspectj.compiler.base.*; 29 30 import org.aspectj.compiler.base.bcg.CodeBuilder; 31 import org.aspectj.compiler.base.bcg.Label; 32 33 abstract public class RefType extends Type { 34 public RefType(JavaCompiler compiler) { 35 super(compiler); 36 } 37 38 final LiteralExpr foldPlusOp(LiteralExpr rand) { return unsupportedFold(); } 40 final LiteralExpr foldMinusOp(LiteralExpr rand) { return unsupportedFold(); } 41 final LiteralExpr foldBitNotOp(LiteralExpr rand) { return unsupportedFold(); } 42 final LiteralExpr foldLogNotOp(LiteralExpr rand) { return unsupportedFold(); } 43 final LiteralExpr foldNumericOp(String op, LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 44 final LiteralExpr foldBitwiseOp(String op, LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 45 final LiteralExpr foldShiftOp(String op, LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 46 final LiteralExpr foldNumericTestOp(String op, LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 47 48 LiteralExpr foldCast(LiteralExpr lit) { return unsupportedFold(); } 50 LiteralExpr foldAddOp(LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 51 LiteralExpr foldEqualityTestOp(String op, LiteralExpr lit1, LiteralExpr lit2) { return unsupportedFold(); } 52 53 void emitCast(CodeBuilder cb, Type castTo) { 55 if (castTo.isAssignableFrom(this)) return; 56 if (!(castTo instanceof RefType)) { 57 System.err.println("can't emit cast for " + this + " to " + castTo); 58 return; 59 } 60 cb.emitCHECKCAST((RefType)castTo); 61 } 62 63 void emitEqualityCompare(CodeBuilder cb, String op, Label t, Label f) { 64 if (op == "==") cb.emitIF_ACMPEQ(t, f); 65 else if (op == "!=") cb.emitIF_ACMPNE(t, f); 66 } 67 68 void emitAload(CodeBuilder cb) { cb.emitAALOAD(); } 69 void emitAstore(CodeBuilder cb) { cb.emitAASTORE(); } 70 void emitNewarray(CodeBuilder cb) { cb.emitANEWARRAY(this); } 71 void emitInstanceof(CodeBuilder cb) { cb.emitINSTANCEOF(this); } 72 73 public void emitLoad(CodeBuilder cb, int loc) { cb.emitALOAD(loc); } 74 public void emitStore(CodeBuilder cb, int loc) { cb.emitASTORE(loc); } 75 public void emitReturn(CodeBuilder cb) { cb.emitARETURN(); } 76 77 String getInternalId() { 78 return getId(); 79 } 80 81 final void emitBitNot(CodeBuilder cb) { unsupportedEmit(); } 83 final void emitLogNot(CodeBuilder cb) { unsupportedEmit(); } 84 final void emitZero(CodeBuilder cb) { unsupportedEmit(); } 85 final void emitOne(CodeBuilder cb) { unsupportedEmit(); } 86 final void emitMinusOne(CodeBuilder cb) { unsupportedEmit(); } 87 final void emitAdd(CodeBuilder cb) { unsupportedEmit(); } 88 final void emitNeg(CodeBuilder cb) { unsupportedEmit(); } 89 final void emitNumericOp(CodeBuilder cb, String op) { unsupportedEmit(); } 90 final void emitBitwiseOp(CodeBuilder cb, String op) { unsupportedEmit(); } 91 final void emitShiftOp(CodeBuilder cb, String op) { unsupportedEmit(); } 92 final void emitNumericCompare(CodeBuilder cb, String op, Label t, Label f) { 93 throw new RuntimeException ("Type " + this + " doesn't support op " + op); 94 } 95 96 99 final boolean hasFastEqualityTestOp() { return true; } 100 final void emitFastEqualityTestOp(CodeBuilder cb, EqualityTestOpExpr e, 101 Label t, Label f) { 102 Expr rand1 = e.getRand1(); 103 Expr rand2 = e.getRand2(); 104 String op = e.getOp(); 105 if (rand1.isConstantZero()) { 106 rand2.cgValue(cb, this); 107 emitEqualityCompare0(cb, op, t, f); 108 } else if (rand2.isConstantZero()) { 109 rand1.cgValue(cb, this); 110 emitEqualityCompare0(cb, op, t, f); 111 } else { 112 rand1.cgValue(cb, this); 113 rand2.cgValue(cb, this); 114 emitEqualityCompare(cb, op, t, f); 115 } 116 } 117 private void emitEqualityCompare0(CodeBuilder cb, String op, Label t, Label f) { 118 if (op == "==") cb.emitIFNULL(t, f); 119 else if (op == "!=") cb.emitIFNONNULL(t, f); 120 } 121 } 122 | Popular Tags |