gnu.expr
Class Declaration

java.lang.Object
  extended by gnu.expr.Declaration
All Implemented Interfaces:
SourceLocator, org.xml.sax.Locator

public class Declaration
extends java.lang.Object
implements SourceLocator

The static information associated with a local variable binding.


Field Summary
 Declaration base
          If non-null, field is relative to base.
 ScopeExp context
           
static int EARLY_INIT
          Initialize in <init>/<clinit> rather than in run/$run$>.
static int EXPORT_SPECIFIED
           
static int EXTERNAL_ACCESS
          This flag bit is set if this can be be acceessed from other modules.
 Field field
           
static int FIELD_OR_METHOD
          True if this is a field or method in a class definition.
 ApplyExp firstCall
          List of ApplyExp where this declaration is the function called.
protected  int flags
           
protected  int id
          Unique id number, to ease print-outs and debugging.
static int IS_ALIAS
           
static int IS_CONSTANT
           
static int IS_DYNAMIC
           
static int IS_IMPORTED
           
static int IS_NAMESPACE_PREFIX
          Set if this declares a namespace prefix (as in XML namespaces).
static int IS_SINGLE_VALUE
           
static int IS_SYNTAX
           
static int IS_UNKNOWN
           
static int MODULE_REFERENCE
          A reference to a module instance.
static int NONSTATIC_SPECIFIED
           
static int NOT_DEFINING
          Set if this is just a declaration, not a definition.
static int PACKAGE_ACCESS
           
static int PRIVATE_ACCESS
           
static java.lang.String PRIVATE_PREFIX
          This prefix is used in field names for a declaration that has both EXTERNAL_ACCESS and IS_PRIVATE set.
static int PRIVATE_SPECIFIED
           
static int PROTECTED_ACCESS
           
static int PUBLIC_ACCESS
           
static int STATIC_SPECIFIED
           
protected  Type type
           
static int TYPE_SPECIFIED
           
protected  Expression typeExp
           
protected  Expression value
          If non-null, the single expression used to set this variable.
 
Constructor Summary
protected Declaration()
           
  Declaration(java.lang.Object name)
           
  Declaration(java.lang.Object name, Field field)
           
  Declaration(java.lang.Object s, Type type)
           
  Declaration(Variable var)
           
 
Method Summary
 Variable allocateVariable(CodeAttr code)
           
 void compileStore(Compilation comp)
           
static Declaration followAliases(Declaration decl)
           
 short getAccessFlags(short defaultFlags)
           
 boolean getCanCall()
           
 boolean getCanRead()
           
 boolean getCanWrite()
           
 int getCode()
           
 int getColumnNumber()
          Return current column number.
 java.lang.Object getConstantValue()
          If getValue() is a constant, return the constant value, otherwise null.
 ScopeExp getContext()
          Return the ScopeExp that contains (declares) this Declaration.
static Declaration getDeclaration(Named proc)
           
static Declaration getDeclaration(java.lang.Object proc, java.lang.String name)
           
static Declaration getDeclarationFromStatic(java.lang.String cname, java.lang.String fname)
          Create a declaration corresponding to a static field.
static Declaration getDeclarationValueFromStatic(java.lang.String className, java.lang.String fieldName, java.lang.String name)
          Similar to getDeclarationFromStatic, but also do noteValue with the field's value.
 java.lang.String getFileName()
          Normally same as getSystemId.
 boolean getFlag(int flag)
           
 int getLineNumber()
          Get the line number of (the start of) this Expression.
 java.lang.String getName()
           
 java.lang.String getPublicId()
           
 java.lang.Object getSymbol()
           
 java.lang.String getSystemId()
           
 Type getType()
           
 Expression getTypeExp()
           
 Expression getValue()
          The value of this Declaration, if known.
 Variable getVariable()
           
 boolean ignorable()
          True if we never need to access this declaration.
 boolean isAlias()
           
 boolean isFluid()
          True if this is a fluid binding (in a FluidLetExp).
 boolean isIndirectBinding()
          True if the value of the variable is the contents of a Location.
 boolean isLexical()
           
 boolean isNamespaceDecl()
           
 boolean isPrivate()
           
 boolean isProcedureDecl()
           
 boolean isPublic()
           
 boolean isSimple()
           
 boolean isStableSourceLocation()
          True if position is unlikely to change.
 boolean isStatic()
           
 boolean isThisParameter()
          Is this an implicit 'this' parameter?
