1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.JavaCompiler; 28 import org.aspectj.compiler.base.CodeWriter; 29 import java.io.IOException ; 30 31 import java.util.*; 32 33 import org.aspectj.compiler.base.bcg.CodeBuilder; 34 import org.aspectj.compiler.base.bcg.Label; 35 36 39 public class ShiftOpExpr extends BinopExpr { 40 41 protected Type discoverType() { 42 Expr rand1 = getRand1(); 43 Expr rand2 = getRand2(); 44 Type ty1 = rand1.getType(); 45 Type ty2 = rand2.getType(); 46 47 if (ty1 instanceof IntegralType && ty2 instanceof IntegralType) { 48 return getTypeManager().unaryNumericPromotion(ty1); 49 } else { 50 showOperatorTypeError(op, ty1, ty2); 51 return getTypeManager().anyType; 52 } 53 } 54 55 protected Type getLiftType() { 56 return getType(); 57 } 58 59 protected LiteralExpr halfFold(Type type, LiteralExpr lit1, LiteralExpr lit2) { 60 return type.foldShiftOp(getOp(), lit1, lit2); 61 } 62 63 66 protected void cgValue(CodeBuilder cb) { 67 Type liftType = getLiftType(); 68 getRand1().cgValue(cb, liftType); 69 getRand2().cgValue(cb, getTypeManager().intType); 70 liftType.emitShiftOp(cb, getOp()); 71 } 72 73 protected void cgOp(CodeBuilder cb, Type ty) { 74 ty.emitShiftOp(cb, getOp()); 75 } 76 77 79 public ShiftOpExpr(SourceLocation location, Expr _rand1, String _op, Expr _rand2) { 80 super(location, _rand1, _op, _rand2); 81 82 } 83 protected ShiftOpExpr(SourceLocation source) { 84 super(source); 85 } 86 87 public ASTObject copyWalk(CopyWalker walker) { 88 ShiftOpExpr ret = new ShiftOpExpr(getSourceLocation()); 89 ret.preCopy(walker, this); 90 if (rand1 != null) ret.setRand1( (Expr)walker.process(rand1) ); 91 ret.op = op; 92 if (rand2 != null) ret.setRand2( (Expr)walker.process(rand2) ); 93 return ret; 94 } 95 96 97 public String getDefaultDisplayName() { 98 return "ShiftOpExpr(op: "+op+")"; 99 } 100 101 } 103 | Popular Tags |