Author: martin
Date: 2005-03-22 04:59:34 -0500 (Tue, 22 Mar 2005)
New Revision: 42076
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/anonymous.cs
trunk/mcs/gmcs/codegen.cs
trunk/mcs/gmcs/expression.cs
Log:
**** Merged r40457-r40460 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-03-22 09:58:37 UTC (rev 42075)
+++ trunk/mcs/gmcs/ChangeLog 2005-03-22 09:59:34 UTC (rev 42076)
@@ -1,3 +1,25 @@
+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
+ is null it means that there has been no need to capture anything,
+ so we just create a sibling.
+
+ Renamed `EmitHelperClasses' to `EmitAnonymousHelperClasses'
+
+ Just a partial fix. The other half is fairly elusive.
+
2005-02-10 Raja R Harinath <[EMAIL PROTECTED]>
Fix #52586, cs0121-4.cs.
Modified: trunk/mcs/gmcs/anonymous.cs
===================================================================
--- trunk/mcs/gmcs/anonymous.cs 2005-03-22 09:58:37 UTC (rev 42075)
+++ trunk/mcs/gmcs/anonymous.cs 2005-03-22 09:59:34 UTC (rev 42076)
@@ -113,7 +113,8 @@
//
TypeBuilder current_type = ec.TypeContainer.TypeBuilder;
- TypeBuilder type_host = Scope == null ? current_type :
Scope.ScopeTypeBuilder;
+ TypeBuilder type_host = (Scope == null ) // ||
Scope.ScopeTypeBuilder == null)
+ ? current_type : Scope.ScopeTypeBuilder;
if (current_type == null)
throw new Exception ("The current_type is
null");
@@ -657,7 +658,7 @@
public class CaptureContext {
public static int count;
public int cc_id;
- Location loc;
+ public Location loc;
//
// Points to the toplevel block that owns this CaptureContext
@@ -665,6 +666,7 @@
ToplevelBlock toplevel_owner;
Hashtable scopes = new Hashtable ();
bool have_captured_vars = false;
+ bool referenced_this = false;
ScopeInfo topmost = null;
//
@@ -909,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;
@@ -948,15 +957,15 @@
return false;
}
- public void EmitHelperClasses (EmitContext ec)
+ public void EmitAnonymousHelperClasses (EmitContext ec)
{
if (topmost != null){
- topmost.NeedThis = HaveCapturedFields;
+ topmost.NeedThis = HaveCapturedFields ||
referenced_this;
topmost.EmitScopeType (ec);
}
}
- public void CloseHelperClasses ()
+ public void CloseAnonymousHelperClasses ()
{
if (topmost != null)
topmost.CloseTypes ();
Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs 2005-03-22 09:58:37 UTC (rev 42075)
+++ trunk/mcs/gmcs/codegen.cs 2005-03-22 09:59:34 UTC (rev 42076)
@@ -560,10 +560,15 @@
public void CaptureParameter (string name, Type t, int idx)
{
-
capture_context.AddParameter (this,
CurrentAnonymousMethod, name, t, idx);
}
+
+ public void CaptureThis ()
+ {
+ capture_context.CaptureThis ();
+ }
+
//
// Use to register a field as captured
//
@@ -624,7 +629,7 @@
public void EmitMeta (ToplevelBlock b, InternalParameters ip)
{
if (capture_context != null)
- capture_context.EmitHelperClasses (this);
+ capture_context.EmitAnonymousHelperClasses
(this);
b.EmitMeta (this);
if (HasReturnLabel)
@@ -768,7 +773,7 @@
// Close pending helper classes if we are the toplevel
//
if (capture_context != null &&
capture_context.ParentToplevel == null)
- capture_context.CloseHelperClasses ();
+ capture_context.CloseAnonymousHelperClasses ();
}
/// <summary>
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2005-03-22 09:58:37 UTC (rev 42075)
+++ trunk/mcs/gmcs/expression.cs 2005-03-22 09:59:34 UTC (rev 42076)
@@ -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