static boolean isUnknown(Declaration decl)
           
 void load(AccessExp access, int flags, Compilation comp, Target target)
           
 void makeField(ClassType frameType, Compilation comp, Expression value)
           
 void makeField(Compilation comp, Expression value)
           
 boolean needsContext()
          If we need a 'context' supplied from a ReferenceExp or 'this.
 boolean needsExternalAccess()
           
 boolean needsInit()
          Does this variable need to be initialized or is default ok
 Declaration nextDecl()
           
 void noteValue(Expression value)
           
 void printInfo(OutPort out)
           
 void printInfo(java.lang.StringBuffer sbuf)
           
 void pushIndirectBinding(Compilation comp)
          Create a Location object, given that isIndirectBinding().
 void setAlias(boolean flag)
           
 void setCanCall()
           
 void setCanCall(boolean called)
           
 void setCanRead()
           
 void setCanRead(boolean read)
           
 void setCanWrite()
           
 void setCanWrite(boolean written)
           
 void setCode(int code)
           
 void setFile(java.lang.String filename)
           
 void setFlag(boolean setting, int flag)
           
 void setFlag(int flag)
           
 void setFluid(boolean fluid)
           
 void setIndirectBinding(boolean indirectBinding)
          Note that the value of the variable is the contents of a Location.
 void setLine(int lineno)
           
 void setLine(int lineno, int colno)
           
 void setLocation(SourceLocator location)
           
 void setName(java.lang.Object symbol)
           
 void setNext(Declaration next)
           
 void setPrivate(boolean isPrivate)
           
 void setProcedureDecl(boolean val)
           
 void setSimple(boolean b)
           
 void setSymbol(java.lang.Object symbol)
           
 void setSyntax()
           
 void setType(Type type)
           
 void setTypeExp(Expression typeExp)
           
 void setValue(Expression value)
          Set the value assoociated with this Declaration.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected int id
Unique id number, to ease print-outs and debugging. If negative, a code to specify a builtin function.


context

public ScopeExp context

type

protected Type type

typeExp

protected Expression typeExp

base

public Declaration base
If non-null, field is relative to base. If IS_FLUID, base points to IS_UNKNOWN Symbol.


field

public Field field

value

protected Expression value
If non-null, the single expression used to set this variable. If the variable can be set more than once, then value is null.


PRIVATE_PREFIX

public static final java.lang.String PRIVATE_PREFIX
This prefix is used in field names for a declaration that has both EXTERNAL_ACCESS and IS_PRIVATE set.

See Also:
Constant Field Values

IS_ALIAS

public static final int IS_ALIAS
See Also:
Constant Field Values

NOT_DEFINING

public static final int NOT_DEFINING
Set if this is just a declaration, not a definition.

See Also:
Constant Field Values

EXPORT_SPECIFIED

public static final int EXPORT_SPECIFIED
See Also:
Constant Field Values

STATIC_SPECIFIED

public static final int STATIC_SPECIFIED
See Also:
Constant Field Values

NONSTATIC_SPECIFIED

public static final int NONSTATIC_SPECIFIED
See Also:
Constant Field Values

TYPE_SPECIFIED

public static final int TYPE_SPECIFIED
See Also:
Constant Field Values

IS_CONSTANT

public static final int IS_CONSTANT
See Also:
Constant Field Values

IS_SYNTAX

public static final int IS_SYNTAX
See Also:
Constant Field Values

IS_UNKNOWN

public static final int IS_UNKNOWN
See Also:
Constant Field Values

IS_IMPORTED

public static final int IS_IMPORTED
See Also:
Constant Field Values

IS_SINGLE_VALUE

public static final int IS_SINGLE_VALUE
See Also:
Constant Field Values

EXTERNAL_ACCESS

