org.aspectj.compiler.base.ast
Class LiteralExpr

java.lang.Object
  extended byorg.aspectj.compiler.base.CompilerObject
      extended byorg.aspectj.compiler.base.ast.ASTObject
          extended byorg.aspectj.compiler.base.ast.Expr
              extended byorg.aspectj.compiler.base.ast.JavaExpr
                  extended byorg.aspectj.compiler.base.ast.LiteralExpr
All Implemented Interfaces:
MajPrimaryExpr
Direct Known Subclasses:
BooleanLiteralExpr, NumericLiteralExpr, StringLiteralExpr

public abstract class LiteralExpr
extends JavaExpr
implements MajPrimaryExpr


Field Summary
protected  Type type
           
protected  java.lang.String value
           
 
Fields inherited from class org.aspectj.compiler.base.ast.ASTObject
dummySource, parent, sourceLocation
 
Constructor Summary
protected LiteralExpr()
           
protected LiteralExpr(SourceLocation source)
           
  LiteralExpr(SourceLocation location, Type _type, java.lang.String _value)
           
  LiteralExpr(Type _type, java.lang.String _value)
           
 
Method Summary
abstract  void addConstant(org.aspectj.compiler.base.bcg.FieldBuilder fb)
           
 boolean canBeCopied()
          Can this expression be copied without changing the semantics of the program.
protected  void cgEffect(org.aspectj.compiler.base.bcg.CodeBuilder cb)
          Evaluates the expression in a context where its value is unnecessary (i.e., from ExprStmt, or in a FieldAccessExpr when the field is static but there is an expression there nonetheless).
protected  void cgValue(org.aspectj.compiler.base.bcg.CodeBuilder cb, Type castTo)
          Leaves the value of this expression on the stack and casts the value to castTo.
 Type discoverType()
           
 boolean getBooleanValue()
           
 java.lang.String getDefaultDisplayName()
           
 double getDoubleValue()
           
 float getFloatValue()
           
 int getIntValue()
           
 long getLongValue()
           
abstract  java.lang.String getStringValue()
          Return a string representing the Literal expr, NOT to be used for unparsing purposes, but rather the string that would be returned by the String.valueOf(char) method.
 Type getType()
           
 java.lang.String getValue()
           
 boolean isUltimatelyLiteral()
          Is this expression ultimately a literal expression.
 Expr makeReference()
          When called for the first time will return an expression that may involve computation and state changes.
 void setType(Type _type)
           
 void setValue(java.lang.String _value)
           
 void unparse(org.aspectj.compiler.base.CodeWriter writer)
           
 
Methods inherited from class org.aspectj.compiler.base.ast.Expr
assertType, cgBuffer, cgTest, cgValue, checkSpec, cleanup, isAssignableTo, isConstantFalse, isConstantTrue, isConstantZero, isInConstructorCallExpr, isInExprStmt, isLegalStmt, isMethodConvertableTo, makeQualifiedThis, postCopy, showOperatorTypeError, showOperatorTypeError, walkCleanup, walkFrameLoc
 
Methods inherited from class org.aspectj.compiler.base.ast.ASTObject
addComment, buildAccessMethod, checkNoSharing, clearComment, clearParent, contains, containsTypes, copy, copyWalk, display, fixAccessPost, fixAST, fromSource, getAST, getBeginColumn, getBeginLine, getBytecodeType, getBytecodeTypeDec, getChildAt, getChildCount, getChildNameAt, getComment, getCompilationUnit, getDeclaringType, getEnclosingCodeDec, getEnclosingDec, getEndColumn, getEndLine, getEndPosition, getFormalComment, getLexicalType, getOutermostBytecodeType, getOutermostLexicalType, getParent, getSourceDirectoryName, getSourceFile, getSourceFileName, getSourceLocation, getStartPosition, hasLegalProtectedAccess, hasSource, hasSourceLocation, implementMixin, indexOf, inStaticContext, isLanguageVisible, isLeaf, isSynthetic, makeChild, makeChild, postAssignmentCheck, postCleanup, postFixAST, postImplementMixin, postInnerAccess, postInnerInfo, postLift, postMove, postScope, postThreading, preAssignmentCheck, preCopy, preIntroduction, preLift, preMove, preScope, preThreading, remove, remove, removeChildAt, replaceWith, setChildAt, setFormalComment, setParent, setParents, setSource, setSourceLocation, setSyntheticSource, showError, showMessage, showTypeError, showWarning, toShortString, toString, unparse, walk, walkAnalysis, walkAssignmentCheck, walkFlow, walkForwardReference, walkInnerInfo, walkMemberMunger, walkScope
 
