1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.AssignmentCheckerPass; 28 import org.aspectj.compiler.base.*; 29 import org.aspectj.compiler.crosscuts.AccessFixer; 30 31 import java.util.*; 32 33 import org.aspectj.compiler.base.bcg.CodeBuilder; 34 35 39 public class ShiftAssignExpr extends AssignExpr { 40 41 public Type discoverType() { 42 Type ty1 = lhs.getType(); 43 Type ty2 = rhs.getType(); 44 if (! ((ty1 instanceof IntegralType) 45 && (ty2 instanceof IntegralType))) { 46 showOperatorTypeError(op, ty1, ty2); 47 } 48 return ty1; 49 } 50 51 protected void cgValue(CodeBuilder cb) { 54 cgValueEffect(cb, true); 55 } 56 protected void cgEffect(CodeBuilder cb) { 57 cgValueEffect(cb, false); 58 } 59 private void cgValueEffect(CodeBuilder cb, boolean needsValue) { 60 AssignableExpr lhs = getLhs(); 61 Expr rhs = getRhs(); 62 String op = getOp(); 63 Type lhsTy = lhs.getType(); 64 lhs.cgLvalue(cb); 65 lhs.cgDupLvalue(cb); 66 lhs.cgLtoRvalue(cb); 67 rhs.cgValue(cb, getTypeManager().intType); 68 lhsTy.emitShiftOp(cb, op); 69 if (lhsTy instanceof IntishType) { 70 ((IntishType)lhsTy).emitCastFromInt(cb); 71 } 72 if (needsValue) { 73 lhs.cgDupRvalue(cb); 74 } 75 lhs.cgAssignment(cb); 76 } 77 78 80 public ShiftAssignExpr(SourceLocation location, AssignableExpr _lhs, String _op, Expr _rhs) { 81 super(location, _lhs, _op, _rhs); 82 83 } 84 protected ShiftAssignExpr(SourceLocation source) { 85 super(source); 86 } 87 88 public ASTObject copyWalk(CopyWalker walker) { 89 ShiftAssignExpr ret = new ShiftAssignExpr(getSourceLocation()); 90 ret.preCopy(walker, this); 91 if (lhs != null) ret.setLhs( (AssignableExpr)walker.process(lhs) ); 92 ret.op = op; 93 if (rhs != null) ret.setRhs( (Expr)walker.process(rhs) ); 94 return ret; 95 } 96 97 98 public String getDefaultDisplayName() { 99 return "ShiftAssignExpr(op: "+op+")"; 100 } 101 102 } 104 | Popular Tags |