public class Scope extends ProtoExpression
NB: This class is not meant to be put in unknowing hands: using it without being fully aware of its functionality may cause seriously wrong behavior - if you do not know for sure that this is what you want, then use Abstraction instead!
VOID_ASSIGNMENTS| Constructor and Description |
|---|
Scope(java.util.AbstractList parameters,
Expression body) |
Scope(Expression body) |
Scope(Parameter[] parameters,
Expression body) |
Scope(Parameter parameter,
Expression body) |
Scope(java.lang.String name,
Expression body) |
| Modifier and Type | Method and Description |
|---|---|
int |
arity() |
Expression |
body() |
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.
|
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.
|
int |
intArity() |
int |
numberOfSubexpressions()
Returns the number of subexpressions
|
int |
objectArity() |
Parameter |
parameter(int i) |
Parameter[] |
parameters()
This is only to enable uniform visitors on expressions.
|
int |
realArity() |
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)
|
void |
setBody(Expression body) |
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.
|
void |
setCheckedType(Type type)
NB: this is not final because itis overridden in
Abstraction and
Global.
|
void |
setSortedArities() |
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
|
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).
|
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.
|
java.lang.String |
toString() |
void |
typeCheck(TypeChecker typeChecker)
This method type-checks this expression in the context of the specified
TypeChecker.
|
Expression |
typedCopy()
Returns a deep copy of this expression this and all its subexpressions share the
same type as their copy's counterparts.
|
int |
voidArity() |
checkedType, setType, type, typeRefaddType, addTypes, boxSort, extent, getEnd, getStart, isConstant, isEquality, isFalse, isHiddenSlicing, isNull, isSelector, isSlicing, isTrue, isVoid, locationString, otherTypes, setCheckedTypeLocked, setEnd, setExtent, setOtherTypes, setStart, shiftOffsets, sort, typeCheck, typeCheck, typeCheckLockedpublic Scope(Parameter[] parameters, Expression body)
public Scope(Parameter parameter, Expression body)
public Scope(java.lang.String name,
Expression body)
public Scope(Expression body)
public Scope(java.util.AbstractList parameters,
Expression body)
public Expression copy()
Expressioncopy in class Expressionpublic Expression typedCopy()
ExpressiontypedCopy in class Expressionpublic final int arity()
public final int intArity()
public final int realArity()
public final int objectArity()
public final int voidArity()
public final void setSortedArities()
public final int numberOfSubexpressions()
ExpressionnumberOfSubexpressions in class Expressionpublic final Expression subexpression(int n) throws NoSuchSubexpressionException
Expressionsubexpression in class ExpressionNoSuchSubexpressionExceptionpublic final Expression setSubexpression(int n, Expression expression) throws NoSuchSubexpressionException
ExpressionsetSubexpression in class ExpressionNoSuchSubexpressionExceptionpublic final Parameter[] parameters()
Expressionparameters in class Expressionpublic final Parameter parameter(int i)
public final Expression body()
public final void setBody(Expression body)
public final void setCheckedType(Type type)
ProtoExpressionsetCheckedType in class ProtoExpressionpublic final void setCheckedType()
ExpressionsetCheckedType in class Expressionpublic void typeCheck(TypeChecker typeChecker) throws TypingErrorException
ExpressiontypeCheck in class ExpressionTypingErrorExceptionpublic final boolean containsFreeName(java.lang.String name)
ExpressioncontainsFreeName in class Expressionpublic final Expression enclosingScope()
ExpressionenclosingScope in class Expressionpublic Expression substitute(java.util.HashMap substitution)
Expressionsubstitute in class Expressionpublic final Expression sanitizeNames(ParameterStack parameters)
ExpressionsanitizeNames in class Expressionpublic void sanitizeSorts(Enclosure enclosure)
ExpressionsanitizeSorts in class Expressionpublic Expression shiftOffsets(int intShift, int realShift, int objectShift, int intDepth, int realDepth, int objectDepth)
ExpressionshiftOffsets in class Expressionpublic final void compile(Compiler compiler)
Expressioncompile in class Expressionpublic java.lang.String toString()
toString in class java.lang.Object