gnu.expr

Class Declaration

Implemented Interfaces:
org.xml.sax.Locator, SourceLocator

public class Declaration
extends java.lang.Object
implements SourceLocator

The static information associated with a local variable binding.

Field Summary

static int
EARLY_INIT
Initialize in / 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.
static int
FIELD_OR_METHOD
True if this is a field or method in a class definition.
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 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
static int
TYPE_SPECIFIED
Declaration
base
If non-null, field is relative to base.
ScopeExp
context
Field
field
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.
protected Type
type
protected Expression
typeExp
protected Expression
value
If non-null, the single expression used to set this variable.

Constructor Summary

Declaration()
Declaration(Object name)
Declaration(Object name, Field field)
Declaration(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.
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(Object proc, String name)
static Declaration
getDeclaration(Named proc)
static Declaration
getDeclarationFromStatic(String cname, String fname)
Create a declaration corresponding to a static field.
static Declaration
getDeclarationValueFromStatic(String className, String fieldName, String name)
Similar to getDeclarationFromStatic, but also do noteValue with the field's value.
String
getFileName()
Normally same as getSystemId.
boolean
getFlag(int flag)
int
getLineNumber()
Get the line number of (the start of) this Expression.
String
getName()
String
getPublicId()
Object
getSymbol()
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(StringBuffer sbuf)
void
printInfo(OutPort out)
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(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(Object symbol)
void
setNext(Declaration next)
void
setPrivate(boolean isPrivate)
void
setProcedureDecl(boolean val)
void
setSimple(boolean b)
void
setSymbol(Object symbol)
void
setSyntax()
void
setType(Type type)
void
setTypeExp(Expression typeExp)
void
setValue(Expression value)
Set the value assoociated with this Declaration.
String
toString()

Field Details

EARLY_INIT

public static final int EARLY_INIT
Initialize in / rather than in run/$run$>.
Field Value:
536870912

EXPORT_SPECIFIED

public static final int EXPORT_SPECIFIED
Field Value:
1024

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 Value:
524288

FIELD_OR_METHOD

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

IS_ALIAS

public static final int IS_ALIAS
Field Value:
256

IS_CONSTANT

public static final int IS_CONSTANT
Field Value:
16384

IS_DYNAMIC

public static final int IS_DYNAMIC
Field Value:
268435456

IS_IMPORTED

public static final int IS_IMPORTED
Field Value:
131072

IS_NAMESPACE_PREFIX

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

IS_SINGLE_VALUE

public static final int IS_SINGLE_VALUE
Field Value:
262144

IS_SYNTAX

public static final int IS_SYNTAX
Field Value:
32768

IS_UNKNOWN

public static final int IS_UNKNOWN
Field Value:
65536

MODULE_REFERENCE

public static final int MODULE_REFERENCE
A reference to a module instance.
Field Value:
1073741824

NONSTATIC_SPECIFIED

public static final int NONSTATIC_SPECIFIED
Field Value:
4096

NOT_DEFINING

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

PACKAGE_ACCESS

public static final int PACKAGE_ACCESS
Field Value:
134217728

PRIVATE_ACCESS

public static final int PRIVATE_ACCESS
Field Value:
16777216

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
Field Value:
16777216

PROTECTED_ACCESS

public static final int PROTECTED_ACCESS
Field Value:
33554432

PUBLIC_ACCESS

public static final int PUBLIC_ACCESS
Field Value:
67108864

STATIC_SPECIFIED

public static final int STATIC_SPECIFIED
Field Value:
2048

TYPE_SPECIFIED

public static final int TYPE_SPECIFIED
Field Value:
8192

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

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

id

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

type

protected Type type

typeExp

protected Expression typeExp

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 Details

Declaration

protected Declaration()

Declaration

public Declaration(Object name)

Declaration

public Declaration(Object name,
                   Field field)

Declaration

public Declaration(Object s,
                   Type type)

Declaration

public Declaration(Variable var)

Method Details

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()
Return current column number. The "first" column is column 1; unknown is -1.
Specified by:
getColumnNumber in interface SourceLocator

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(Object proc,
                                         String name)

getDeclaration

public static Declaration getDeclaration(Named proc)

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 getDeclarationFromStatic, but also do noteValue with the field's value.

getFileName

public final String getFileName()
Normally same as getSystemId.
Specified by:
getFileName in interface SourceLocator

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.
Specified by:
getLineNumber in interface SourceLocator

getName

public final String getName()

getPublicId

public String getPublicId()
Specified by:
getPublicId in interface SourceLocator

getSymbol

public final Object getSymbol()

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface SourceLocator

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.

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()
True if position is unlikely to change. True for an expression but not an input file.
Specified by:
isStableSourceLocation in interface SourceLocator

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(ClassType frameType,
                      Compilation comp,
                      Expression value)

makeField

public void makeField(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(StringBuffer sbuf)

printInfo

public void printInfo(OutPort out)

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()

setCanCall

public final void setCanCall(boolean called)

setCanRead

public final void setCanRead()

setCanRead

public final void setCanRead(boolean read)

setCanWrite

public final void setCanWrite()

setCanWrite

public final void setCanWrite(boolean written)

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.

setLine

public final void setLine(int lineno)

setLine

public final void setLine(int lineno,
                          int colno)

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()