Author: raja
Date: 2007-03-27 12:18:59 -0500 (Tue, 27 Mar 2007)
New Revision: 75033
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/codegen.cs
trunk/mcs/mcs/flowanalysis.cs
trunk/mcs/mcs/statement.cs
Log:
Prepare to kill 'Reachability'
* flowanalysis.cs (FlowBranching.Reachability): Make class private.
(FlowBranching.UsageVector.Reachability): Remove property.
(FlowBranching.UsageVector.IsUnreachable): New property.
(FlowBranching.UsageVector.ResetBarrier): New.
(FlowBranching.UsageVector, FlowBranchingLabeled): Update to changes.
* codegen.cs, statement.cs: Update to changes.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-03-27 17:15:02 UTC (rev 75032)
+++ trunk/mcs/mcs/ChangeLog 2007-03-27 17:18:59 UTC (rev 75033)
@@ -1,3 +1,13 @@
+2007-03-27 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Prepare to kill 'Reachability'
+ * flowanalysis.cs (FlowBranching.Reachability): Make class private.
+ (FlowBranching.UsageVector.Reachability): Remove property.
+ (FlowBranching.UsageVector.IsUnreachable): New property.
+ (FlowBranching.UsageVector.ResetBarrier): New.
+ (FlowBranching.UsageVector, FlowBranchingLabeled): Update to changes.
+ * codegen.cs, statement.cs: Update to changes.
+
2007-03-27 Martin Baulig <[EMAIL PROTECTED]>
Fix #81209.
Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs 2007-03-27 17:15:02 UTC (rev 75032)
+++ trunk/mcs/mcs/codegen.cs 2007-03-27 17:18:59 UTC (rev 75033)
@@ -603,11 +603,11 @@
// Ends a code branching. Merges the state of locals and
parameters
// from all the children of the ending branching.
// </summary>
- public FlowBranching.Reachability EndFlowBranching ()
+ public bool EndFlowBranching ()
{
FlowBranching.UsageVector vector = DoEndFlowBranching
();
- return vector.Reachability;
+ return vector.IsUnreachable;
}
// <summary>
@@ -696,8 +696,8 @@
if (!ok)
return false;
- FlowBranching.Reachability reachability
= top_level.End ();
- if (reachability.IsUnreachable)
+ bool flow_unreachable = top_level.End
();
+ if (flow_unreachable)
unreachable = true;
}
#if PRODUCTION
Modified: trunk/mcs/mcs/flowanalysis.cs
===================================================================
--- trunk/mcs/mcs/flowanalysis.cs 2007-03-27 17:15:02 UTC (rev 75032)
+++ trunk/mcs/mcs/flowanalysis.cs 2007-03-27 17:18:59 UTC (rev 75033)
@@ -67,7 +67,7 @@
Finally
}
- public sealed class Reachability
+ private sealed class Reachability
{
bool is_unreachable;
@@ -236,7 +236,7 @@
? MyBitVector.Empty
: new MyBitVector (parent == null ?
MyBitVector.Empty : parent.parameters, num_params);
- reachability = parent == null ?
Reachability.Always () : parent.Reachability.Clone ();
+ reachability = parent == null ?
Reachability.Always () : parent.reachability.Clone ();
id = ++next_id;
}
@@ -245,7 +245,7 @@
: this (type, parent, block, loc,
parent.CountParameters, parent.CountLocals)
{ }
- public UsageVector (MyBitVector parameters, MyBitVector
locals, Reachability reachability, Block block, Location loc)
+ private UsageVector (MyBitVector parameters,
MyBitVector locals, Reachability reachability, Block block, Location loc)
{
this.Type = SiblingType.Block;
this.Location = loc;
@@ -274,7 +274,7 @@
public bool IsAssigned (VariableInfo var, bool
ignoreReachability)
{
- if (!ignoreReachability && !var.IsParameter &&
Reachability.IsUnreachable)
+ if (!ignoreReachability && !var.IsParameter &&
IsUnreachable)
return true;
return var.IsAssigned (var.IsParameter ?
parameters : locals);
@@ -282,7 +282,7 @@
public void SetAssigned (VariableInfo var)
{
- if (!var.IsParameter &&
Reachability.IsUnreachable)
+ if (!var.IsParameter && IsUnreachable)
return;
var.SetAssigned (var.IsParameter ? parameters :
locals);
@@ -290,7 +290,7 @@
public bool IsFieldAssigned (VariableInfo var, string
name)
{
- if (!var.IsParameter &&
Reachability.IsUnreachable)
+ if (!var.IsParameter && IsUnreachable)
return true;
return var.IsFieldAssigned (var.IsParameter ?
parameters : locals, name);
@@ -298,16 +298,21 @@
public void SetFieldAssigned (VariableInfo var, string
name)
{
- if (!var.IsParameter &&
Reachability.IsUnreachable)
+ if (!var.IsParameter && IsUnreachable)
return;
var.SetFieldAssigned (var.IsParameter ?
parameters : locals, name);
}
- public Reachability Reachability {
- get { return reachability; }
+ public bool IsUnreachable {
+ get { return reachability.IsUnreachable; }
}
+ public void ResetBarrier ()
+ {
+ reachability.Meet (Reachability.Always ());
+ }
+
public void Goto ()
{
if (!reachability.IsUnreachable)
@@ -321,17 +326,17 @@
MyBitVector locals = null;
MyBitVector parameters = null;
- Reachability reachability =
sibling_list.Reachability.Clone ();
+ Reachability reachability =
sibling_list.reachability.Clone ();
- if (!sibling_list.Reachability.IsUnreachable) {
+ if (!sibling_list.IsUnreachable) {
locals &= sibling_list.locals;
parameters &= sibling_list.parameters;
}
for (UsageVector child = sibling_list.Next;
child != null; child = child.Next) {
- reachability.Meet (child.Reachability);
+ reachability.Meet (child.reachability);
- if (!child.Reachability.IsUnreachable) {
+ if (!child.IsUnreachable) {
locals &= child.locals;
parameters &= child.parameters;
}
@@ -347,7 +352,7 @@
{
Report.Debug (2, " MERGING CHILD EFFECTS",
this, child, reachability, Type);
- Reachability new_r = child.Reachability;
+ Reachability new_r = child.reachability;
//
// We've now either reached the point after the
branching or we will
@@ -392,11 +397,11 @@
for (UsageVector vector = o_vectors; vector !=
null; vector = vector.Next) {
Report.Debug (1, " MERGING BREAK
ORIGIN", vector);
- if (vector.Reachability.IsUnreachable)
+ if (vector.IsUnreachable)
continue;
locals &= vector.locals;
parameters &= vector.parameters;
- reachability.Meet (vector.Reachability);
+ reachability.Meet (vector.reachability);
}
Report.Debug (1, " MERGING BREAK ORIGINS
DONE", this);
@@ -667,7 +672,7 @@
actual = CurrentUsageVector.Clone ();
// stand-in for backward jumps
- CurrentUsageVector.Reachability.Meet
(Reachability.Always ());
+ CurrentUsageVector.ResetBarrier ();
}
public override bool AddGotoOrigin (UsageVector vector, Goto
goto_stmt)
@@ -686,7 +691,7 @@
{
UsageVector vector = base.Merge ();
- if (actual.Reachability.IsUnreachable)
+ if (actual.IsUnreachable)
Report.Warning (162, 2, stmt.loc, "Unreachable
code detected");
actual.MergeChild (vector, false);
@@ -708,7 +713,7 @@
// </summary>
void CheckOutParameters (UsageVector vector, Location loc)
{
- if (vector.Reachability.IsUnreachable)
+ if (vector.IsUnreachable)
return;
for (int i = 0; i < param_map.Count; i++) {
VariableInfo var = param_map [i];
@@ -785,9 +790,9 @@
return vector;
}
- public Reachability End ()
+ public bool End ()
{
- return Merge ().Reachability;
+ return Merge ().IsUnreachable;
}
}
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2007-03-27 17:15:02 UTC (rev 75032)
+++ trunk/mcs/mcs/statement.cs 2007-03-27 17:18:59 UTC (rev 75033)
@@ -261,7 +261,7 @@
ok &= TrueStatement.Resolve (ec);
- is_true_ret =
ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable;
+ is_true_ret =
ec.CurrentBranching.CurrentUsageVector.IsUnreachable;
ec.CurrentBranching.CreateSibling ();
@@ -347,14 +347,14 @@
ec.StartFlowBranching
(FlowBranching.BranchingType.Loop, loc);
- bool was_unreachable =
ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable;
+ bool was_unreachable =
ec.CurrentBranching.CurrentUsageVector.IsUnreachable;
ec.StartFlowBranching
(FlowBranching.BranchingType.Embedded, loc);
if (!EmbeddedStatement.Resolve (ec))
ok = false;
ec.EndFlowBranching ();
- if
(ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable &&
!was_unreachable)
+ if
(ec.CurrentBranching.CurrentUsageVector.IsUnreachable && !was_unreachable)
Report.Warning (162, 2, expr.Location,
"Unreachable code detected");
expr = Expression.ResolveBoolean (ec, expr, loc);
@@ -573,7 +573,7 @@
if (!infinite)
ec.CurrentBranching.CreateSibling ();
- bool was_unreachable =
ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable;
+ bool was_unreachable =
ec.CurrentBranching.CurrentUsageVector.IsUnreachable;
ec.StartFlowBranching
(FlowBranching.BranchingType.Embedded, loc);
if (!Statement.Resolve (ec))
@@ -581,7 +581,7 @@
ec.EndFlowBranching ();
if (Increment != null){
- if
(ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable) {
+ if
(ec.CurrentBranching.CurrentUsageVector.IsUnreachable) {
if (!Increment.ResolveUnreachable (ec,
!was_unreachable))
ok = false;
} else {
@@ -2297,7 +2297,7 @@
num_statements = ix + 1;
- unreachable =
ec.CurrentBranching.CurrentUsageVector.Reachability.IsUnreachable;
+ unreachable =
ec.CurrentBranching.CurrentUsageVector.IsUnreachable;
if (unreachable && s is LabeledStatement)
throw new InternalErrorException
("should not happen");
}
@@ -2319,7 +2319,7 @@
// initializer, then we must initialize all of the
struct's fields.
if ((flags & Flags.IsToplevel) != 0 &&
!Toplevel.IsThisAssigned (ec) &&
- !vector.Reachability.IsUnreachable)
+ !vector.IsUnreachable)
ok = false;
if ((labels != null) && (RootContext.WarningLevel >=
2)) {
@@ -2331,7 +2331,7 @@
Report.Debug (4, "RESOLVE BLOCK DONE #2",
StartLocation, vector);
- if (vector.Reachability.IsUnreachable)
+ if (vector.IsUnreachable)
flags |= Flags.HasRet;
if (ok && (errors == Report.Errors)) {
@@ -3606,11 +3606,10 @@
ec.CurrentBranching.CreateSibling (
null,
FlowBranching.SiblingType.SwitchSection);
- FlowBranching.Reachability reachability =
ec.EndFlowBranching ();
+ ec.EndFlowBranching ();
ec.Switch = old_switch;
- Report.Debug (1, "END OF SWITCH BLOCK", loc,
ec.CurrentBranching,
- reachability);
+ Report.Debug (1, "END OF SWITCH BLOCK", loc,
ec.CurrentBranching);
return true;
}
@@ -4136,8 +4135,8 @@
return false;
}
- FlowBranching.Reachability reachability =
ec.EndFlowBranching ();
- has_ret = reachability.IsUnreachable;
+ bool flow_unreachable = ec.EndFlowBranching ();
+ has_ret = flow_unreachable;
return true;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches