com.sun.tools.javac.code
Class Symbol.VarSymbol

java.lang.Object
  extended by com.sun.tools.javac.code.Symbol
      extended by com.sun.tools.javac.code.Symbol.VarSymbol
All Implemented Interfaces:
Element, VariableElement
Enclosing class:
Symbol

public static class Symbol.VarSymbol
extends Symbol
implements VariableElement

A class for variable symbols


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.tools.javac.code.Symbol
Symbol.ClassSymbol, Symbol.Completer, Symbol.CompletionFailure, Symbol.DelegatedSymbol, Symbol.Level, Symbol.MethodSymbol, Symbol.OperatorSymbol, Symbol.PackageSymbol, Symbol.TypeSymbol, Symbol.VarSymbol, Symbol.Visitor<R,P>
 
Field Summary
 int adr
          The variable's address.
private  java.lang.Object data
          The variable's constant value, if this is a constant.
 int pos
          The variable's declaration position.
 
Fields inherited from class com.sun.tools.javac.code.Symbol
attributes_field, completer, erasure_field, flags_field, kind, level, name, owner, type
 
Constructor Summary
Symbol.VarSymbol(long flags, Name name, Type type, Symbol owner)
          Construct a variable symbol, given its flags, name, type and owner.
 
Method Summary
<R,P> R
accept(ElementVisitor<R,P> v, P p)
          Applies a visitor to this element.
<R,P> R
accept(Symbol.Visitor<R,P> v, P p)
           
 Symbol asMemberOf(Type site, Types types)
          The (variable or method) symbol seen as a member of given class type`site' (this might change the symbol's type).
 Symbol.VarSymbol clone(Symbol newOwner)
          Clone this symbol with new owner.
 java.lang.Object getConstantValue()
          Returns the value of this variable if this is a final field initialized to a compile-time constant.
 java.lang.Object getConstValue()
           
 ElementKind getKind()
          Returns the kind of this element.
 boolean isExceptionParameter()
           
 void setData(java.lang.Object data)
           
 void setLazyConstValue(Env<AttrContext> env, Log log, Attr attr, JCTree.JCExpression initializer)
           
 java.lang.String toString()
          The Java source which this symbol represents.
 
Methods inherited from class com.sun.tools.javac.code.Symbol
addParentLevel, asType, attribute, complete, enclClass, erasure, exists, externalType, flags, flatName, getAnnotation, getAnnotationMirrors, getEnclosedElements, getEnclosingElement, getLevel, getModifiers, getQualifiedName, getSimpleName, getTypeParameters, hasOuterInstance, isConstructor, isEnclosedBy, isInheritedIn, isInner, isInterface, isLocal, isMemberOf, isStatic, isSubClass, location, location, members, outermostClass, overrides, packge, removeParentLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.lang.model.element.Element
asType, equals, getAnnotation, getAnnotationMirrors, getEnclosedElements, getEnclosingElement, getModifiers, getSimpleName, hashCode
 

Field Detail

pos

public int pos
The variable's declaration position.


adr

public int adr
The variable's address. Used for different purposes during flow analysis, translation and code generation. Flow analysis: If this is a blank final or local variable, its sequence number. Translation: If this is a private field, its access number. Code generation: If this is a local variable, its logical slot number.


data

private java.lang.Object data
The variable's constant value, if this is a constant. Before the constant value is evaluated, it points to an initalizer environment. If this is not a constant, it can be used for other stuff.

Constructor Detail

Symbol.VarSymbol

public Symbol.VarSymbol(long flags,
                        Name name,
                        Type type,
                        Symbol owner)
Construct a variable symbol, given its flags, name, type and owner.

Method Detail

clone

public Symbol.VarSymbol clone(Symbol newOwner)
Clone this symbol with new owner.

Overrides:
clone in class Symbol

toString

public java.lang.String toString()
Description copied from class: Symbol
The Java source which this symbol represents. A description of this symbol; overrides Object.

Overrides:
toString in class Symbol

asMemberOf

public Symbol asMemberOf(Type site,
                         Types types)
Description copied from class: Symbol
The (variable or method) symbol seen as a member of given class type`site' (this might change the symbol's type). This is used exclusively for producing diagnostics.

Overrides:
asMemberOf in class Symbol

getKind

public ElementKind getKind()
Description copied from interface: Element
Returns the kind of this element.

Specified by:
getKind in interface Element
Overrides:
getKind in class Symbol
Returns:
the kind of this element

accept

public <R,P> R accept(ElementVisitor<R,P> v,
                      P p)
Description copied from interface: Element
Applies a visitor to this element.

Specified by:
accept in interface Element
Type Parameters:
R - the return type of the visitor's methods
P - the type of the additional parameter to the visitor's methods
Parameters:
v - the visitor operating on this element
p - additional parameter to the visitor
Returns:
a visitor-specified result

getConstantValue

public java.lang.Object getConstantValue()
Description copied from interface: VariableElement
Returns the value of this variable if this is a final field initialized to a compile-time constant. Returns null otherwise. The value will be of a primitive type or a String. If the value is of a primitive type, it is wrapped in the appropriate wrapper class (such as Integer).

Note that not all final fields will have constant values. In particular, enum constants are not considered to be compile-time constants. To have a constant value, a field's type must be either a primitive type or String.

Specified by:
getConstantValue in interface VariableElement
Returns:
the value of this variable if this is a final field initialized to a compile-time constant, or null otherwise
See Also:
Elements.getConstantExpression(Object)

setLazyConstValue

public void setLazyConstValue(Env<AttrContext> env,
                              Log log,
                              Attr attr,
                              JCTree.JCExpression initializer)

isExceptionParameter

public boolean isExceptionParameter()

getConstValue

public java.lang.Object getConstValue()

setData

public void setData(java.lang.Object data)

accept

public <R,P> R accept(Symbol.Visitor<R,P> v,
                      P p)
Overrides:
accept in class Symbol