Author: martin
Date: 2005-05-02 05:07:16 -0400 (Mon, 02 May 2005)
New Revision: 43871
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/codegen.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/statement.cs
Log:
2005-05-02 Martin Baulig <[EMAIL PROTECTED]>
Fix #70140.
* class.cs (ConstructorInitializer.Resolve): Added `Block block'
arguments; use it instead of creating a new TopLevelBlock.
(Constructor.Emit): Call `block.ResolveMeta ()' before resolving
our ConstructorInitializer.
* statement.cs (Block.IsConstructor): New public property.
(TopLevelBlock.TopLevelBranching): New public property.
(TopLevelBlock.ResolveMeta): New public method; call ResolveMeta()
and create our `TopLevelBranching'.
* codegen.cs (EmitContext.ResolveTopBlock): If we're not an
anonymous method host, use `block.TopLevelBranching' rather than
creating a new branching.
* expression.cs (This.DoResolve): Don't report a CS0188 if we're
inside the constructor.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-05-02 09:06:34 UTC (rev 43870)
+++ trunk/mcs/mcs/ChangeLog 2005-05-02 09:07:16 UTC (rev 43871)
@@ -1,3 +1,24 @@
+2005-05-02 Martin Baulig <[EMAIL PROTECTED]>
+
+ Fix #70140.
+
+ * class.cs (ConstructorInitializer.Resolve): Added `Block block'
+ arguments; use it instead of creating a new TopLevelBlock.
+ (Constructor.Emit): Call `block.ResolveMeta ()' before resolving
+ our ConstructorInitializer.
+
+ * statement.cs (Block.IsConstructor): New public property.
+ (TopLevelBlock.TopLevelBranching): New public property.
+ (TopLevelBlock.ResolveMeta): New public method; call ResolveMeta()
+ and create our `TopLevelBranching'.
+
+ * codegen.cs (EmitContext.ResolveTopBlock): If we're not an
+ anonymous method host, use `block.TopLevelBranching' rather than
+ creating a new branching.
+
+ * expression.cs (This.DoResolve): Don't report a CS0188 if we're
+ inside the constructor.
+
2005-04-20 Miguel de Icaza <[EMAIL PROTECTED]>
* anonymous.cs (ScopeInfo.AddChild): when adding a new child to
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2005-05-02 09:06:34 UTC (rev 43870)
+++ trunk/mcs/mcs/class.cs 2005-05-02 09:07:16 UTC (rev 43871)
@@ -4046,13 +4046,13 @@
}
}
- public bool Resolve (ConstructorBuilder caller_builder,
EmitContext ec)
+ public bool Resolve (ConstructorBuilder caller_builder, Block
block, EmitContext ec)
{
Expression base_constructor_group;
Type t;
bool error = false;
- ec.CurrentBlock = new ToplevelBlock
(Block.Flags.Implicit, parameters, loc);
+ ec.CurrentBlock = block;
if (argument_list != null){
foreach (Argument a in argument_list){
@@ -4423,6 +4423,15 @@
return;
}
+ // If this is a non-static `struct' constructor and
doesn't have any
+ // initializer, it must initialize all of the struct's
fields.
+ if ((Parent.Kind == Kind.Struct) &&
+ ((ModFlags & Modifiers.STATIC) == 0) &&
(Initializer == null))
+ Block.AddThisVariable (Parent, Location);
+
+ if (block != null)
+ block.ResolveMeta (ec, ParameterInfo);
+
if ((ModFlags & Modifiers.STATIC) == 0){
if (Parent.Kind == Kind.Class && Initializer ==
null)
Initializer = new
ConstructorBaseInitializer (
@@ -4434,7 +4443,8 @@
// `this' access
//
ec.IsStatic = true;
- if (Initializer != null && !Initializer.Resolve
(ConstructorBuilder, ec))
+ if ((Initializer != null) &&
+ !Initializer.Resolve (ConstructorBuilder,
block, ec))
return;
ec.IsStatic = false;
}
@@ -4472,12 +4482,6 @@
if (OptAttributes != null)
OptAttributes.Emit (ec, this);
- // If this is a non-static `struct' constructor and
doesn't have any
- // initializer, it must initialize all of the struct's
fields.
- if ((Parent.Kind == Kind.Struct) &&
- ((ModFlags & Modifiers.STATIC) == 0) &&
(Initializer == null))
- Block.AddThisVariable (Parent, Location);
-
ec.EmitTopBlock (block, ParameterInfo, Location);
if (source != null)
Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs 2005-05-02 09:06:34 UTC (rev 43870)
+++ trunk/mcs/mcs/codegen.cs 2005-05-02 09:07:16 UTC (rev 43871)
@@ -332,7 +332,7 @@
/// Whether we're control flow analysis enabled
/// </summary>
public bool DoFlowAnalysis;
-
+
/// <summary>
/// Keeps track of the Type to LocalBuilder temporary storage
created
/// to store structures (used to compute the address of the
structure
@@ -513,12 +513,16 @@
{
FlowBranching.BranchingType type;
- if (CurrentBranching.Type ==
FlowBranching.BranchingType.Switch)
+ if ((CurrentBranching != null) &&
+ (CurrentBranching.Type ==
FlowBranching.BranchingType.Switch))
type =
FlowBranching.BranchingType.SwitchSection;
else
type = FlowBranching.BranchingType.Block;
- current_flow_branching = FlowBranching.CreateBranching
(CurrentBranching, type, block, block.StartLocation);
+ DoFlowAnalysis = true;
+
+ current_flow_branching = FlowBranching.CreateBranching (
+ CurrentBranching, type, block,
block.StartLocation);
return current_flow_branching;
}
@@ -681,10 +685,7 @@
#if PRODUCTION
try {
#endif
- int errors = Report.Errors;
-
- block.ResolveMeta (block, this, ip);
- if (Report.Errors != errors)
+ if (!block.ResolveMeta (this, ip))
return false;
bool old_do_flow_analysis =
DoFlowAnalysis;
@@ -692,11 +693,10 @@
if (anonymous_method_host != null)
current_flow_branching =
FlowBranching.CreateBranching (
-
anonymous_method_host.CurrentBranching, FlowBranching.BranchingType.Block,
- block, loc);
+
anonymous_method_host.CurrentBranching,
+
FlowBranching.BranchingType.Block, block, loc);
else
- current_flow_branching =
FlowBranching.CreateBranching (
- null,
FlowBranching.BranchingType.Block, block, loc);
+ current_flow_branching =
block.TopLevelBranching;
if (!block.Resolve (this)) {
current_flow_branching = null;
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-05-02 09:06:34 UTC (rev 43870)
+++ trunk/mcs/mcs/expression.cs 2005-05-02 09:07:16 UTC (rev 43871)
@@ -6831,7 +6831,9 @@
if (!ResolveBase (ec))
return null;
- if ((variable_info != null) &&
!variable_info.IsAssigned (ec)) {
+ bool is_ctor = (block == null) || block.IsConstructor;
+
+ if ((variable_info != null) && !is_ctor &&
!variable_info.IsAssigned (ec)) {
Error (188, "The this object cannot be used
before all " +
"of its fields are assigned to");
variable_info.SetAssigned (ec);
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2005-05-02 09:06:34 UTC (rev 43870)
+++ trunk/mcs/mcs/statement.cs 2005-05-02 09:07:16 UTC (rev 43871)
@@ -1187,6 +1187,12 @@
}
Flags flags;
+ public bool IsConstructor {
+ get {
+ return this_variable != null;
+ }
+ }
+
public bool Implicit {
get {
return (flags & Flags.Implicit) != 0;
@@ -2113,6 +2119,7 @@
//
public ToplevelBlock Container;
CaptureContext capture_context;
+ FlowBranching top_level_branching;
Hashtable capture_contexts;
@@ -2185,6 +2192,26 @@
return capture_context;
}
}
+
+ public FlowBranching TopLevelBranching {
+ get {
+ return top_level_branching;
+ }
+ }
+
+ public bool ResolveMeta (EmitContext ec, InternalParameters ip)
+ {
+ int errors = Report.Errors;
+
+ if (top_level_branching != null)
+ return true;
+
+ ResolveMeta (this, ec, ip);
+
+ top_level_branching = ec.StartFlowBranching (this);
+
+ return Report.Errors == errors;
+ }
}
public class SwitchLabel {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches