org.aspectj.compiler.base.ast
Class Expr

java.lang.Object
  extended byorg.aspectj.compiler.base.CompilerObject
      extended byorg.aspectj.compiler.base.ast.ASTObject
          extended byorg.aspectj.compiler.base.ast.Expr
Direct Known Subclasses:
AnonymousMethodExpr, ClassExpr, ConstructorCallExpr, EmptyExpr, Exprs, GenTypeName, JavaExpr, ParenExpr, Pcd, ProceedExpr, ReferenceExpr, TypeExpr

public abstract class Expr
extends ASTObject


Field Summary
protected  Type type
           
 
Fields inherited from class org.aspectj.compiler.base.ast.ASTObject
dummySource, parent, sourceLocation
 
Constructor Summary
Expr()
           
Expr(SourceLocation location)
           
 
Method Summary
 void assertType(Type type)
           
 boolean canBeCopied()
          Can this expression be copied without changing the semantics of the program.
protected  void cgBuffer(org.aspectj.compiler.base.bcg.CodeBuilder cb)
          Evaluates the expression in a context where the top of the stack contains a StringBuffer object.
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 cgTest(org.aspectj.compiler.base.bcg.CodeBuilder cb, org.aspectj.compiler.base.bcg.Label tdest, org.aspectj.compiler.base.bcg.Label fdest)
          Evaluates the expression in a context where its value will only be used to branch (from IfStmt, TriTestExpr, WhileStmt, DoStmt, and ForStmt).
protected  void cgValue(org.aspectj.compiler.base.bcg.CodeBuilder cb)
          Leaves the value of this expression on the stack.
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.
 void checkSpec()
           
 void cleanup()
           
protected abstract  Type discoverType()
           
 java.lang.String getDefaultDisplayName()
           
 Type getType()
           
 boolean isAssignableTo(Type type)
          Normally this is a type consideration, but this is overridden by IntLiteralExpr to handle JLS 5.2's requirement that some int literals are assignable to byte, short, and char variables.
 boolean isConstantFalse()
          is this expression the boolean literal value false?
 boolean isConstantTrue()
          is this expression the boolean literal value true?
 boolean isConstantZero()
          is this expression zero or null?
 boolean isInConstructorCallExpr()
          is this an expression in a super or this constructor call?
 boolean isInExprStmt()
           
 boolean isLegalStmt()
           
 boolean isMethodConvertableTo(Type type)
          Method invocation conversion, JLS 5.3, is the same as assignment conversion without the numeric narrowing conversion.
 boolean isUltimatelyLiteral()
          Is this expression ultimately a literal expression.
protected  Expr makeQualifiedThis(Type declaringType)
           
 Expr makeReference()
          When called for the first time will return an expression that may involve computation and state changes.
 ASTObject postCopy(CopyWalker walker, ASTObject oldObject)
           
 void setType(Type type)
           
 void showOperatorTypeError(java.lang.String op, Type a)
           
 void showOperatorTypeError(java.lang.String op, Type a, Type b)
           
 void walkCleanup(org.aspectj.compiler.base.ByteCodeCleanupPass w)
           
 void walkFrameLoc(org.aspectj.compiler.base.FrameLocPass walker)
           
 
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, 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
 

Field Detail

type

protected Type type
Constructor Detail

Expr

public Expr(SourceLocation location)

Expr

public Expr()
Method Detail

isInConstructorCallExpr

public boolean isInConstructorCallExpr()
is this an expression in a super or this constructor call?


isConstantZero

public boolean isConstantZero()
is this expression zero or null?


isConstantTrue

public boolean isConstantTrue()
is this expression the boolean literal value true?


isConstantFalse

public boolean isConstantFalse()
is this expression the boolean literal value false?


isAssignableTo

public boolean isAssignableTo(Type type)
Normally this is a type consideration, but this is overridden by IntLiteralExpr to handle JLS 5.2's requirement that some int literals are assignable to byte, short, and char variables.


isMethodConvertableTo

public final boolean isMethodConvertableTo(Type type)
Method invocation conversion, JLS 5.3, is the same as assignment conversion without the numeric narrowing conversion. So all this does is delegate to the purely type-based Type.isAssignableFrom(org.aspectj.compiler.base.ast.Type) method.


isLegalStmt

public boolean isLegalStmt()

postCopy

public ASTObject postCopy(CopyWalker walker,
                          ASTObject oldObject)
Overrides:
postCopy in class ASTObject

makeQualifiedThis

protected Expr makeQualifiedThis(Type declaringType)

isInExprStmt

public boolean isInExprStmt()

checkSpec

public void checkSpec()
Overrides:
checkSpec in class ASTObject

assertType

public void assertType(Type type)

getType

public Type getType()

setType

public void setType(Type type)

showOperatorTypeError

public void showOperatorTypeError(java.lang.String op,
                                  Type a,
                                  Type b)

showOperatorTypeError

public void showOperatorTypeError(java.lang.String op,
                                  Type a)

makeReference

public Expr makeReference()
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.


canBeCopied

public boolean canBeCopied()
Can this expression be copied without changing the semantics of the program.


isUltimatelyLiteral

public boolean isUltimatelyLiteral()
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.


discoverType

protected abstract Type discoverType()

cleanup

public void cleanup()
Overrides:
cleanup in class ASTObject

walkCleanup

public void walkCleanup(org.aspectj.compiler.base.ByteCodeCleanupPass w)
Overrides:
walkCleanup in class ASTObject

cgValue

protected void cgValue(org.aspectj.compiler.base.bcg.CodeBuilder cb)
Leaves the value of this expression on the stack. May self-call cgTest(CodeBuilder, Label, Label).


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. May self-call cgValue(CodeBuilder).


cgEffect

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). May self-call cgValue(CodeBuilder).


cgBuffer

protected void cgBuffer(org.aspectj.compiler.base.bcg.CodeBuilder cb)
Evaluates the expression in a context where the top of the stack contains a StringBuffer object. The value of this expression is then appended into the StringBuffer. This is used in evaluating the String + operator. May self-call cgValue(CodeBuilder).


cgTest

protected void cgTest(org.aspectj.compiler.base.bcg.CodeBuilder cb,
                      org.aspectj.compiler.base.bcg.Label tdest,
                      org.aspectj.compiler.base.bcg.Label fdest)
Evaluates the expression in a context where its value will only be used to branch (from IfStmt, TriTestExpr, WhileStmt, DoStmt, and ForStmt). The expression, of course, will have boolean type. By default, this evaluates the expression to the stack and then emits an EQ/NE branch bytecode, but many expressions such as tests in BinopExpr will be able to do much better. May self-call cgValue(CodeBuilder).


walkFrameLoc

public void walkFrameLoc(org.aspectj.compiler.base.FrameLocPass walker)
Overrides:
walkFrameLoc in class ASTObject

getDefaultDisplayName

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