BoundScope.java
package edu.udel.cis.vsl.tass.model.impl.scope;
import edu.udel.cis.vsl.tass.model.IF.SyntaxException;
import edu.udel.cis.vsl.tass.model.IF.expression.BoundExpressionIF;
import edu.udel.cis.vsl.tass.model.IF.scope.BoundScopeIF;
import edu.udel.cis.vsl.tass.model.IF.scope.ScopeIF;
import edu.udel.cis.vsl.tass.model.IF.variable.BoundVariableIF;
public class BoundScope extends Scope implements BoundScopeIF {
private BoundExpressionIF expression;
public BoundScope(ScopeIF parent) {
super(parent, ScopeKind.BOUND, parent.model(),
"incomplete bound scope in " + parent);
}
/** The binding expression for which this is the scope. */
public BoundExpressionIF expression() {
return expression;
}
/**
* The variables in this scope are assigned ID numbers 0, 1, 2, ..., at
* completion time. This method returns the variable with the given ID.
*/
@Override
public BoundVariableIF variableWithId(int id) {
return (BoundVariableIF) super.variableWithId(id);
}
/**
* Returns the variable in this scope with the given name, or null if there
* isn't one.
*/
@Override
public BoundVariableIF variableWithName(String name) {
return (BoundVariableIF) super.variableWithName(name);
}
/** Adds the variable to this scope. */
public void addBoundVariable(BoundVariableIF variable)
throws SyntaxException {
addVariable(variable);
}
/** Sets the bound expression for this scope. */
public void setExpression(BoundExpressionIF expression) {
this.expression = expression;
this.name = "bound scope in " + parent() + " for expression:\n"
+ expression;
}
}