expr = Convert.ImplicitConversionRequired (
ec, expr, iterator.IteratorType, loc);
if (expr == null)
-@@ -119,13 +122,473 @@
+@@ -119,13 +122,478 @@
}
}
+ return base.DoResolveInternal (ec);
+ }
+
++ protected override void DoEmit (EmitContext ec)
++ {
++ DoEmitInstance (ec);
++ }
++
+ protected override void EmitParameterReference (EmitContext ec,
+ CapturedParameter cp)
+ {
public readonly bool IsStatic;
//
-@@ -139,7 +602,6 @@
+@@ -139,7 +607,6 @@
// Context from the original method
//
GenericMethod generic_method;
TypeExpr current_type;
Type this_type;
Parameters parameters;
-@@ -147,7 +609,7 @@
+@@ -147,7 +614,7 @@
IMethodData orig_method;
MethodInfo dispose_method;
Constructor ctor;
CaptureContext cc;
-@@ -156,25 +618,25 @@
+@@ -156,25 +623,25 @@
Expression generic_enumerator_type;
Expression generic_enumerable_type;
TypeArguments generic_args;
{
ILGenerator ig = ec.ig;
-@@ -192,7 +654,7 @@
+@@ -192,7 +659,7 @@
resume_points.Add (entry_point);
entry_point.Define (ig);
EmitYieldBreak (ig);
-@@ -203,7 +665,7 @@
+@@ -203,7 +670,7 @@
labels [i] = ((ResumePoint) resume_points [i]).Label;
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Switch, labels);
Label end = ig.DefineLabel ();
-@@ -221,7 +683,7 @@
+@@ -221,7 +688,7 @@
ig.BeginFaultBlock ();
ig.Emit (OpCodes.Ldarg_0);
ig.EndExceptionBlock ();
-@@ -264,12 +726,12 @@
+@@ -264,12 +731,12 @@
ig.MarkLabel (dispatcher);
ig.Emit (OpCodes.Ldarg_0);
ig.MarkLabel (end);
}
-@@ -305,13 +767,13 @@
+@@ -305,13 +772,13 @@
// Store the new current
ig.Emit (OpCodes.Ldarg_0);
expr.Emit (ec);
// Return ok
ig.Emit (OpCodes.Br, move_next_ok);
-@@ -329,726 +791,119 @@
+@@ -329,726 +796,119 @@
pc++;
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, pc);
}
protected class MoveNextStatement : Statement {
-@@ -1062,147 +917,17 @@
+@@ -1062,147 +922,17 @@
public override bool Resolve (EmitContext ec)
{
}
//
-@@ -1212,10 +937,10 @@
+@@ -1212,10 +942,10 @@
class NoCheckReturn : Statement {
public Expression Expr;
}
public override bool Resolve (EmitContext ec)
-@@ -1236,10 +961,47 @@
+@@ -1236,10 +966,47 @@
}
}
===================================================================
--- anonymous.cs (revision 63019)
+++ anonymous.cs (working copy)
-@@ -20,297 +20,662 @@
+@@ -20,297 +20,667 @@
namespace Mono.CSharp {
+ static int next_id;
+ int id = ++next_id;
+
-+ protected void DoEmit (EmitContext ec)
++ protected virtual void DoEmit (EmitContext ec)
+ {
+ if (ec.CurrentBlock.Toplevel == Scope.ScopeBlock.Toplevel)
-+ ec.ig.Emit (OpCodes.Ldloc, scope_instance);
++ DoEmitInstance (ec);
+ else
+ ec.ig.Emit (OpCodes.Ldarg_0);
+ }
+
++ protected void DoEmitInstance (EmitContext ec)
++ {
++ ec.ig.Emit (OpCodes.Ldloc, scope_instance);
++ }
++
+ protected virtual void EmitScopeConstructor (EmitContext ec)
+ {
+ ec.ig.Emit (OpCodes.Newobj, scope_ctor);
}
public bool ImplicitStandardConversionExists (Type delegate_type)
-@@ -318,8 +683,9 @@
+@@ -318,8 +688,9 @@
if (Parameters == null)
return true;
ParameterData invoke_pd = TypeManager.GetParameterData (invoke_mb);
if (Parameters.Count != invoke_pd.Count)
-@@ -338,31 +704,20 @@
+@@ -338,31 +709,20 @@
//
public Expression Compatible (EmitContext ec, Type delegate_type)
{
if (Parameters == null) {
//
// We provide a set of inaccessible parameters
-@@ -375,7 +730,9 @@
+@@ -375,7 +735,9 @@
"+" + i, invoke_pd.ParameterModifier (i), null, loc);
}
} else {
if (Parameters.Count != invoke_pd.Count) {
Report.SymbolRelatedToPreviousError (delegate_type);
-@@ -407,8 +764,10 @@
+@@ -407,8 +769,10 @@
return null;
}
}
//
// Second: the return type of the delegate must be compatible with
// the anonymous type. Instead of doing a pass to examine the block
-@@ -419,135 +778,318 @@
+@@ -419,135 +783,318 @@
//MethodBuilder builder = method_data.MethodBuilder;
//ILGenerator ig = builder.GetILGenerator ();
}
}
-@@ -573,69 +1115,40 @@
+@@ -573,69 +1120,40 @@
public override void Emit (EmitContext ec)
{
ArrayList locals = new ArrayList ();
ArrayList children = new ArrayList ();
-@@ -643,40 +1156,52 @@
+@@ -643,40 +1161,52 @@
//
// The types and fields generated
//
internal void AddChild (ScopeInfo si)
{
if (children.Contains (si))
-@@ -703,7 +1228,7 @@
+@@ -703,7 +1233,7 @@
children.Remove (child);
}
}
static int indent = 0;
-@@ -719,8 +1244,6 @@
+@@ -719,8 +1249,6 @@
Pad ();
Console.WriteLine ("START");
indent++;
foreach (LocalInfo li in locals){
Pad ();
Console.WriteLine ("var {0}", MakeFieldName (li.Name));
-@@ -733,168 +1256,18 @@
+@@ -733,168 +1261,18 @@
Console.WriteLine ("END");
}
public static void CheckCycles (string msg, ScopeInfo s)
{
ArrayList l = new ArrayList ();
-@@ -935,6 +1308,173 @@
+@@ -935,6 +1313,173 @@
return sb.ToString ();
}
}
//
-@@ -952,7 +1492,8 @@
+@@ -952,7 +1497,8 @@
//
// Points to the toplevel block that owns this CaptureContext
//
//
// All the scopes we capture
-@@ -965,25 +1506,23 @@
+@@ -965,25 +1511,23 @@
ArrayList roots = new ArrayList ();
bool have_captured_vars = false;
}
void DoPath (StringBuilder sb, CaptureContext cc)
-@@ -995,17 +1534,6 @@
+@@ -995,17 +1539,6 @@
sb.Append (cc.cc_id.ToString ());
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
-@@ -1017,7 +1545,7 @@
+@@ -1017,7 +1550,7 @@
public ToplevelBlock ParentToplevel {
get {
}
}
-@@ -1029,124 +1557,257 @@
+@@ -1029,124 +1562,257 @@
}
}
}
public bool HaveCapturedVariables {
-@@ -1164,21 +1825,23 @@
+@@ -1164,21 +1830,23 @@
}
}
return true;
if (captured_parameters != null)
-@@ -1186,224 +1849,53 @@
+@@ -1186,224 +1854,53 @@
return false;
}
}
//
-@@ -1412,7 +1904,10 @@
+@@ -1412,7 +1909,10 @@
//
bool IsAncestor (ScopeInfo probe, ScopeInfo scope)
{
if (probe.ScopeBlock == b)
return true;
}
-@@ -1474,7 +1969,7 @@
+@@ -1474,7 +1974,7 @@
}
return parent;
}
//
// Links all the scopes
//
-@@ -1483,7 +1978,9 @@
+@@ -1483,7 +1983,9 @@
{
if (linked)
return;
linked = true;
if (ParentCaptureContext != null)
ParentCaptureContext.LinkScopes ();
-@@ -1492,9 +1989,14 @@
+@@ -1492,9 +1994,14 @@
ScopeInfo [] scope_list = new ScopeInfo [scope_count];
scopes.Values.CopyTo (scope_list, 0);
if (parent == null){
roots.Add (scope_list [i]);
continue;
-@@ -1504,17 +2006,28 @@
+@@ -1504,17 +2011,28 @@
parent.AddChild (scope_list [i]);
}
found = true;
// Found, link all the roots to this root
-@@ -1533,6 +2046,13 @@
+@@ -1533,6 +2051,13 @@
throw new Exception ("Internal compiler error: Did not find the parent for the root in the chain");
}
}