public abstract class Expression extends java.lang.Object implements Locatable
| Modifier and Type | Field and Description |
|---|---|
static boolean |
VOID_ASSIGNMENTS
When this is true, all assignments have a void type (and return
no value); otherwise, they have the same type as the assigned value (which is also
the value they return).
|
| Constructor and Description |
|---|
Expression() |
| Modifier and Type | Method and Description |
|---|---|
Expression |
addType(Type newType)
This adds the specified type as another type for this expression.
|
Expression |
addTypes(Expression expression)
Adds all the types prescribed for the specified expression to this one.
|
byte |
boxSort()
This returns the runtime sort for this expression unless its type
has been marked as boxed - in which case it returns OBJECT_SORT.
|
abstract Type |
checkedType()
This method returns the final unambiguously checked type of this expression.
|
abstract void |
compile(Compiler compiler)
This method compiles this expression in the context of the specified
Compiler.
|
boolean |
containsFreeName(java.lang.String name)
Returns true iff the specified name occurs free in this expression.
|
abstract Expression |
copy()
Returns a deep copy of this expression.
|
Expression |
enclosingScope()
Returns this expression enclosing scope (if it has been computed by linkScopeTree);
null otherwise.
|
Locatable |
extent() |
Location |
getEnd()
Returns the end of this expressions's extent as a
Location.
|
Location |
getStart()
Returns the start of this expressions's extent as a
Location.
|
boolean |
isConstant()
Returns true iff this expression is a
Constant.
|
boolean |
isEquality(Tables tables) |
boolean |
isFalse()
Returns true iff this expression denotes the constant false.
|
boolean |
isHiddenSlicing(Tables tables,
Parameter parameter)
Returns true iff this expression is a "hidden" slicing filter for the
specified parameter; i.e., one that uses accessor projections rather than
explicit tuple projections.
|
boolean |
isNull()
Returns true iff this expression denotes the constant null.
|
boolean |
isSelector(Tables tables,
Parameter parameter)
Returns true iff this expression is a selector filter for the specified
parameter.
|
boolean |
isSlicing(Tables tables,
Parameter parameter)
Returns true iff this expression is a slicing filter for the specified
parameter.
|
boolean |
isTrue()
Returns true iff this expression denotes the constant true.
|
boolean |
isVoid()
Returns true iff this expression denotes the constant void.
|
java.lang.String |
locationString()
Returns an explicit string for this expression's extent's location.
|
int |
numberOfSubexpressions()
Returns the number of subexpressions
|
java.util.HashSet |
otherTypes() |
Parameter[] |
parameters()
This is only to enable uniform visitors on expressions.
|
Expression |
sanitizeNames(ParameterStack parameters)
This method returns the actual expression corresponding to this one after
eliminating all the Dummy expressions that occur
in it where names where read.
|
void |
sanitizeSorts(Enclosure enclosure)
|
abstract void |
setCheckedType()
This method sets the final unambiguously checked type of this expression, possibly
along with other final information that may be needed by the compiler for
generating code.
|
abstract void |
setCheckedType(Type type)
This method sets the final unambiguously checked type of this expression to the
specified type.
|
boolean |
setCheckedTypeLocked() |
Locatable |
setEnd(Location location)
Sets the end of this expressions's extent to the specified
Location and returns this.
|
Expression |
setExtent(Locatable extent) |
Expression |
setOtherTypes(java.util.HashSet otherTypes) |
Locatable |
setStart(Location location)
Sets the start of this expressions's extent to the specified
Location and returns this.
|
Expression |
setSubexpression(int n,
Expression expression)
Returns this expression after setting its n-th subexpression to the specified
expression; if there is no subexpression at the given position, this throws a
NoSuchSubexpressionException
|
abstract void |
setType(Type type)
This method forcibly sets this expression's type field, if it has one, to the
specified type.
|
Expression |
shiftOffsets(int intShift,
int realShift,
int objectShift) |
Expression |
shiftOffsets(int intShift,
int realShift,
int objectShift,
int intDepth,
int realDepth,
int objectDepth)
This methods visits this expression shifting the offset of all the Locals it encounters by the specified amount (per
sort) as long as the offset it sees is referencing a parameter within the specified
scope depth (per sort); This method is used when the compiler needs to
synthesize an scope from an already typechecked expression (i.e., for
currying or un/boxing - e.g., see the pad method below).
|
byte |
sort()
Returns the sort of this expression's type after it has been
checked.
|
Expression |
subexpression(int n)
Returns the n-th subexpression of this expression; if there is no subexpression
at the given position, this throws a NoSuchSubexpressionException
|
Expression |
substitute(java.util.HashMap substitution)
Returns the expression resulting from substituting all the free occurrences
of the parameters's names as specified by the given substitution.
|
abstract Type |
type()
This method returns the current type of this expression.
|
void |
typeCheck(Global filter,
TypeChecker typeChecker)
This method type-checks this expression in the context of the specified typechecker,
using the type of the specified Global as a filter.
|
abstract void |
typeCheck(TypeChecker typeChecker)
This method type-checks this expression in the context of the specified
TypeChecker.
|
void |
typeCheck(Type type,
TypeChecker typeChecker)
This method ascertains that this expression has the specified type in
the context of the specified
TypeChecker.
|
boolean |
typeCheckLocked() |
abstract Expression |
typedCopy()
Returns a deep copy of this expression this and all its subexpressions share the
same type as their copy's counterparts.
|
abstract Type |
typeRef()
This method returns this expression's undereferenced type field if it has one.
|
public static boolean VOID_ASSIGNMENTS
public abstract Expression copy()
public abstract Expression typedCopy()
public final boolean typeCheckLocked()
public final boolean setCheckedTypeLocked()
public boolean isSlicing(Tables tables, Parameter parameter)
public boolean isHiddenSlicing(Tables tables, Parameter parameter)
public boolean isSelector(Tables tables, Parameter parameter)
public final boolean isEquality(Tables tables) throws UndefinedEqualityException
UndefinedEqualityExceptionpublic final boolean isConstant()
public final boolean isVoid()
public boolean isTrue()
public boolean isFalse()
public boolean isNull()
public abstract Type type()
public abstract void setType(Type type)
public abstract Type typeRef()
public abstract Type checkedType()
public abstract void setCheckedType()
public abstract void setCheckedType(Type type)
public Expression substitute(java.util.HashMap substitution)
public Expression enclosingScope()
public boolean containsFreeName(java.lang.String name)
public Expression sanitizeNames(ParameterStack parameters)
public void sanitizeSorts(Enclosure enclosure)
public Expression shiftOffsets(int intShift, int realShift, int objectShift, int intDepth, int realDepth, int objectDepth)
public final Expression shiftOffsets(int intShift, int realShift, int objectShift)
public abstract void typeCheck(TypeChecker typeChecker) throws TypingErrorException
TypingErrorExceptionpublic void typeCheck(Type type, TypeChecker typeChecker) throws TypingErrorException
TypingErrorExceptionpublic final void typeCheck(Global filter, TypeChecker typeChecker) throws TypingErrorException
TypingErrorExceptionpublic abstract void compile(Compiler compiler)
public int numberOfSubexpressions()
public Expression subexpression(int n) throws NoSuchSubexpressionException
NoSuchSubexpressionExceptionpublic Expression setSubexpression(int n, Expression expression) throws NoSuchSubexpressionException
NoSuchSubexpressionExceptionpublic Parameter[] parameters()
public final byte sort()
public byte boxSort()
public final Expression addType(Type newType)
public final java.util.HashSet otherTypes()
public final Expression setOtherTypes(java.util.HashSet otherTypes)
public final Expression addTypes(Expression expression)
public final Locatable extent()
public final Expression setExtent(Locatable extent)
public final Location getStart()
public final Locatable setStart(Location location)
public final Locatable setEnd(Location location)
public final java.lang.String locationString()
locationString in interface Locatable