this.emSource = emSource;
}
public SQLColumnValues getFieldValue(TypedValue.GetFieldValue val, T in) throws TypedValueVisitorException
{
if (!(val.operand instanceof TypedValue.ThisValue))
throw new TypedValueVisitorException("Unhandled access to a field");
// Currently, we only support parameters of a few small simple types.
// We should also support more complex types (e.g. entities) and allow
// fields/methods of those entities to be called in the query (code
// motion will be used to push those field accesses or method calls
// outside the query where they will be evaluated and then passed in
// as a parameter)
Type t = val.getType();
if (!allowedQueryParameterTypes.containsKey(t))
throw new TypedValueVisitorException("Accessing a field with unhandled type");
try
{
// TODO: Careful here. ParameterLocation is relative to the base
// lambda, but if we arrive here from inside a nested query, "this"
// might refer to a lambda nested inside the base lambda. (Of course,
// nested queries with parameters aren't currently supported, so it
// doesn't matter.)
ParameterLocation paramLoc = ParameterLocation.createThisFieldAccess(val.name, lambdaIndex);
// Object param = paramLoc.getParameter(lambda);
SQLColumnValues toReturn = new SQLColumnValues(allowedQueryParameterTypes.get(t));
assert(toReturn.getNumColumns() == 1);
toReturn.columns[0].add(new SQLSubstitution.ExternalParameterLink(paramLoc));
return toReturn;
} catch (Exception e)
{
throw new TypedValueVisitorException(e);
}
}