public class Declaration extends SourceLocator.Simple
Modifier and Type | Class and Description |
---|---|
static class |
Declaration.ValueSource |
SourceLocator.Simple
Modifier and Type | Field and Description |
---|---|
static long |
ABSTRACT_ACCESS |
static long |
ALLOCATE_ON_STACK
Allocate variable on JVM stack as an optimization.
|
Declaration |
base
If non-null, field is relative to base.
|
static long |
CLASS_ACCESS_FLAGS |
ScopeExp |
context |
static long |
DONT_COPY |
static int |
EARLY_INIT
Initialize in
<init> /<clinit>
rather than in run /$run$ . |
static long |
ENUM_ACCESS |
static int |
EXPORT_SPECIFIED |
static int |
EXTERNAL_ACCESS
This flag bit is set if this can be be accessed from other modules.
|
static long |
FIELD_ACCESS_FLAGS |
static int |
FIELD_OR_METHOD
True if this is a field or method in a class definition.
|
static long |
FINAL_ACCESS |
ApplyExp |
firstCall
List of ApplyExp where this declaration is the function called.
|
protected long |
flags |
Method |
getterMethod |
protected int |
id
Unique id number, to ease print-outs and debugging.
|
static int |
IS_ALIAS |
static int |
IS_CAPTURED |
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 long |
IS_PARAMETER |
static long |
IS_REST_PARAMETER |
static int |
IS_SINGLE_VALUE |
static long |
IS_SUPPLIED_PARAMETER
Is this a supplied-parameter variable?
If IS_SUPPLIED_PARAMETER is true and IS_PARAMETER is false
then this is a boolean variable which reports if the previous parameter
was provided by the argument list, rather than defaulted.
|
static int |
IS_SYNTAX |
static int |
IS_UNKNOWN |
static long |
KEYWORDS_OK
Applies to a 'rest' parameter if it can match keywords.
|
static long |
MAYBE_UNINITIALIZED_ACCESS |
static long |
METHOD_ACCESS_FLAGS |
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 long |
PATTERN_NESTED
True for a variable inside a pattern, but not the top of the pattern.
|
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 |
PROCEDURE
True if in the function namespace, for languages that distinguishes them.
|
static int |
PROTECTED_ACCESS |
static int |
PUBLIC_ACCESS |
static long |
SCAN_OWNER |
Method |
setterMethod |
static long |
SKIP_FOR_METHOD_PARAMETER
See parameterForMethod()
|
static int |
STATIC_SPECIFIED |
static long |
STRICTFP_ACCESS |
static long |
SYNCHRONIZED_ACCESS |
static long |
TRANSIENT_ACCESS |
Type |
type
The type of the value of this Declaration.
|
static int |
TYPE_SPECIFIED |
Expression |
typeExp |
static long |
VOLATILE_ACCESS |
filename, position
Constructor and Description |
---|
Declaration(java.lang.Object name) |
Declaration(java.lang.Object name,
Field field) |
Declaration(java.lang.Object name,
Type type) |
Declaration(Variable var) |
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(Expression exp)
Add an annotation to the set of our annotations.
|
void |
addCaller(ApplyExp exp)
Add a call to the list headed by
firstCall . |
Variable |
allocateVariable(CodeAttr code) |
Variable |
allocateVariable(CodeAttr code,
boolean autoPopScope) |
void |
clearCallList()
Clear the list of callers headed by
firstCall . |
void |
compileAnnotations(AttrContainer container,
java.lang.annotation.ElementType etype) |
void |
compileStore(Compilation comp) |
static Declaration |
followAliases(Declaration decl) |
short |
getAccessFlags(short defaultFlags) |
<T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<T> clas) |
Expression |
getAnnotation(int i)
Indexed get of one of the annotations associated with this declaration.
|
AnnotationEntry |
getAnnotation(java.lang.String className) |
boolean |
getCanCall() |
boolean |
getCanRead() |
boolean |
getCanReadOrCall() |
boolean |
getCanWrite() |
int |
getCode() |
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. |
Field |
getField() |
boolean |
getFlag(long flag) |
Type |
getImplementationType() |
Expression |
getInitValue()
Get the "initial value" expression.
|
LambdaExp |
getLambdaValue() |
java.lang.String |
getName() |
int |
getScanNesting()
If non-zero, indicates this names a 'scan' of a sequence.
|
java.lang.Object |
getSymbol() |
Type |
getType() |
Expression |
getTypeExp() |
Expression |
getTypeExpRaw() |
Expression |
getValue()
The value of this
Declaration , if known. |
Expression |
getValueRaw() |
Variable |
getVariable() |
boolean |
hasConstantValue() |
boolean |
hasUnknownValue() |
boolean |
ignorable()
True if we never need to access this declaration.
|
boolean |
inExternalModule(Compilation comp) |
boolean |
isAlias() |
boolean |
isClassField() |
boolean |
isClassMethod() |
boolean |
isCompiletimeConstant() |
boolean |
isFluid()
True if this is a fluid binding (in a FluidLetExp).
|
boolean |
isGuard()
Does this encapsulate a boolean guard expression?
In that case this is an unnamed pseudo-parameter, that matches no
actual arguments but where
getInitValue() is the expression. |
boolean |
isIndirectBinding()
True if the value of the variable is the contents of a Location.
|
boolean |
isLexical() |
boolean |
isModuleLocal() |
boolean |
isNamespaceDecl() |
boolean |
isPrivate() |
boolean |
isProcedureDecl() |
boolean |
isPublic() |
boolean |
isSimple() |
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) |
Type |
loadFieldLocation(Declaration owner,
Compilation comp) |
void |
makeField(ClassType frameType,
Compilation comp,
Expression value) |
void |
makeField(Compilation comp,
Expression value) |
boolean |
mayBeAccessedUninitialized() |
void |
maybeIndirectBinding(Compilation comp) |
void |
maybeSourceName(AttrContainer member,
java.lang.String expName)
Add SourceName annotation to member, if needed.
|
boolean |
needsContext()
If we need a 'context' supplied from a ReferenceExp or 'this.
|
boolean |
needsExternalAccess() |
Declaration |
nextDecl() |
void |
noteValue(Expression value) |
void |
noteValueConstant(java.lang.Object value) |
void |
noteValueFromApply(ApplyExp app,
int index) |
void |
noteValueFromLet(ScopeExp letter) |
void |
noteValueFromSet(SetExp setter) |
void |
noteValueUnknown() |
int |
numAnnotations()
The number of annotations associated with the declaration.
|
boolean |
parameterForMethod()
Is this a parameter for the generated method?
For example if a lambda's parameter is the pattern
[x y]
then there is an anonymous parameter p0 that is the incoming 2-element
sequence plus named parameters x and y . |
boolean |
patchSymbolFromSet()
Set symbol from initializing SetExp.
|
void |
printInfo(gnu.kawa.io.OutPort out) |
void |
printInfo(java.lang.StringBuffer sbuf) |
void |
pushIndirectBinding(Compilation comp)
Create a Location object, given that isIndirectBinding().
|
void |
setAlias(boolean flag) |
void |
setAnnotation(int i,
Expression ann)
Replace one of the annotations associated with this declaration.
|
void |
setCanCall() |
void |
setCanCall(boolean called) |
void |
setCanRead() |
void |
setCanRead(boolean read) |
void |
setCanWrite() |
void |
setCanWrite(boolean written) |
void |
setCode(int code) |
void |
setField(Field field) |
void |
setFlag(boolean setting,
long flag) |
void |
setFlag(long flag) |
void |
setFluid(boolean fluid) |
void |
setIndirectBinding(boolean indirectBinding)
Note that the value of the variable is the contents of a Location.
|
void |
setInitValue(Expression init) |
void |
setName(java.lang.Object symbol) |
void |
setNext(Declaration next) |
void |
setPrivate(boolean isPrivate) |
void |
setProcedureDecl(boolean val) |
void |
setScanNesting(int value) |
void |
setSimple(boolean b) |
void |
setSymbol(java.lang.Object symbol) |
void |
setSyntax() |
void |
setType(Expression typeExp,
Type type) |
void |
setType(Type type) |
void |
setTypeExp(Expression typeExp) |
void |
setValue(Expression value)
Set the value associated with this Declaration.
|
java.lang.String |
toString() |
getColumnNumber, getEndColumn, getEndLine, getFileName, getLineNumber, getPublicId, getStartColumn, getStartLine, getSystemId, isRepl, isStableSourceLocation, setFile, setLine, setLine, setLine, setLocation
protected int id
public ScopeExp context
public Type type
public Expression typeExp
public Declaration base
public Method getterMethod
public Method setterMethod
public static final java.lang.String PRIVATE_PREFIX
public static final int PROCEDURE
public static final int IS_ALIAS
public static final int NOT_DEFINING
public static final int EXPORT_SPECIFIED
public static final int STATIC_SPECIFIED
public static final int NONSTATIC_SPECIFIED
public static final int TYPE_SPECIFIED
public static final int IS_CONSTANT
public static final int IS_SYNTAX
public static final int IS_UNKNOWN
public static final int IS_IMPORTED
public static final int IS_CAPTURED
public static final int IS_SINGLE_VALUE
public static final int EXTERNAL_ACCESS
public static final int FIELD_OR_METHOD
public static final int IS_NAMESPACE_PREFIX
public static final int PRIVATE_ACCESS
public static final int PRIVATE_SPECIFIED
public static final int PROTECTED_ACCESS
public static final int PUBLIC_ACCESS
public static final int PACKAGE_ACCESS
public static final int IS_DYNAMIC
public static final int EARLY_INIT
<init>
/<clinit>
rather than in run
/$run$
.public static final int MODULE_REFERENCE
public static final long VOLATILE_ACCESS
public static final long TRANSIENT_ACCESS
public static final long ENUM_ACCESS
public static final long FINAL_ACCESS
public static final long ABSTRACT_ACCESS
public static final long SYNCHRONIZED_ACCESS
public static final long STRICTFP_ACCESS
public static final long CLASS_ACCESS_FLAGS
public static final long FIELD_ACCESS_FLAGS
public static final long METHOD_ACCESS_FLAGS
public static final long MAYBE_UNINITIALIZED_ACCESS
public static final long ALLOCATE_ON_STACK
public static final long PATTERN_NESTED
public static final long SKIP_FOR_METHOD_PARAMETER
public static final long IS_REST_PARAMETER
public static final long IS_PARAMETER
public static final long IS_SUPPLIED_PARAMETER
public static final long KEYWORDS_OK
public static final long DONT_COPY
public static final long SCAN_OWNER
protected long flags
public ApplyExp firstCall
public Declaration(java.lang.Object name, Type type)
public Declaration(Variable var)
public Declaration(java.lang.Object name)
public Declaration(java.lang.Object name, Field field)
public void setCode(int code)
public int getCode()
public final Expression getTypeExp()
public final Type getType()
public Expression getTypeExpRaw()
public final void setType(Type type)
public final void setTypeExp(Expression typeExp)
public final void setType(Expression typeExp, Type type)
public final java.lang.String getName()
public final void setName(java.lang.Object symbol)
public final java.lang.Object getSymbol()
public final void setSymbol(java.lang.Object symbol)
public final Declaration nextDecl()
public final void setNext(Declaration next)
public Variable getVariable()
public int getScanNesting()
public void setScanNesting(int value)
public final boolean isSimple()
public final void setSimple(boolean b)
public final void setSyntax()
public final ScopeExp getContext()
public Type loadFieldLocation(Declaration owner, Compilation comp)
public void load(AccessExp access, int flags, Compilation comp, Target target)
public void compileStore(Compilation comp)
public boolean isCompiletimeConstant()
public final boolean needsExternalAccess()
public final boolean needsContext()
public final boolean getFlag(long flag)
public final void setFlag(boolean setting, long flag)
public final void setFlag(long flag)
public final boolean isPublic()
public final boolean isPrivate()
public final boolean isModuleLocal()
public final void setPrivate(boolean isPrivate)
public short getAccessFlags(short defaultFlags)
public final boolean isAlias()
public final void setAlias(boolean flag)
public final boolean isFluid()
public final void setFluid(boolean fluid)
public final boolean isProcedureDecl()
public final void setProcedureDecl(boolean val)
public final boolean isClassMethod()
public final boolean isClassField()
public final boolean isNamespaceDecl()
public final boolean parameterForMethod()
[x y]
then there is an anonymous parameter p0 that is the incoming 2-element
sequence plus named parameters x
and y
.
The later two are parameters for the generated method,
but the anonymous p0 is not.public final boolean isIndirectBinding()
INDIRECT_BINDING
public final void setIndirectBinding(boolean indirectBinding)
INDIRECT_BINDING
public void maybeIndirectBinding(Compilation comp)
public boolean inExternalModule(Compilation comp)
public boolean isGuard()
getInitValue()
is the expression.public final boolean getCanRead()
public final void setCanRead(boolean read)
public final void setCanRead()
public final boolean getCanReadOrCall()
public final boolean getCanCall()
public final void setCanCall(boolean called)
public final void setCanCall()
public final boolean getCanWrite()
public final void setCanWrite(boolean written)
public final void setCanWrite()
public final boolean isThisParameter()
public boolean mayBeAccessedUninitialized()
public boolean ignorable()
public boolean isStatic()
public final boolean isLexical()
public static final boolean isUnknown(Declaration decl)
public void addCaller(ApplyExp exp)
firstCall
.public void clearCallList()
firstCall
.public int numAnnotations()
public Expression getAnnotation(int i)
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> clas)
public AnnotationEntry getAnnotation(java.lang.String className)
public void setAnnotation(int i, Expression ann)
public void addAnnotation(Expression exp)
exp
- A constant-valued expression that evaluates to an Annotation.public void compileAnnotations(AttrContainer container, java.lang.annotation.ElementType etype)
public void pushIndirectBinding(Compilation comp)
public Type getImplementationType()
public void printInfo(gnu.kawa.io.OutPort out)
public void printInfo(java.lang.StringBuffer sbuf)
public java.lang.String toString()
toString
in class java.lang.Object
public static Declaration followAliases(Declaration decl)
public void makeField(Compilation comp, Expression value)
public void makeField(ClassType frameType, Compilation comp, Expression value)
public void maybeSourceName(AttrContainer member, java.lang.String expName)
public static Declaration getDeclarationFromStatic(java.lang.String cname, java.lang.String fname)
cname
- name of class containing fieldfname
- name of static fieldpublic static Declaration getDeclarationValueFromStatic(java.lang.String className, java.lang.String fieldName, java.lang.String name)
getDeclarationFromStatic
,
but also do noteValue
with the field's value.public static Declaration getDeclaration(Named proc)
public static Declaration getDeclaration(java.lang.Object proc, java.lang.String name)
public Expression getInitValue()
public void setInitValue(Expression init)
public boolean hasUnknownValue()
public final Expression getValue()
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.public Expression getValueRaw()
public final void setValue(Expression value)
public final java.lang.Object getConstantValue()
public final boolean hasConstantValue()
public LambdaExp getLambdaValue()
public void noteValue(Expression value)
public void noteValueConstant(java.lang.Object value)
public void noteValueUnknown()
public void noteValueFromSet(SetExp setter)
public void noteValueFromLet(ScopeExp letter)
public void noteValueFromApply(ApplyExp app, int index)
public boolean patchSymbolFromSet()
public Field getField()
public void setField(Field field)