gnu.expr

Class Declaration

public class Declaration extends Object implements SourceLocator

The static information associated with a local variable binding.
Field Summary
Declarationbase
If non-null, field is relative to base.
ScopeExpcontext
static intEARLY_INIT
Initialize in {@code }/{@code } rather than in {@code run}/{@code $run$}>.
static intEXPORT_SPECIFIED
static intEXTERNAL_ACCESS
This flag bit is set if this can be be acceessed from other modules.
Fieldfield
ApplyExpfirstCall
List of ApplyExp where this declaration is the function called.
protected intflags
static intFIELD_OR_METHOD
True if this is a field or method in a class definition.
protected intid
Unique id number, to ease print-outs and debugging.
static intIS_ALIAS
static intIS_CONSTANT
static intIS_DYNAMIC
static intIS_IMPORTED
static intIS_NAMESPACE_PREFIX
Set if this declares a namespace prefix (as in XML namespaces).
static intIS_SINGLE_VALUE
static intIS_SYNTAX
static intIS_UNKNOWN
static intMODULE_REFERENCE
A reference to a module instance.
static intNONSTATIC_SPECIFIED
static intNOT_DEFINING
Set if this is just a declaration, not a definition.
static intPACKAGE_ACCESS
static intPRIVATE_ACCESS
static StringPRIVATE_PREFIX
This prefix is used in field names for a declaration that has both EXTERNAL_ACCESS and IS_PRIVATE set.
static intPRIVATE_SPECIFIED
static intPROTECTED_ACCESS
static intPUBLIC_ACCESS
static intSTATIC_SPECIFIED
protected Typetype
protected ExpressiontypeExp
static intTYPE_SPECIFIED
protected Expressionvalue
If non-null, the single expression used to set this variable.
Constructor Summary
protected Declaration()
Declaration(Variable var)
Declaration(Object name)
Declaration(Object s, Type type)
Declaration(Object name, Field field)
Method Summary
VariableallocateVariable(CodeAttr code)
voidcompileStore(Compilation comp)
static DeclarationfollowAliases(Declaration decl)
shortgetAccessFlags(short defaultFlags)
booleangetCanCall()
booleangetCanRead()
booleangetCanWrite()
intgetCode()
intgetColumnNumber()
ObjectgetConstantValue()
If getValue() is a constant, return the constant value, otherwise null.
ScopeExpgetContext()
Return the ScopeExp that contains (declares) this Declaration.
static DeclarationgetDeclaration(Named proc)
static DeclarationgetDeclaration(Object proc, String name)
static DeclarationgetDeclarationFromStatic(String cname, String fname)
Create a declaration corresponding to a static field.
static DeclarationgetDeclarationValueFromStatic(String className, String fieldName, String name)
Similar to {@code getDeclarationFromStatic}, but also do {@code noteValue} with the field's value.
StringgetFileName()
booleangetFlag(int flag)
intgetLineNumber()
Get the line number of (the start of) this Expression.
StringgetName()
StringgetPublicId()
ObjectgetSymbol()
StringgetSystemId()
TypegetType()
ExpressiongetTypeExp()
ExpressiongetValue()
The value of this Declaration, if known.
VariablegetVariable()
booleanignorable()
True if we never need to access this declaration.
booleanisAlias()
booleanisFluid()
True if this is a fluid binding (in a FluidLetExp).
booleanisIndirectBinding()
True if the value of the variable is the contents of a Location.
booleanisLexical()
booleanisNamespaceDecl()
booleanisPrivate()
booleanisProcedureDecl()
booleanisPublic()
booleanisSimple()
booleanisStableSourceLocation()
booleanisStatic()
booleanisThisParameter()
Is this an implicit 'this' parameter?
static booleanisUnknown(Declaration decl)
voidload(AccessExp access, int flags, Compilation comp, Target target)
voidmakeField(Compilation comp, Expression value)
voidmakeField(ClassType frameType, Compilation comp, Expression value)
booleanneedsContext()
If we need a 'context' supplied from a ReferenceExp or 'this.
booleanneedsExternalAccess()
booleanneedsInit()
Does this variable need to be initialized or is default ok
DeclarationnextDecl()
voidnoteValue(Expression value)
voidprintInfo(OutPort out)
voidprintInfo(StringBuffer sbuf)
voidpushIndirectBinding(Compilation comp)
Create a Location object, given that isIndirectBinding().
voidsetAlias(boolean flag)
voidsetCanCall(boolean called)
voidsetCanCall()
voidsetCanRead(boolean read)
voidsetCanRead()
voidsetCanWrite(boolean written)
voidsetCanWrite()
voidsetCode(int code)
voidsetFile(String filename)
voidsetFlag(boolean setting, int flag)
voidsetFlag(int flag)
voidsetFluid(boolean fluid)
voidsetIndirectBinding(boolean indirectBinding)
Note that the value of the variable is the contents of a Location.
voidsetLine(int lineno, int colno)
voidsetLine(int lineno)
voidsetLocation(SourceLocator location)
voidsetName(Object symbol)
voidsetNext(Declaration next)
voidsetPrivate(boolean isPrivate)
voidsetProcedureDecl(boolean val)
voidsetSimple(boolean b)
voidsetSymbol(Object symbol)
voidsetSyntax()
voidsetType(Type type)
voidsetTypeExp(Expression typeExp)
voidsetValue(Expression value)
Set the value assoociated with this Declaration.
StringtoString()

Field Detail

