X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fgmcs%2Fiterators.cs;h=85cd202458601957feeb19acffd112fa21a28714;hb=74c2eca79fe94d3b29d339703689fd2f2787e792;hp=529d67351ac2a68e2ace96224a8fd50987bdee81;hpb=aae5c5e35eff96ff69930c40a7bc9c4517c29f8e;p=mono.git diff --git a/mcs/gmcs/iterators.cs b/mcs/gmcs/iterators.cs index 529d67351ac..85cd2024586 100644 --- a/mcs/gmcs/iterators.cs +++ b/mcs/gmcs/iterators.cs @@ -8,7 +8,7 @@ // // TODO: // Flow analysis for Yield. -// Emit calls to parent object constructor. +// Emit calls to base object constructor. // // Generics note: // Current should be defined to return T, and IEnumerator.Current returns object @@ -139,6 +139,8 @@ namespace Mono.CSharp { Type [] param_types; InternalParameters parameters; + MethodInfo dispose_method; + Expression enumerator_type; Expression enumerable_type; Expression generic_enumerator_type; @@ -207,7 +209,7 @@ namespace Mono.CSharp { ig.BeginFaultBlock (); ig.Emit (OpCodes.Ldarg_0); - ig.Emit (OpCodes.Callvirt, dispose.MethodBuilder); + ig.Emit (OpCodes.Callvirt, dispose_method); ig.EndExceptionBlock (); @@ -399,7 +401,7 @@ namespace Mono.CSharp { } if (container.CurrentType != null) - this_type = container.CurrentType.ResolveType (ec); + this_type = container.CurrentType; else this_type = container.TypeBuilder; @@ -437,13 +439,40 @@ namespace Mono.CSharp { return true; } + MethodInfo FetchMethodDispose () + { + MemberList dispose_list; + + dispose_list = FindMembers ( + current_type.Type, + MemberTypes.Method, BindingFlags.Public | BindingFlags.Instance, + Type.FilterName, "Dispose"); + + if (dispose_list.Count != 1) + throw new InternalErrorException ("Cannot find Dipose() method."); + + return (MethodInfo) dispose_list [0]; + } + + protected override bool DoDefineMembers () + { + if (!base.DoDefineMembers ()) + return false; + + dispose_method = FetchMethodDispose (); + if (dispose_method == null) + return false; + + return true; + } + // // Returns the new block for the method, or null on failure // protected override bool DefineNestedTypes () { if (CurrentType != null) - current_type = CurrentType; + current_type = new TypeExpression (CurrentType, Location); else current_type = new TypeExpression (TypeBuilder, Location);