public static final int EXTERNAL_ACCESS
This flag bit is set if this can be be acceessed from other modules. Ignored unless PRIVATE. Used when an exported macro references a non-exported name.

See Also:
Constant Field Values

FIELD_OR_METHOD

public static final int FIELD_OR_METHOD
True if this is a field or method in a class definition.

See Also:
Constant Field Values

IS_NAMESPACE_PREFIX

public static final int IS_NAMESPACE_PREFIX
Set if this declares a namespace prefix (as in XML namespaces).

See Also:
Constant Field Values

PRIVATE_ACCESS

public static final int PRIVATE_ACCESS
See Also:
Constant Field Values

PRIVATE_SPECIFIED

public static final int PRIVATE_SPECIFIED
See Also:
Constant Field Values

PROTECTED_ACCESS

public static final int PROTECTED_ACCESS
See Also:
Constant Field Values

PUBLIC_ACCESS

public static final int PUBLIC_ACCESS
See Also:
Constant Field Values

PACKAGE_ACCESS

public static final int PACKAGE_ACCESS
See Also:
Constant Field Values

IS_DYNAMIC

public static final int IS_DYNAMIC
See Also:
Constant Field Values

EARLY_INIT

public static final int EARLY_INIT
Initialize in <init>/<clinit> rather than in run/$run$>.

See Also:
Constant Field Values

MODULE_REFERENCE

public static final int MODULE_REFERENCE
A reference to a module instance.

See Also:
Constant Field Values

flags

protected int flags

firstCall

public ApplyExp firstCall
List of ApplyExp where this declaration is the function called. The applications are chained using their nextCall fields. The chain is not built if STATIC_SPECIFIED.

Constructor Detail

Declaration

protected Declaration()

Declaration

public Declaration(Variable var)

Declaration

public Declaration(java.lang.Object name)

Declaration

public Declaration(java.lang.Object s,
                   Type type)

Declaration

public Declaration(java.lang.Object name,
                   Field field)
Method Detail

setCode

public void setCode(int code)

getCode

public int getCode()

getTypeExp

public final Expression getTypeExp()

getType

public final Type getType()

setType

public final void setType(Type type)

setTypeExp

public final void setTypeExp(Expression typeExp)

getName

public final java.lang.String getName()

setName

public final void setName(java.lang.Object symbol)

getSymbol

public final java.lang.Object getSymbol()

setSymbol

public final void setSymbol(java.lang.Object symbol)

nextDecl

public final Declaration nextDecl()

setNext

public final void setNext(Declaration next)

getVariable

public Variable getVariable()

isSimple

public final boolean isSimple()

setSimple

public final void setSimple(boolean b)

setSyntax

public final void setSyntax()

getContext

public final ScopeExp getContext()
Return the ScopeExp that contains (declares) this Declaration.


load

public void load(AccessExp access,
                 int flags,
                 Compilation comp,
                 Target target)

compileStore

public void compileStore(Compilation comp)

getValue

public final Expression getValue()
The value of this Declaration, if known. Usually the expression used to initialize the Declaration, or null if the Declaration can be assigned a different value after initialization. Note that this is the semantic value: If the INDIRECT_LOCATION is set, then getValue is the value after de-referencing the resulting Location. An exception is if isAlias(); in that case getValue() is an expression yielding a Location which needs to be de-referenced to get this Declaration's actual value.


setValue

public final void setValue(Expression value)
Set the value assoociated with this Declaration. Most code should use noteValue instead.


getConstantValue

public final java.lang.Object getConstantValue()
If getValue() is a constant, return the constant value, otherwise null.


needsExternalAccess

public final boolean needsExternalAccess()

needsContext

public final boolean needsContext()
If we need a 'context' supplied from a ReferenceExp or 'this.


getFlag

public final boolean getFlag(int flag)

setFlag

public final void setFlag(boolean setting,
                          int flag)

setFlag

public final void setFlag(int flag)

isPublic

public final boolean isPublic()

isPrivate

public final boolean isPrivate()

setPrivate

public final void setPrivate(boolean isPrivate)

getAccessFlags

public short getAccessFlags(short defaultFlags)

isAlias

public final boolean isAlias()

setAlias

public final void setAlias(boolean flag)

