public Expression CreateReferenceExpression(ResolveContext rc, Location loc) { // // We know the variable name is somewhere in the scope. This generates // an access expression from current block // var pb = rc.CurrentBlock.ParametersBlock; while (true) { if (pb is QueryBlock) { for (int i = pb.Parameters.Count - 1; i >= 0; --i) { var p = pb.Parameters[i]; if (p.Name == Name) { return(pb.GetParameterReference(i, loc)); } Expression expr = null; var tp = p as QueryBlock.TransparentParameter; while (tp != null) { if (expr == null) { expr = pb.GetParameterReference(i, loc); } else { expr = new TransparentMemberAccess(expr, tp.Name); } if (tp.Identifier == Name) { return(new TransparentMemberAccess(expr, Name)); } if (tp.Parent.Name == Name) { return(new TransparentMemberAccess(expr, Name)); } tp = tp.Parent as QueryBlock.TransparentParameter; } } } if (pb == block) { return(null); } pb = pb.Parent.ParametersBlock; } }
public Expression CreateReferenceExpression (ResolveContext rc, Location loc) { // // We know the variable name is somewhere in the scope. This generates // an access expression from current block // var pb = rc.CurrentBlock.ParametersBlock; while (true) { if (pb is QueryBlock) { for (int i = pb.Parameters.Count - 1; i >= 0; --i) { var p = pb.Parameters[i]; if (p.Name == Name) return pb.GetParameterReference (i, loc); Expression expr = null; var tp = p as QueryBlock.TransparentParameter; while (tp != null) { if (expr == null) expr = pb.GetParameterReference (i, loc); else expr = new TransparentMemberAccess (expr, tp.Name); if (tp.Identifier == Name) return new TransparentMemberAccess (expr, Name); if (tp.Parent.Name == Name) return new TransparentMemberAccess (expr, Name); tp = tp.Parent as QueryBlock.TransparentParameter; } } } if (pb == block) return null; pb = pb.Parent.ParametersBlock; } }