Author: martin
Date: 2006-09-05 12:36:05 -0400 (Tue, 05 Sep 2006)
New Revision: 64951
Modified:
branches/martin/anonymous-methods/gmcs/anonymous.cs
branches/martin/anonymous-methods/gmcs/class.cs
branches/martin/anonymous-methods/gmcs/iterators.cs
branches/martin/anonymous-methods/gmcs/statement.cs
Log:
Fix the type resolving madness:
- introduce a new TypeContainer.ResolveMembers() pass which calls
ResolveMembers() on all methods, properties, operators and indexers.
- CompilerGeneratedClass.PopulateTypes() is gone; use the
ResolveMembers() framework instead.
Modified: branches/martin/anonymous-methods/gmcs/anonymous.cs
===================================================================
--- branches/martin/anonymous-methods/gmcs/anonymous.cs 2006-09-05 15:38:06 UTC
(rev 64950)
+++ branches/martin/anonymous-methods/gmcs/anonymous.cs 2006-09-05 16:36:05 UTC
(rev 64951)
@@ -69,9 +69,6 @@
protected override bool DoDefineMembers ()
{
- if (!PopulateType ())
- throw new InternalErrorException ();
-
members_defined = true;
if (!base.DoDefineMembers ())
@@ -87,16 +84,16 @@
return true;
}
- protected override bool DoPopulateType ()
+ protected override bool DoResolveMembers ()
{
if (CompilerGenerated != null) {
foreach (CompilerGeneratedClass c in
CompilerGenerated) {
- if (!c.PopulateType ())
+ if (!c.ResolveMembers ())
return false;
}
}
- return true;
+ return base.DoResolveMembers ();
}
public GenericMethod GenericMethod {
@@ -148,12 +145,6 @@
throw new InternalErrorException ("Helper class
already defined!");
}
- public override void EmitType ()
- {
- Report.Debug (64, "COMPILER GENERATED EMIT TYPE", this,
CompilerGenerated);
- base.EmitType ();
- }
-
protected class CapturedVariable : Field
{
public CapturedVariable (CompilerGeneratedClass helper,
string name,
@@ -223,9 +214,9 @@
protected abstract ScopeInitializerBase CreateScopeInitializer
();
- protected override bool DoPopulateType ()
+ protected override bool DoResolveMembers ()
{
- Report.Debug (64, "SCOPE INFO RESOLVE TYPE", this,
GetType (), IsGeneric,
+ Report.Debug (64, "SCOPE INFO RESOLVE MEMBERS", this,
GetType (), IsGeneric,
Parent.IsGeneric, GenericMethod);
if (IsGeneric) {
@@ -248,7 +239,7 @@
if (Host != this)
scope_instance = Host.CaptureScope (this);
- return base.DoPopulateType ();
+ return base.DoResolveMembers ();
}
protected abstract class ScopeInitializerBase :
ExpressionStatement
@@ -999,10 +990,12 @@
method = DoCreateMethodHost (ec);
- if (RootScope == null)
- return method.Define ();
- else
+ if (RootScope != null)
return true;
+
+ if (!method.ResolveMembers ())
+ return false;
+ return method.Define ();
}
protected abstract Method DoCreateMethodHost (EmitContext ec);
Modified: branches/martin/anonymous-methods/gmcs/class.cs
===================================================================
--- branches/martin/anonymous-methods/gmcs/class.cs 2006-09-05 15:38:06 UTC
(rev 64950)
+++ branches/martin/anonymous-methods/gmcs/class.cs 2006-09-05 16:36:05 UTC
(rev 64951)
@@ -453,8 +453,8 @@
ArrayList type_bases;
- bool type_populated;
- bool type_populated_ok;
+ bool members_resolved;
+ bool members_resolved_ok;
bool members_defined;
bool members_defined_ok;
@@ -1280,46 +1280,62 @@
part.TypeBuilder = TypeBuilder;
}
- if (!CreateAnonymousHelpers ()) {
+ if (!(this is CompilerGeneratedClass)) {
+ if (!ResolveMembers ()) {
+ error = true;
+ return null;
+ }
+ }
+
+ if (!DefineNestedTypes ()) {
error = true;
return null;
}
- DefineNestedTypes ();
-
return TypeBuilder;
}
- protected bool CreateAnonymousHelpers ()
+ public bool ResolveMembers ()
{
+ if (members_resolved)
+ return members_resolved_ok;
+
+ members_resolved_ok = DoResolveMembers ();
+ members_resolved = true;
+
+ return members_resolved_ok;
+ }
+
+ protected virtual bool DoResolveMembers ()
+ {
if (methods != null) {
foreach (Method method in methods) {
- if (!method.CreateAnonymousHelpers ())
+ if (!method.ResolveMembers ())
return false;
}
}
if (operators != null) {
foreach (Operator o in operators) {
- if (!o.CreateAnonymousHelpers ())
+ if (!o.ResolveMembers ())
return false;
}
}
if (properties != null) {
foreach (PropertyBase p in properties) {
- if (!p.Get.IsDummy &&
!p.Get.CreateAnonymousHelpers ())
+ if (!p.Get.IsDummy &&
!p.Get.ResolveMembers ())
return false;
- if (!p.Set.IsDummy &&
!p.Set.CreateAnonymousHelpers ())
+ if (!p.Set.IsDummy &&
!p.Set.ResolveMembers ())
return false;
}
}
if (indexers != null) {
foreach (PropertyBase p in indexers) {
- if (!p.Get.IsDummy &&
!p.Get.CreateAnonymousHelpers ())
+ if (!p.Get.IsDummy &&
!p.Get.ResolveMembers ())
return false;
- if (!p.Set.IsDummy &&
!p.Set.CreateAnonymousHelpers ())
+ if (!p.Set.IsDummy &&
!p.Set.ResolveMembers ())
return false;
}
}
@@ -1527,22 +1543,6 @@
Report.Error (1530, loc, "Keyword `new' is not allowed
on namespace elements");
}
- protected bool PopulateType ()
- {
- if (type_populated)
- return type_populated_ok;
-
- type_populated_ok = DoPopulateType ();
- type_populated = true;
-
- return type_populated_ok;
- }
-
- protected virtual bool DoPopulateType ()
- {
- return true;
- }
-
/// <summary>
/// Populates our TypeBuilder with fields and methods
/// </summary>
@@ -3793,13 +3793,8 @@
anonymous_methods.Add (anonymous);
}
- bool base_defined;
-
protected bool DefineGenericMethod ()
{
- if (base_defined)
- return true;
-
if (!DoDefineBase ())
return false;
@@ -3817,17 +3812,11 @@
return false;
}
- base_defined = true;
return true;
}
- public bool CreateAnonymousHelpers ()
+ public bool ResolveMembers ()
{
- Report.Debug (64, "METHOD DEFINE HELPERS", this, Name,
- ModFlags & Modifiers.METHOD_YIELDS,
- ModFlags & Modifiers.ANONYMOUS_HOST,
- Block);
-
if (!DefineGenericMethod ())
return false;
@@ -3851,9 +3840,6 @@
public override bool Define ()
{
- if (!DefineGenericMethod ())
- return false;
-
if (!DoDefine ())
return false;
@@ -6417,7 +6403,7 @@
return method.IsClsComplianceRequired ();
}
- public bool CreateAnonymousHelpers ()
+ public bool ResolveMembers ()
{
TypeContainer container = ((TypeContainer)
Parent).PartialContainer;
Modified: branches/martin/anonymous-methods/gmcs/iterators.cs
===================================================================
--- branches/martin/anonymous-methods/gmcs/iterators.cs 2006-09-05 15:38:06 UTC
(rev 64950)
+++ branches/martin/anonymous-methods/gmcs/iterators.cs 2006-09-05 16:36:05 UTC
(rev 64951)
@@ -188,7 +188,7 @@
return base.GetClassBases (out base_class);
}
- protected override bool DoDefineMembers ()
+ protected override bool DoResolveMembers ()
{
pc_field = CaptureVariable ("$PC",
TypeManager.int32_type);
current_field = CaptureVariable ("$current",
Iterator.OriginalIteratorType);
@@ -203,10 +203,16 @@
new GetEnumeratorMethod (this, true);
}
+ return base.DoResolveMembers ();
+ }
+
+ protected override bool DoDefineMembers ()
+ {
if (!base.DoDefineMembers ())
return false;
FetchMethodDispose ();
+
return true;
}
@@ -843,6 +849,8 @@
Report.Debug (64, "RESOLVE ITERATOR #1", this, method,
method.Parent,
RootScope, ec);
+ if (!RootScope.ResolveMembers ())
+ return false;
if (!RootScope.DefineMembers ())
return false;
Modified: branches/martin/anonymous-methods/gmcs/statement.cs
===================================================================
--- branches/martin/anonymous-methods/gmcs/statement.cs 2006-09-05 15:38:06 UTC
(rev 64950)
+++ branches/martin/anonymous-methods/gmcs/statement.cs 2006-09-05 16:36:05 UTC
(rev 64951)
@@ -2194,6 +2194,8 @@
return false;
if (!anonymous_method_host.ResolveType ())
return false;
+ if (!anonymous_method_host.ResolveMembers ())
+ return false;
if (!anonymous_method_host.DefineMembers ())
return false;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches