Author: martin
Date: 2006-11-23 08:49:14 -0500 (Thu, 23 Nov 2006)
New Revision: 68387
Modified:
branches/martin/anonymous-methods2/mcs/anonymous.cs
branches/martin/anonymous-methods2/mcs/codegen.cs
branches/martin/anonymous-methods2/mcs/statement.cs
Log:
Modified: branches/martin/anonymous-methods2/mcs/anonymous.cs
===================================================================
--- branches/martin/anonymous-methods2/mcs/anonymous.cs 2006-11-23 11:50:24 UTC
(rev 68386)
+++ branches/martin/anonymous-methods2/mcs/anonymous.cs 2006-11-23 13:49:14 UTC
(rev 68387)
@@ -311,6 +311,19 @@
}
}
+ protected override bool DoDefineMembers ()
+ {
+ Report.Debug (64, "SCOPE INFO DEFINE MEMBERS", this,
GetType (), IsGeneric,
+ Parent.IsGeneric, GenericMethod);
+
+ foreach (CapturedScope child in scopes.Values) {
+ if (!child.DefineMembers ())
+ return false;
+ }
+
+ return base.DoDefineMembers ();
+ }
+
protected override bool DoResolveMembers ()
{
Report.Debug (64, "SCOPE INFO RESOLVE MEMBERS", this,
GetType (), IsGeneric,
@@ -361,17 +374,28 @@
protected abstract class CapturedVariable : Variable
{
public readonly ScopeInfo Scope;
- public readonly Field Field;
+ public readonly string Name;
public FieldExpr FieldInstance;
+ protected Field field;
+ protected CapturedVariable (ScopeInfo scope, string
name)
+ {
+ this.Scope = scope;
+ this.Name = name;
+ }
+
protected CapturedVariable (ScopeInfo scope, string
name, Type type)
+ : this (scope, name)
{
- this.Scope = scope;
- this.Field = scope.CaptureVariable (
+ this.field = scope.CaptureVariable (
scope.MakeFieldName (name),
scope.RootScope.InflateType (type));
}
+ public Field Field {
+ get { return field; }
+ }
+
public override Type Type {
get { return Field.MemberType; }
}
@@ -457,11 +481,19 @@
public readonly ScopeInfo ChildScope;
public CapturedScope (ScopeInfo root, ScopeInfo child)
- : base (root, "scope" + child.ID,
- child.IsGeneric ? child.CurrentType :
child.TypeBuilder)
+ : base (root, "scope" + child.ID)
{
this.ChildScope = child;
}
+
+ public bool DefineMembers ()
+ {
+ Type type = ChildScope.IsGeneric ?
+ ChildScope.CurrentType :
ChildScope.TypeBuilder;
+ field = Scope.CaptureVariable (
+ Scope.MakeFieldName (Name),
Scope.InflateType (type));
+ return true;
+ }
}
static void DoPath (StringBuilder sb, ScopeInfo start)
@@ -727,6 +759,28 @@
scopes.Add (scope);
}
+ bool linked;
+ public void LinkScopes ()
+ {
+ Report.Debug (128, "LINK SCOPES", this, linked, scopes);
+
+ if (linked)
+ return;
+
+ linked = true;
+ if (ParentHost != null)
+ ParentHost.LinkScopes ();
+
+ foreach (ScopeInfo si in scopes) {
+ if (!si.Define ())
+ throw new InternalErrorException ();
+ if (si.DefineType () == null)
+ throw new InternalErrorException ();
+ if (!si.ResolveType ())
+ throw new InternalErrorException ();
+ }
+ }
+
protected override ScopeInitializer CreateScopeInitializer ()
{
foreach (ScopeInfo si in scopes) {
@@ -1324,6 +1378,7 @@
method = DoCreateMethodHost (ec);
+#if FIXME
if (Scope != null) {
if (!Scope.Define ())
throw new InternalErrorException ();
@@ -1332,6 +1387,7 @@
if (!Scope.ResolveType ())
throw new InternalErrorException ();
}
+#endif
if (Scope != null)
return true;
@@ -1471,6 +1527,7 @@
Report.Debug (128, "CREATE METHOD HOST #1", this,
scope, scopes);
foreach (ScopeInfo si in scopes) {
+#if FIXME
Report.Debug (128, "CREATE METHOD HOST #2",
this, scope, si);
if (!si.Define ())
throw new InternalErrorException ();
@@ -1480,6 +1537,7 @@
si.TypeBuilder);
if (!si.ResolveCurrentType ())
throw new InternalErrorException ();
+#endif
scope.CaptureScope (si);
}
Modified: branches/martin/anonymous-methods2/mcs/codegen.cs
===================================================================
--- branches/martin/anonymous-methods2/mcs/codegen.cs 2006-11-23 11:50:24 UTC
(rev 68386)
+++ branches/martin/anonymous-methods2/mcs/codegen.cs 2006-11-23 13:49:14 UTC
(rev 68387)
@@ -718,6 +718,9 @@
}
}
+ if (!block.CompleteContexts (this))
+ return false;
+
resolved = true;
return true;
}
Modified: branches/martin/anonymous-methods2/mcs/statement.cs
===================================================================
--- branches/martin/anonymous-methods2/mcs/statement.cs 2006-11-23 11:50:24 UTC
(rev 68386)
+++ branches/martin/anonymous-methods2/mcs/statement.cs 2006-11-23 13:49:14 UTC
(rev 68387)
@@ -2300,6 +2300,31 @@
get { return parameters; }
}
+ public bool CompleteContexts (EmitContext ec)
+ {
+ Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS", this,
+ container, root_scope);
+
+ if (root_scope != null)
+ root_scope.LinkScopes ();
+
+ if ((container == null) && (root_scope != null)) {
+ Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS
#1", this,
+ root_scope);
+
+ if (root_scope.DefineType () == null)
+ return false;
+ if (!root_scope.ResolveType ())
+ return false;
+ if (!root_scope.ResolveMembers ())
+ return false;
+ if (!root_scope.DefineMembers ())
+ return false;
+ }
+
+ return true;
+ }
+
public GenericMethod GenericMethod {
get { return generic; }
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches