Package gnu.expr
Class ReferenceExp
- java.lang.Object
-
- gnu.mapping.PropertySet
-
- gnu.mapping.Procedure
-
- gnu.expr.Expression
-
- gnu.expr.AccessExp
-
- gnu.expr.ReferenceExp
-
- All Implemented Interfaces:
gnu.kawa.format.Printable
,Named
,SourceLocator
,SourceLocator
,Locator
- Direct Known Subclasses:
ThisExp
public class ReferenceExp extends AccessExp
This class represents a variable reference (an identifier).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALLOCATE_ON_STACK_LAST
static int
DONT_DEREFERENCE
static int
PROCEDURE_NAME
static int
TYPE_NAME
Flag indicates a reference to a type name.-
Fields inherited from class gnu.expr.AccessExp
NEXT_AVAIL_FLAG, PREFER_BINDING2
-
Fields inherited from class gnu.expr.Expression
applyMethodExpression, flags, noExpressions, type, VALIDATED
-
Fields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKey
-
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
-
Constructor Summary
Constructors Constructor Description ReferenceExp(Declaration binding)
ReferenceExp(ReferenceExp old)
ReferenceExp(Object symbol)
ReferenceExp(Object symbol, Declaration binding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(CallContext ctx)
Evaluate the expression.protected Type
calculateType()
void
compile(Compilation comp, Target target)
protected Expression
deepCopy(IdentityHashTable mapper)
boolean
getDontDereference()
boolean
isProcedureName()
True if this identifier appears in "function call position".boolean
isSingleValue()
boolean
isUnknown()
protected boolean
mustCompile()
void
print(gnu.kawa.io.OutPort ps)
void
setDontDereference(boolean setting)
void
setProcedureName(boolean setting)
Note if this identifier appears in "function call position".boolean
side_effects()
True if evaluating may have side-effects.String
toString()
Expression
validateApply(ApplyExp exp, InlineCalls visitor, Type required, Declaration decl)
Apply inlining transformations on a given ApplyExp.Object
valueIfConstant()
Return value if it is constant, or null if non-constant or unknown.protected <R,D>
Rvisit(ExpVisitor<R,D> visitor, D d)
-
Methods inherited from class gnu.expr.AccessExp
contextDecl, getBinding, getName, getSimpleName, getSymbol, setBinding, setContextDecl, string_name
-
Methods inherited from class gnu.expr.Expression
applyMethodExpression, checkLiteralKeyword, compile, compile, compileWithPosition, compileWithPosition, deepCopy, deepCopy, deepCopy, eval, eval, getColumnNumber, getEndColumn, getEndLine, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getStartColumn, getStartLine, getSystemId, getType, getTypeRaw, isStableSourceLocation, makeWhile, maybeSetLine, neverReturns, numArgs, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLine, setLocation, setType, visitChildren
-
Methods inherited from class gnu.mapping.Procedure
apply0, apply1, apply2, apply3, apply4, applyL, applyN, applyToConsumerDefault, applyToObjectDefault, checkArgCount, checkBadCode, getApplyMethod, getApplyToConsumerMethod, getApplyToObjectMethod, getReturnType, getSetter, getSourceLocation, isSideEffectFree, lookupApplyHandle, maxArgs, maxArgs, minArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation
-
Methods inherited from class gnu.mapping.PropertySet
getProperty, removeProperty, setName, setProperty, setProperty, setSymbol
-
-
-
-
Field Detail
-
DONT_DEREFERENCE
public static final int DONT_DEREFERENCE
- See Also:
- Constant Field Values
-
PROCEDURE_NAME
public static final int PROCEDURE_NAME
- See Also:
- Constant Field Values
-
TYPE_NAME
public static final int TYPE_NAME
Flag indicates a reference to a type name.- See Also:
- Constant Field Values
-
ALLOCATE_ON_STACK_LAST
public static final int ALLOCATE_ON_STACK_LAST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReferenceExp
public ReferenceExp(Object symbol)
-
ReferenceExp
public ReferenceExp(Object symbol, Declaration binding)
-
ReferenceExp
public ReferenceExp(Declaration binding)
-
ReferenceExp
public ReferenceExp(ReferenceExp old)
-
-
Method Detail
-
getDontDereference
public final boolean getDontDereference()
-
setDontDereference
public final void setDontDereference(boolean setting)
-
isUnknown
public final boolean isUnknown()
-
isProcedureName
public final boolean isProcedureName()
True if this identifier appears in "function call position". If so, it should be interpreted as a function name, which makes a difference for languages (like Common Lisp) that have two name spaces.
-
setProcedureName
public final void setProcedureName(boolean setting)
Note if this identifier appears in "function call position".
-
mustCompile
protected boolean mustCompile()
- Specified by:
mustCompile
in classExpression
-
valueIfConstant
public final Object valueIfConstant()
Description copied from class:Expression
Return value if it is constant, or null if non-constant or unknown.- Overrides:
valueIfConstant
in classExpression
-
apply
public void apply(CallContext ctx) throws Throwable
Description copied from class:Expression
Evaluate the expression. This is named apply rather than eval so it is compatible with the full-tail-call calling convention, and we can stash an Expression in CallContext's proc field. FIXME - are we making use of this?- Overrides:
apply
in classExpression
- Throws:
Throwable
-
compile
public void compile(Compilation comp, Target target)
- Specified by:
compile
in classExpression
-
deepCopy
protected Expression deepCopy(IdentityHashTable mapper)
- Overrides:
deepCopy
in classExpression
-
visit
protected <R,D> R visit(ExpVisitor<R,D> visitor, D d)
- Overrides:
visit
in classExpression
-
validateApply
public Expression validateApply(ApplyExp exp, InlineCalls visitor, Type required, Declaration decl)
Description copied from class:Expression
Apply inlining transformations on a given ApplyExp. Assumes the ApplyExp's function is this expression, or can be optimized to this expression.- Overrides:
validateApply
in classExpression
- Parameters:
exp
- an application whose function expression can be simplified to this expression.visitor
- the context for the current inlining passdecl
- if non-null, a Declaration bound to this expression.- Returns:
- an Expression equivalent to the passed-in exp.
-
print
public void print(gnu.kawa.io.OutPort ps)
- Specified by:
print
in classExpression
-
calculateType
protected Type calculateType()
- Overrides:
calculateType
in classExpression
-
isSingleValue
public boolean isSingleValue()
- Overrides:
isSingleValue
in classExpression
-
side_effects
public boolean side_effects()
Description copied from class:Expression
True if evaluating may have side-effects.- Overrides:
side_effects
in classExpression
-
toString
public String toString()
- Overrides:
toString
in classExpression
-
-