// Next, compute the set of variable names defined in this container.
Set variableNames = new HashSet();
for (Iterator variables = model.attributeList(Variable.class)
.iterator(); variables.hasNext();) {
Variable variable = (Variable) variables.next();
variableNames.add(variable.getName());
}
variableNames = Collections.unmodifiableSet(variableNames);
// Free variables of contained actors that are defined in this
// container are not free variables of this container.
set.removeAll(variableNames);
// Iterate over all the variables of this container, and add in
// any free variables they reference.
PtParser parser = new PtParser();
ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();
for (Iterator variables = model.attributeList(Variable.class)
.iterator(); variables.hasNext();) {
Variable variable = (Variable) variables.next();
String expression = variable.getExpression();
ASTPtRootNode root;
if (variable.isStringMode()) {
root = parser.generateStringParseTree(expression);
} else {
root = parser.generateParseTree(expression);
}
Set freeIdentifiers = new HashSet(collector
.collectFreeVariables(root));
// Identifiers that reference other variables in the same container
// are bound, not free.
Set tempSet = new HashSet(variableNames);
tempSet.remove(variable.getName());
freeIdentifiers.removeAll(tempSet);
set.addAll(freeIdentifiers);
}