base

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

context

public ScopeExp context

EARLY_INIT

public static final int EARLY_INIT
Initialize in {@code }/{@code } rather than in {@code run}/{@code $run$}>.

EXPORT_SPECIFIED

public static final int EXPORT_SPECIFIED

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.

field

public Field field

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.

flags

protected int flags

FIELD_OR_METHOD

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

id

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

IS_ALIAS

public static final int IS_ALIAS

IS_CONSTANT

public static final int IS_CONSTANT

IS_DYNAMIC

public static final int IS_DYNAMIC

IS_IMPORTED

public static final int IS_IMPORTED

IS_NAMESPACE_PREFIX

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

IS_SINGLE_VALUE

public static final int IS_SINGLE_VALUE

IS_SYNTAX

public static final int IS_SYNTAX

IS_UNKNOWN

public static final int IS_UNKNOWN

MODULE_REFERENCE

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

NONSTATIC_SPECIFIED

public static final int NONSTATIC_SPECIFIED

NOT_DEFINING

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

PACKAGE_ACCESS

public static final int PACKAGE_ACCESS

PRIVATE_ACCESS

public static final int PRIVATE_ACCESS

PRIVATE_PREFIX

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

PRIVATE_SPECIFIED

public static final int PRIVATE_SPECIFIED

PROTECTED_ACCESS

public static final int PROTECTED_ACCESS

PUBLIC_ACCESS

public static final int PUBLIC_ACCESS

STATIC_SPECIFIED

public static final int STATIC_SPECIFIED

type

protected Type type

typeExp

protected Expression typeExp

TYPE_SPECIFIED

public static final int TYPE_SPECIFIED

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.

Constructor Detail

Declaration

protected Declaration()

Declaration

public Declaration(Variable var)

Declaration

public Declaration(Object name)

Declaration

public Declaration(Object s, Type type)

Declaration

public Declaration(Object name, Field field)

Method Detail

allocateVariable

public final Variable allocateVariable(CodeAttr code)

compileStore

public void compileStore(Compilation comp)

followAliases

public static Declaration followAliases(Declaration decl)

getAccessFlags

public short getAccessFlags(short defaultFlags)

getCanCall

public final boolean getCanCall()

getCanRead

public final boolean getCanRead()

getCanWrite

public final boolean getCanWrite()

getCode

public int getCode()

getColumnNumber

public final int getColumnNumber()

getConstantValue

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

getContext

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

getDeclaration

public static Declaration getDeclaration(Named proc)

getDeclaration

public static Declaration getDeclaration(Object proc, String name)

getDeclarationFromStatic

public static Declaration getDeclarationFromStatic(String cname, 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(String className, String fieldName, String name)
Similar to {@code getDeclarationFromStatic}, but also do {@code noteValue} with the field's value.

getFileName

public final String getFileName()

getFlag

public final boolean getFlag(int flag)

getLineNumber

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

getName

public final String getName()

getPublicId

public String getPublicId()

getSymbol

public final Object getSymbol()

getSystemId

public String getSystemId()

getType

public final Type getType()

getTypeExp

public final Expression getTypeExp()

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.

getVariable

public Variable getVariable()

ignorable

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

isAlias

public final boolean isAlias()

isFluid

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

isIndirectBinding

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

See Also: INDIRECT_BINDING

isLexical

public final boolean isLexical()

isNamespaceDecl

public final boolean isNamespaceDecl()

isPrivate

public final boolean isPrivate()

isProcedureDecl

public final boolean isProcedureDecl()

isPublic

public final boolean isPublic()

isSimple

public final boolean isSimple()

isStableSourceLocation

public boolean isStableSourceLocation()

isStatic

public boolean isStatic()

isThisParameter

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

isUnknown

public static final boolean isUnknown(Declaration decl)

load

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

makeField

public void makeField(Compilation comp, Expression value)

makeField

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

needsContext

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

needsExternalAccess

public final boolean needsExternalAccess()

needsInit

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

nextDecl

public final Declaration nextDecl()

noteValue

public void noteValue(Expression value)

printInfo

public void printInfo(OutPort out)

printInfo

public void printInfo(StringBuffer sbuf)

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.

setAlias

public final void setAlias(boolean flag)

setCanCall

public final void setCanCall(boolean called)

setCanCall

public final void setCanCall()

setCanRead

public final void setCanRead(boolean read)

setCanRead

public final void setCanRead()

setCanWrite

public final void setCanWrite(boolean written)

setCanWrite

public final void setCanWrite()

setCode

public void setCode(int code)

setFile

public final void setFile(String filename)

setFlag

public final void setFlag(boolean setting, int flag)

setFlag

public final void setFlag(int flag)

setFluid

public final void setFluid(boolean fluid)

setIndirectBinding

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

See Also: INDIRECT_BINDING

setLine

public final void setLine(int lineno, int colno)

setLine

public final void setLine(int lineno)

setLocation

public final void setLocation(SourceLocator location)

setName

public final void setName(Object symbol)

setNext

public final void setNext(Declaration next)

setPrivate

public final void setPrivate(boolean isPrivate)

setProcedureDecl

public final void setProcedureDecl(boolean val)

setSimple

public final void setSimple(boolean b)

setSymbol

public final void setSymbol(Object symbol)

setSyntax

public final void setSyntax()

setType

public final void setType(Type type)

setTypeExp

public final void setTypeExp(Expression typeExp)

setValue

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

toString

public String toString()