1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.JavaCompiler; 28 29 import org.aspectj.compiler.base.bcg.FieldBuilder; 30 import org.aspectj.compiler.base.bcg.CodeBuilder; 31 import org.aspectj.compiler.base.bcg.Label; 32 33 34 38 public class DoubleLiteralExpr extends NumericLiteralExpr { 39 40 public int getIntValue() { return (int)doubleValue; } 41 public long getLongValue() { return (long)doubleValue; } 42 public float getFloatValue() { return (float)doubleValue; } 43 public String getStringValue() { return "" + doubleValue; } 44 45 public DoubleLiteralExpr(SourceLocation source, double _doubleValue) { 46 this(source, source.getCompiler().getTypeManager().doubleType, createUsefulString(_doubleValue), _doubleValue); 47 } 48 49 private static String createUsefulString(double d) { 50 if (Double.isNaN(d)) { 51 return "(0.0 / 0.0)"; 52 } else if (Double.isInfinite(d)) { 53 return d > 0 ? "(1.0 / 0.0)" : "(-1.0 / 0.0)"; 54 } else { 55 return d + "d"; 56 } 57 } 58 59 protected void cgValue(CodeBuilder cb) { 62 cb.emitDoubleConstant(doubleValue); 63 } 64 public void addConstant(FieldBuilder fb) { 65 fb.setConstantValue(doubleValue); 66 } 67 public boolean isConstantZero() { return doubleValue == 0.0d; } 68 70 protected double doubleValue; 72 public double getDoubleValue() { return doubleValue; } 73 public void setDoubleValue(double _doubleValue) { doubleValue = _doubleValue; } 74 75 public DoubleLiteralExpr(SourceLocation location, Type _type, String _value, double _doubleValue) { 76 super(location, _type, _value); 77 setDoubleValue(_doubleValue); 78 } 79 protected DoubleLiteralExpr(SourceLocation source) { 80 super(source); 81 } 82 83 public ASTObject copyWalk(CopyWalker walker) { 84 DoubleLiteralExpr ret = new DoubleLiteralExpr(getSourceLocation()); 85 ret.preCopy(walker, this); 86 ret.type = type; 87 ret.value = value; 88 ret.doubleValue = doubleValue; 89 return ret; 90 } 91 92 93 public String getDefaultDisplayName() { 94 return "DoubleLiteralExpr(type: "+type+", "+"value: "+value+", "+"doubleValue: "+doubleValue+")"; 95 } 96 97 } 99 | Popular Tags |