isFluid

public final boolean isFluid()
True if this is a fluid binding (in a FluidLetExp).


setFluid

public final void setFluid(boolean fluid)

isProcedureDecl

public final boolean isProcedureDecl()

setProcedureDecl

public final void setProcedureDecl(boolean val)

isNamespaceDecl

public final boolean isNamespaceDecl()

isIndirectBinding

public final boolean isIndirectBinding()
True if the value of the variable is the contents of a Location.

See Also:
INDIRECT_BINDING

setIndirectBinding

public final void setIndirectBinding(boolean indirectBinding)
Note that the value of the variable is the contents of a Location.

See Also:
INDIRECT_BINDING

getCanRead

public final boolean getCanRead()

setCanRead

public final void setCanRead(boolean read)

setCanRead

public final void setCanRead()

getCanCall

public final boolean getCanCall()

setCanCall

public final void setCanCall(boolean called)

setCanCall

public final void setCanCall()

getCanWrite

public final boolean getCanWrite()

setCanWrite

public final void setCanWrite(boolean written)

setCanWrite

public final void setCanWrite()

isThisParameter

public final boolean isThisParameter()
Is this an implicit 'this' parameter?


ignorable

public boolean ignorable()
True if we never need to access this declaration.


needsInit

public boolean needsInit()
Does this variable need to be initialized or is default ok


isStatic

public boolean isStatic()

isLexical

public final boolean isLexical()

isUnknown

public static final boolean isUnknown(Declaration decl)

noteValue

public void noteValue(Expression value)

pushIndirectBinding

public void pushIndirectBinding(Compilation comp)
Create a Location object, given that isIndirectBinding(). Assume the initial value is already pushed on the stack; leaves initialized Location object on stack.


allocateVariable

public final Variable allocateVariable(CodeAttr code)

setLocation

public final void setLocation(SourceLocator location)

setFile

public final void setFile(java.lang.String filename)

setLine

public final void setLine(int lineno,
                          int colno)

setLine

public final void setLine(int lineno)

getFileName

public final java.lang.String getFileName()
Description copied from interface: SourceLocator
Normally same as getSystemId.

Specified by:
getFileName in interface SourceLocator

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in interface SourceLocator
Specified by:
getPublicId in interface org.xml.sax.Locator

getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface SourceLocator
Specified by:
getSystemId in interface org.xml.sax.Locator

getLineNumber

public final int getLineNumber()
Get the line number of (the start of) this Expression. The "first" line is line 1; unknown is -1.

Specified by:
getLineNumber in interface SourceLocator
Specified by:
getLineNumber in interface org.xml.sax.Locator

getColumnNumber

public final int getColumnNumber()
Description copied from interface: SourceLocator
Return current column number. The "first" column is column 1; unknown is -1.

Specified by:
getColumnNumber in interface SourceLocator
Specified by:
getColumnNumber in interface org.xml.sax.Locator

isStableSourceLocation

public boolean isStableSourceLocation()
Description copied from interface: SourceLocator
True if position is unlikely to change. True for an expression but not an input file.

Specified by:
isStableSourceLocation in interface SourceLocator

printInfo

public void printInfo(OutPort out)

printInfo

public void printInfo(java.lang.StringBuffer sbuf)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

followAliases

public static Declaration followAliases(Declaration decl)

makeField

public void makeField(Compilation comp,
                      Expression value)

makeField

public void makeField(ClassType frameType,
                      Compilation comp,
                      Expression value)

getDeclarationFromStatic

public static Declaration getDeclarationFromStatic(java.lang.String cname,
                                                   java.lang.String fname)
Create a declaration corresponding to a static field.

Parameters:
cname - name of class containing field
fname - name of static field

getDeclarationValueFromStatic

public static Declaration getDeclarationValueFromStatic(java.lang.String className,
                                                        java.lang.String fieldName,
                                                        java.lang.String name)
Similar to getDeclarationFromStatic, but also do noteValue with the field's value.


getDeclaration

public static Declaration getDeclaration(Named proc)

getDeclaration

public static Declaration getDeclaration(java.lang.Object proc,
                                         java.lang.String name)