Methods inherited from class org.aspectj.compiler.base.CompilerObject
getCompiler, getOptions, getTypeManager, getWorld
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.aspectj.compiler.base.ast.MajPrimaryExpr
unparse
 

Field Detail

type

protected Type type

value

protected java.lang.String value
Constructor Detail

LiteralExpr

public LiteralExpr(SourceLocation location,
                   Type _type,
                   java.lang.String _value)

LiteralExpr

protected LiteralExpr(SourceLocation source)

LiteralExpr

public LiteralExpr(Type _type,
                   java.lang.String _value)

LiteralExpr

protected LiteralExpr()
Method Detail

getStringValue

public abstract java.lang.String getStringValue()
Return a string representing the Literal expr, NOT to be used for unparsing purposes, but rather the string that would be returned by the String.valueOf(char) method.


getIntValue

public int getIntValue()

getLongValue

public long getLongValue()

getFloatValue

public float getFloatValue()

getDoubleValue

public double getDoubleValue()

getBooleanValue

public boolean getBooleanValue()

discoverType

public Type discoverType()
Specified by:
discoverType in class Expr

makeReference

public Expr makeReference()
Description copied from class: Expr
When called for the first time will return an expression that may involve computation and state changes. When called on an Expr returned from this method, it is guaranteed that no further computation will occur. For Exprs that are already references, this is copied identity. For others, this will return a ReferenceExpr.

Overrides:
makeReference in class Expr

canBeCopied

public boolean canBeCopied()
Description copied from class: Expr
Can this expression be copied without changing the semantics of the program.

Overrides:
canBeCopied in class Expr

isUltimatelyLiteral

public boolean isUltimatelyLiteral()
Description copied from class: Expr
Is this expression ultimately a literal expression. The only difference between this and canBeCopied is that 'this' is NOT ultimatelyLiteral, and that a cast is only copiable if its expression is ultimatelyLiteral.

Overrides:
isUltimatelyLiteral in class Expr

unparse

public void unparse(org.aspectj.compiler.base.CodeWriter writer)
             throws java.io.IOException
Overrides:
unparse in class ASTObject
Throws:
java.io.IOException

cgValue

protected void cgValue(org.aspectj.compiler.base.bcg.CodeBuilder cb,
                       Type castTo)
Leaves the value of this expression on the stack and casts the value to castTo. We do a better job than for regular expressions since literal expressions can be statically cast.

Overrides:
cgValue in class Expr

cgEffect

protected void cgEffect(org.aspectj.compiler.base.bcg.CodeBuilder cb)
Description copied from class: Expr
Evaluates the expression in a context where its value is unnecessary (i.e., from ExprStmt, or in a FieldAccessExpr when the field is static but there is an expression there nonetheless). May self-call Expr.cgValue(CodeBuilder).

Overrides:
cgEffect in class Expr

addConstant

public abstract void addConstant(org.aspectj.compiler.base.bcg.FieldBuilder fb)

getType

public Type getType()
Overrides:
getType in class Expr

setType

public void setType(Type _type)
Overrides:
setType in class Expr

getValue

public java.lang.String getValue()

setValue

public void setValue(java.lang.String _value)

getDefaultDisplayName

public java.lang.String getDefaultDisplayName()
Overrides:
getDefaultDisplayName in class Expr