1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.FlowCheckerPass; 28 import org.aspectj.compiler.base.JavaCompiler; 29 import org.aspectj.compiler.base.CodeWriter; 30 import java.io.IOException ; 31 32 import org.aspectj.compiler.base.bcg.FieldBuilder; 33 import org.aspectj.compiler.base.bcg.CodeBuilder; 34 import org.aspectj.compiler.base.bcg.Label; 35 36 41 public abstract class LiteralExpr extends Expr { 42 43 44 48 abstract public String getStringValue(); 49 50 public int getIntValue() { return 0; } 52 public long getLongValue() { return 0L; } 53 public float getFloatValue() { return 0.0f; } 54 public double getDoubleValue() { return 0.0; } 55 public boolean getBooleanValue() { return false; } 56 57 public Type discoverType() { 58 return type; 59 } 60 61 public Expr makeReference() { return this; } 62 63 public boolean canBeCopied() { 64 return true; 65 } 66 67 public boolean isUltimatelyLiteral() { 68 return true; 69 } 70 71 public void unparse(CodeWriter writer) throws IOException { 72 writer.write(value); 73 } 74 75 80 protected void cgValue(CodeBuilder cb, Type castTo) { 81 castTo.foldCast(this).cgValue(cb); 82 } 83 84 protected void cgEffect(CodeBuilder cb) { } 85 86 abstract public void addConstant(FieldBuilder fb); 87 88 protected Type type; 90 public Type getType() { return type; } 91 public void setType(Type _type) { type = _type; } 92 93 protected String value; 94 public String getValue() { return value; } 95 public void setValue(String _value) { value = _value; } 96 97 public LiteralExpr(SourceLocation location, Type _type, String _value) { 98 super(location); 99 setType(_type); 100 setValue(_value); 101 } 102 protected LiteralExpr(SourceLocation source) { 103 super(source); 104 } 105 106 107 public String getDefaultDisplayName() { 108 return "LiteralExpr(type: "+type+", "+"value: "+value+")"; 109 } 110 111 } 113 | Popular Tags |