===================================================================
--- anonymous.cs (revision 63019)
+++ anonymous.cs (working copy)
-@@ -20,297 +20,288 @@
+@@ -20,297 +20,290 @@
namespace Mono.CSharp {
+ Report.Debug (64, "COMPILER GENERATED NESTED #1", this,
+ Name, Parent, parent_type);
+
++#if FIXME
+ CompilerGeneratedClass parent = Parent as CompilerGeneratedClass;
+ if (parent != null)
+ parent_link = new CapturedVariable (this, "<>parent", parent_type);
++#endif
+
+ RootContext.RegisterCompilerGeneratedType (TypeBuilder);
+ return base.DefineNestedTypes ();
- return b;
+ TypeExpr parent_type;
+ bool members_defined;
-+ CapturedVariable parent_link;
++ protected CapturedVariable parent_link;
+ CapturedVariable this_field;
- CaptureContext ca = a.CaptureContext;
- CaptureContext cb = b.CaptureContext;
-+ public Type ParentType {
++ protected Type ParentType {
+ get { return parent_type.Type; }
+ }
+ if (pfield != null) {
+ Parameter[] ctor_params = new Parameter [1];
+ ctor_params [0] = new Parameter (
-+ parent_type, "parent", Parameter.Modifier.NONE,
++ pfield.MemberType, "parent", Parameter.Modifier.NONE,
+ null, Location);
- //
}
public bool ImplicitStandardConversionExists (Type delegate_type)
-@@ -318,8 +309,9 @@
+@@ -318,8 +311,9 @@
if (Parameters == null)
return true;
ParameterData invoke_pd = TypeManager.GetParameterData (invoke_mb);
if (Parameters.Count != invoke_pd.Count)
-@@ -338,31 +330,20 @@
+@@ -338,31 +332,20 @@
//
public Expression Compatible (EmitContext ec, Type delegate_type)
{
if (Parameters == null) {
//
// We provide a set of inaccessible parameters
-@@ -375,7 +356,9 @@
+@@ -375,7 +358,9 @@
"+" + i, invoke_pd.ParameterModifier (i), null, loc);
}
} else {
if (Parameters.Count != invoke_pd.Count) {
Report.SymbolRelatedToPreviousError (delegate_type);
-@@ -407,8 +390,10 @@
+@@ -407,8 +392,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 +404,375 @@
+@@ -419,135 +406,375 @@
//MethodBuilder builder = method_data.MethodBuilder;
//ILGenerator ig = builder.GetILGenerator ();
}
}
-@@ -573,69 +798,43 @@
+@@ -573,69 +800,43 @@
public override void Emit (EmitContext ec)
{
ArrayList locals = new ArrayList ();
ArrayList children = new ArrayList ();
-@@ -643,40 +842,59 @@
+@@ -643,40 +844,61 @@
//
// The types and fields generated
//
+
cc.RegisterCaptureContext ();
+
++#if FIXME
+ if (!Define ())
+ throw new InternalErrorException ();
+ if (DefineType () == null)
+ throw new InternalErrorException ();
++#endif
}
- public void AddLocal (LocalInfo li)
internal void AddChild (ScopeInfo si)
{
if (children.Contains (si))
-@@ -719,8 +937,6 @@
+@@ -703,8 +925,31 @@
+ children.Remove (child);
+ }
+ }
+- }
++ }
+
++ protected override bool DefineNestedTypes ()
++ {
++ Report.Debug (64, "SCOPE INFO DEFINE NESTED", this, Name, Parent, Parent.Name,
++ ParentScope);
++
++ if (ParentScope == null)
++ return base.DefineNestedTypes ();
++
++ TypeExpr parent_type;
++ if (ParentScope.IsGeneric) {
++ parent_type = new ConstructedType (
++ ParentScope.TypeBuilder, ParentScope.TypeParameters, Location);
++ parent_type = parent_type.ResolveAsTypeTerminal (this, false);
++ if ((parent_type == null) || (parent_type.Type == null))
++ return false;
++ } else {
++ parent_type = new TypeExpression (ParentScope.TypeBuilder, Location);
++ }
++
++ parent_link = new CapturedVariable (this, "<>parent", parent_type);
++ return base.DefineNestedTypes ();
++ }
++
+ static int indent = 0;
+
+ void Pad ()
+@@ -719,8 +964,6 @@
Pad ();
Console.WriteLine ("START");
indent++;
foreach (LocalInfo li in locals){
Pad ();
Console.WriteLine ("var {0}", MakeFieldName (li.Name));
-@@ -733,168 +949,41 @@
+@@ -733,168 +976,41 @@
Console.WriteLine ("END");
}
public static void CheckCycles (string msg, ScopeInfo s)
{
ArrayList l = new ArrayList ();
-@@ -935,6 +1024,344 @@
+@@ -935,6 +1051,344 @@
return sb.ToString ();
}
}
//
-@@ -952,7 +1379,8 @@
+@@ -952,7 +1406,8 @@
//
// Points to the toplevel block that owns this CaptureContext
//
//
// All the scopes we capture
-@@ -965,25 +1393,23 @@
+@@ -965,25 +1420,23 @@
ArrayList roots = new ArrayList ();
bool have_captured_vars = false;
}
void DoPath (StringBuilder sb, CaptureContext cc)
-@@ -995,17 +1421,6 @@
+@@ -995,17 +1448,6 @@
sb.Append (cc.cc_id.ToString ());
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
-@@ -1017,7 +1432,7 @@
+@@ -1017,7 +1459,7 @@
public ToplevelBlock ParentToplevel {
get {
}
}
-@@ -1029,124 +1444,261 @@
+@@ -1029,124 +1471,264 @@
}
}
+
+ internal ScopeInfo GetScopeForBlock (Block block)
+ {
++ while (block.Implicit)
++ block = block.Parent;
++
ScopeInfo si = (ScopeInfo) scopes [block.ID];
+ Report.Debug (64, "GET SCOPE FOR BLOCK", this, block,
+ block.ScopeInfo, block.Parent, si);
}
public bool HaveCapturedVariables {
-@@ -1164,21 +1716,23 @@
+@@ -1164,21 +1746,23 @@
}
}
return true;
if (captured_parameters != null)
-@@ -1186,88 +1740,54 @@
+@@ -1186,88 +1770,57 @@
return false;
}
+ am, block.ID, block.Toplevel.ID, ToplevelOwner.ID,
+ block, block.Toplevel, ToplevelOwner);
+
++ while (block.Implicit)
++ block = block.Parent;
++
+ if (block.Toplevel == ToplevelOwner){
+ si = (ScopeInfo) scopes [block.ID];
+ si.EmitScopeInstance (ec);
}
}
}
-@@ -1275,135 +1795,35 @@
+@@ -1275,135 +1828,35 @@
//
// Internal routine that loads the instance to reach parameter `name'
//
}
//
-@@ -1412,7 +1832,10 @@
+@@ -1412,7 +1865,10 @@
//
bool IsAncestor (ScopeInfo probe, ScopeInfo scope)
{
if (probe.ScopeBlock == b)
return true;
}
-@@ -1474,7 +1897,7 @@
+@@ -1474,7 +1930,7 @@
}
return parent;
}
//
// Links all the scopes
//
-@@ -1483,7 +1906,9 @@
+@@ -1483,7 +1939,9 @@
{
if (linked)
return;
linked = true;
if (ParentCaptureContext != null)
ParentCaptureContext.LinkScopes ();
-@@ -1492,9 +1917,14 @@
+@@ -1492,9 +1950,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 +1934,28 @@
+@@ -1504,17 +1967,28 @@
parent.AddChild (scope_list [i]);
}
found = true;
// Found, link all the roots to this root
+@@ -1533,6 +2007,13 @@
+ throw new Exception ("Internal compiler error: Did not find the parent for the root in the chain");
+ }
+ }
++
++ foreach (ScopeInfo si in scope_list) {
++ if (!si.Define ())
++ throw new InternalErrorException ();
++ if (si.DefineType () == null)
++ throw new InternalErrorException ();
++ }
+ }
+ }
+ }
Index: expression.cs
===================================================================
--- expression.cs (revision 63019)