//
// Authors: Marek Safar (marek.safar@gmail.com)
//
-// Licensed under the terms of the GNU GPL
+// Dual licensed under the terms of the MIT X11 or GNU GPL
//
-// (C) 2007 Novell, Inc
+// Copyright 2007-2008 Novell, Inc
//
using System;
public override Expression DoResolve (EmitContext ec)
{
+ int counter = TransparentParameter.Counter;
+
Expression e = BuildQueryClause (ec, null, null, null);
e = e.Resolve (ec);
+
+ //
+ // Reset counter in probing mode to ensure that all transparent
+ // identifier anonymous types are created only once
+ //
+ if (ec.IsInProbingMode)
+ TransparentParameter.Counter = counter;
+
return e;
}
protected override MethodGroupExpr DoResolveOverload (EmitContext ec)
{
mg.CustomErrorHandler = this;
- MethodGroupExpr rmg = mg.OverloadResolve (ec, Arguments, false, loc);
+ MethodGroupExpr rmg = mg.OverloadResolve (ec, ref Arguments, false, loc);
return rmg;
}
public bool NoExactMatch (EmitContext ec, MethodBase method)
{
- ParameterData pd = TypeManager.GetParameterData (method);
+#if GMCS_SOURCE
+ AParametersCollection pd = TypeManager.GetParameterData (method);
Type source_type = pd.ExtensionMethodType;
if (source_type != null) {
Argument a = (Argument) Arguments [0];
"Try specifying the type argument explicitly",
mg.Name.ToLower ());
return true;
+#else
+ return false;
+#endif
}
}
t.next = (AQueryClause)next.Clone (clonectx);
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ // Should not be reached
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
return expr.DoResolve (ec);
{
Parameters p = new Parameters (parameters);
- LambdaExpression selector = new LambdaExpression (
- null, null, (TypeContainer)ec.TypeContainer, p, ec.CurrentBlock, loc);
+ LambdaExpression selector = new LambdaExpression (loc);
selector.Block = new SelectorBlock (ec.CurrentBlock, p, ti, loc);
- selector.Block.AddStatement (new Return (expr, loc));
-
- if (!ec.IsInProbingMode) {
- selector.CreateAnonymousHelpers ();
+ selector.Block.AddStatement (new ContextualReturn (expr));
- // TODO: I am not sure where this should be done to work
- // correctly with anonymous containerss and was called only once
- // FIXME: selector.RootScope == null for nested anonymous
- // methods only ?
- if (selector.RootScope != null)
- selector.RootScope.DefineType ();
- }
-
return new Argument (selector);
}
protected abstract string MethodName { get; }
+ public override void MutateHoistedGenericType (AnonymousMethodStorey storey)
+ {
+ // Nothing to mutate
+ }
+
public virtual AQueryClause Next {
set {
next = value;
public class Cast : QueryStartClause
{
// We don't have to clone cast type
- readonly Expression type_expr;
+ readonly FullNamedExpression type_expr;
- public Cast (Expression type, Expression expr)
+ public Cast (FullNamedExpression type, Expression expr)
: base (expr)
{
this.type_expr = type;
public override Expression BuildQueryClause (EmitContext ec, Expression lSide, Parameter parameter, TransparentIdentifiersScope ti)
{
- lSide = CreateQueryExpression (expr, new TypeArguments (loc, type_expr), null);
+ lSide = CreateQueryExpression (expr, new TypeArguments (type_expr), null);
if (next != null)
return next.BuildQueryClause (ec, lSide, parameter, ti);
//
// Spread resolved initializer type
//
- parameter.ParameterType = type;
- parameter.Resolve (ec);
+ ((ImplicitLambdaParameter) parameter).Type = type;
}
return e;
}
- protected override void Error_InvalidInitializer (Expression initializer)
+ protected override void Error_InvalidInitializer (string initializer)
{
Report.Error (1932, loc, "A range variable `{0}' cannot be initialized with `{1}'",
- Name, initializer.GetSignatureForError ());
+ Name, initializer);
}
}
// Nothing to clone
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ();
+ }
+
public override Expression DoResolve (EmitContext ec)
{
throw new NotSupportedException ();
{
throw new NotSupportedException ();
}
+
+ public override void MutateHoistedGenericType (AnonymousMethodStorey storey)
+ {
+ throw new NotSupportedException ();
+ }
}
public ImplicitQueryParameter (LocatedToken variable)
//
public class TransparentParameter : ImplicitLambdaParameter
{
- static int counter;
+ public static int Counter;
const string ParameterNamePrefix = "<>__TranspIdent";
public TransparentParameter (Location loc)
- : base (ParameterNamePrefix + counter++, loc)
+ : base (ParameterNamePrefix + Counter++, loc)
{
}
}
//
// This block is actually never used, it is used by parser only
//
- public class QueryBlock : Block
+ public class QueryBlock : ExplicitBlock
{
- Hashtable range_variables = new Hashtable ();
-
public QueryBlock (Block parent, Location start)
: base (parent, start, Location.Null)
{
+ range_variables = new System.Collections.Specialized.HybridDictionary ();
}
protected override void AddVariable (LocalInfo li)
{
string name = li.Name;
if (range_variables.Contains (name)) {
- Location conflict = (Location)range_variables [name];
- Report.SymbolRelatedToPreviousError (conflict, name);
+ LocalInfo conflict = (LocalInfo) range_variables [name];
+ Report.SymbolRelatedToPreviousError (conflict.Location, name);
Error_AlreadyDeclared (li.Location, name);
return;
}
- range_variables.Add (name, li.Location);
+ range_variables.Add (name, li);
+ Explicit.AddKnownVariable (name, li);
}
protected override void Error_AlreadyDeclared (Location loc, string var, string reason)