//
// 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
Type [] param_types;
InternalParameters parameters;
+ MethodInfo dispose_method;
+
Expression enumerator_type;
Expression enumerable_type;
Expression generic_enumerator_type;
ig.BeginFaultBlock ();
ig.Emit (OpCodes.Ldarg_0);
- ig.Emit (OpCodes.Callvirt, dispose.MethodBuilder);
+ ig.Emit (OpCodes.Callvirt, dispose_method);
ig.EndExceptionBlock ();
}
if (container.CurrentType != null)
- this_type = container.CurrentType.ResolveType (ec);
+ this_type = container.CurrentType;
else
this_type = container.TypeBuilder;
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);
this.field = field;
}
+ public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
+ {
+ return DoResolve (ec);
+ }
+
public override Expression DoResolve (EmitContext ec)
{
FieldExpr fexpr = new FieldExpr (field.FieldBuilder, loc);