Author: martin
Date: 2005-04-12 08:03:59 -0400 (Tue, 12 Apr 2005)
New Revision: 42821
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/anonymous.cs
trunk/mcs/gmcs/codegen.cs
trunk/mcs/gmcs/expression.cs
Log:
**** Merged r40460 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-12 12:02:41 UTC (rev 42820)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-12 12:03:59 UTC (rev 42821)
@@ -1,3 +1,15 @@
+2005-02-11 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * anonymous.cs (CaptureContext): Track whether `this' has been
+ referenced.
+
+ * expression.cs (This.ResolveBase): Call CaptureThis. Before we
+ only captured `this' if it was implicitly done (instance
+ methods/variables were used).
+
+ * codegen.cs (EmitContext.CaptureThis): New method to flag that
+ `this' must be captured.
+
2005-01-30 Miguel de Icaza <[EMAIL PROTECTED]>
* anonymous.cs (CreateMethodHost): If there Scope.ScopeTypeBuilder
Modified: trunk/mcs/gmcs/anonymous.cs
===================================================================
--- trunk/mcs/gmcs/anonymous.cs 2005-04-12 12:02:41 UTC (rev 42820)
+++ trunk/mcs/gmcs/anonymous.cs 2005-04-12 12:03:59 UTC (rev 42821)
@@ -666,6 +666,7 @@
ToplevelBlock toplevel_owner;
Hashtable scopes = new Hashtable ();
bool have_captured_vars = false;
+ bool referenced_this = false;
ScopeInfo topmost = null;
//
@@ -910,8 +911,15 @@
else
captured_fields [fe] = fe;
}
-
+ public void CaptureThis ()
+ {
+ CaptureContext parent = ParentCaptureContext;
+ if (parent != null)
+ parent.CaptureThis ();
+ referenced_this = true;
+ }
+
public bool HaveCapturedVariables {
get {
return have_captured_vars;
@@ -952,7 +960,7 @@
public void EmitAnonymousHelperClasses (EmitContext ec)
{
if (topmost != null){
- topmost.NeedThis = HaveCapturedFields;
+ topmost.NeedThis = HaveCapturedFields ||
referenced_this;
topmost.EmitScopeType (ec);
}
}
Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs 2005-04-12 12:02:41 UTC (rev 42820)
+++ trunk/mcs/gmcs/codegen.cs 2005-04-12 12:03:59 UTC (rev 42821)
@@ -562,7 +562,13 @@
{
capture_context.AddParameter (this,
CurrentAnonymousMethod, name, t, idx);
}
+
+ public void CaptureThis ()
+ {
+ capture_context.CaptureThis ();
+ }
+
//
// Use to register a field as captured
//
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2005-04-12 12:02:41 UTC (rev 42820)
+++ trunk/mcs/gmcs/expression.cs 2005-04-12 12:03:59 UTC (rev 42821)
@@ -6895,6 +6895,9 @@
if ((block != null) && (block.ThisVariable != null))
variable_info = block.ThisVariable.VariableInfo;
+ if (ec.CurrentAnonymousMethod != null)
+ ec.CaptureThis ();
+
return true;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches