public class Evaluator
{
// TODO Remove HARDCODED "this". Should be alias of some name
public Collection evaluate(SymbolTable symtbl, Expression expr, Imports imports, ClassLoaderResolver clr)
{
Symbol symThis = symtbl.getSymbol("this");
Collection candidates = (Collection) symThis.getValue();
Iterator it = candidates.iterator();
Collection result = new HashSet();
while(it.hasNext())
{
symThis.setValue(it.next());
if( expr.evaluate(new InMemoryExpressionEvaluator(symtbl, imports, clr)) == Boolean.TRUE )
{
result.add(symThis.getValue());
}
}
return result;
}