Package gnu.expr
Class SetExp
-
- All Implemented Interfaces:
gnu.kawa.format.Printable
,Named
,SourceLocator
,SourceLocator
,Locator
public class SetExp extends AccessExp
An Expression to set (bind) or define a new value to a named variable.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
-
Field Summary
Fields Modifier and Type Field Description static int
BAD_SHORT
"Failure" return value of canUseInc.static int
DEFINING_FLAG
static int
GLOBAL_FLAG
static int
HAS_VALUE
static int
PROCEDURE
static int
SET_IF_UNBOUND
-
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 SetExp(Declaration decl, Expression val)
SetExp(Object symbol, Expression val)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(CallContext ctx)
Evaluate the expression.protected Type
calculateType()
static int
canUseInc(Expression rhs, Declaration target)
void
compile(Compilation comp, Target target)
boolean
getHasValue()
True if evaluating the SetExp yields the value of the RHS.Expression
getNewValue()
Get the Expression for calculating the new ("right-hand") value.boolean
isDefining()
boolean
isFuncDef()
True if this is a functon definition ("defun").boolean
isSetIfUnbound()
static SetExp
makeDefinition(Declaration decl, Expression val)
static SetExp
makeDefinition(Object symbol, Expression val)
protected boolean
mustCompile()
void
print(gnu.kawa.io.OutPort out)
void
setDefining(boolean value)
void
setFuncDef(boolean value)
void
setHasValue(boolean value)
void
setNewValue(Expression newValue)
void
setSetIfUnbound(boolean value)
String
toString()
protected <R,D>
Rvisit(ExpVisitor<R,D> visitor, D d)
protected <R,D>
voidvisitChildren(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, deepCopy, eval, eval, getColumnNumber, getEndColumn, getEndLine, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getStartColumn, getStartLine, getSystemId, getType, getTypeRaw, isSingleValue, isStableSourceLocation, makeWhile, maybeSetLine, neverReturns, numArgs, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLine, setLocation, setType, side_effects, validateApply, valueIfConstant
-
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
-
DEFINING_FLAG
public static final int DEFINING_FLAG
- See Also:
- Constant Field Values
-
GLOBAL_FLAG
public static final int GLOBAL_FLAG
- See Also:
- Constant Field Values
-
PROCEDURE
public static final int PROCEDURE
- See Also:
- Constant Field Values
-
SET_IF_UNBOUND
public static final int SET_IF_UNBOUND
- See Also:
- Constant Field Values
-
HAS_VALUE
public static final int HAS_VALUE
- See Also:
- Constant Field Values
-
BAD_SHORT
public static final int BAD_SHORT
"Failure" return value of canUseInc.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SetExp
public SetExp(Object symbol, Expression val)
-
SetExp
public SetExp(Declaration decl, Expression val)
-
-
Method Detail
-
makeDefinition
public static SetExp makeDefinition(Object symbol, Expression val)
-
makeDefinition
public static SetExp makeDefinition(Declaration decl, Expression val)
-
getNewValue
public final Expression getNewValue()
Get the Expression for calculating the new ("right-hand") value.
-
setNewValue
public void setNewValue(Expression newValue)
-
isDefining
public final boolean isDefining()
-
setDefining
public final void setDefining(boolean value)
-
getHasValue
public final boolean getHasValue()
True if evaluating the SetExp yields the value of the RHS.
-
setHasValue
public final void setHasValue(boolean value)
-
isFuncDef
public final boolean isFuncDef()
True if this is a functon definition ("defun").
-
setFuncDef
public final void setFuncDef(boolean value)
-
isSetIfUnbound
public final boolean isSetIfUnbound()
-
setSetIfUnbound
public final void setSetIfUnbound(boolean value)
-
mustCompile
protected boolean mustCompile()
- Specified by:
mustCompile
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
-
canUseInc
public static int canUseInc(Expression rhs, Declaration target)
-
calculateType
protected final Type calculateType()
- Overrides:
calculateType
in classExpression
-
visit
protected <R,D> R visit(ExpVisitor<R,D> visitor, D d)
- Overrides:
visit
in classExpression
-
visitChildren
protected <R,D> void visitChildren(ExpVisitor<R,D> visitor, D d)
- Overrides:
visitChildren
in classExpression
-
print
public void print(gnu.kawa.io.OutPort out)
- Specified by:
print
in classExpression
-
toString
public String toString()
- Overrides:
toString
in classExpression
-
-