Author: raja
Date: 2007-05-27 08:59:39 -0400 (Sun, 27 May 2007)
New Revision: 78005
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/cs-parser.jay
trunk/mcs/mcs/statement.cs
Log:
New ExplicitBlock invariants
* mcs/statement.cs (Block.Explicit): New field. It points to the
immediately enclosing non-implicit block.
(Block..ctor): Maintain the invariant.
* mcs/cs-parser.jay, gmcs/cs-parser.jay: Take advantage of invariant.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2007-05-27 12:59:18 UTC (rev 78004)
+++ trunk/mcs/gmcs/ChangeLog 2007-05-27 12:59:39 UTC (rev 78005)
@@ -1,5 +1,7 @@
2007-05-27 Raja R Harinath <[EMAIL PROTECTED]>
+ * cs-parser.jay: Update to new ExplicitBlock invariant.
+
* cs-parser.jay: Update to changes introduced in Block and
ExplicitBlock.
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2007-05-27 12:59:18 UTC (rev 78004)
+++ trunk/mcs/gmcs/cs-parser.jay 2007-05-27 12:59:39 UTC (rev 78005)
@@ -4754,11 +4754,7 @@
}
statement_list
{
- Block topmost = current_block;
-
- while (topmost.Implicit)
- topmost = topmost.Parent;
- $$ = new SwitchSection ((ArrayList) $1, topmost);
+ $$ = new SwitchSection ((ArrayList) $1, current_block.Explicit);
}
;
@@ -5894,13 +5890,9 @@
Block
end_block (Location loc)
{
- Block retval;
-
- while (current_block.Implicit)
- current_block = current_block.Parent;
- retval = current_block;
- current_block.SetEndLocation (loc);
- current_block = current_block.Parent;
+ Block retval = current_block.Explicit;
+ retval.SetEndLocation (loc);
+ current_block = retval.Parent;
if (current_block == null)
top_current_block = null;
return retval;
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-05-27 12:59:18 UTC (rev 78004)
+++ trunk/mcs/mcs/ChangeLog 2007-05-27 12:59:39 UTC (rev 78005)
@@ -1,5 +1,11 @@
2007-05-27 Raja R Harinath <[EMAIL PROTECTED]>
+ New ExplicitBlock invariants
+ * statement.cs (Block.Explicit): New field. It points to the
+ immediately enclosing non-implicit block.
+ (Block..ctor): Maintain the invariant.
+ * cs-parser.jay: Take advantage of invariant.
+
Introduce ExplicitBlock
* statement.cs (ExplicitBlock): New.
(ToplevelBlock): Derive from it.
Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2007-05-27 12:59:18 UTC (rev 78004)
+++ trunk/mcs/mcs/cs-parser.jay 2007-05-27 12:59:39 UTC (rev 78005)
@@ -4153,11 +4153,7 @@
}
statement_list
{
- Block topmost = current_block;
-
- while (topmost.Implicit)
- topmost = topmost.Parent;
- $$ = new SwitchSection ((ArrayList) $1, topmost);
+ $$ = new SwitchSection ((ArrayList) $1, current_block.Explicit);
}
;
@@ -5170,13 +5166,9 @@
Block
end_block (Location loc)
{
- Block retval;
-
- while (current_block.Implicit)
- current_block = current_block.Parent;
- retval = current_block;
- current_block.SetEndLocation (loc);
- current_block = current_block.Parent;
+ Block retval = current_block.Explicit;
+ retval.SetEndLocation (loc);
+ current_block = retval.Parent;
if (current_block == null)
top_current_block = null;
return retval;
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2007-05-27 12:59:18 UTC (rev 78004)
+++ trunk/mcs/mcs/statement.cs 2007-05-27 12:59:39 UTC (rev 78005)
@@ -1441,6 +1441,7 @@
public readonly Location StartLocation;
public Location EndLocation = Location.Null;
+ public ExplicitBlock Explicit;
public ToplevelBlock Toplevel;
[Flags]
@@ -1551,11 +1552,16 @@
else
Toplevel = parent.Toplevel;
+ if ((flags & Flags.IsExplicit) != 0)
+ Explicit = (ExplicitBlock) this;
+ else
+ Explicit = parent.Explicit;
+
if (parent != null && Implicit) {
- if (parent.known_variables == null)
- parent.known_variables = new Hashtable
();
+ if (Explicit.known_variables == null)
+ Explicit.known_variables = new
Hashtable ();
// share with parent
- known_variables = parent.known_variables;
+ known_variables = Explicit.known_variables;
}
}
@@ -1732,9 +1738,7 @@
Block b = this;
LocalInfo kvi = b.GetKnownVariableInfo (name, true);
while (kvi == null) {
- while (b.Implicit)
- b = b.Parent;
- b = b.Parent;
+ b = b.Explicit.Parent;
if (b == null)
return true;
kvi = b.GetKnownVariableInfo (name, false);
@@ -1744,7 +1748,7 @@
return true;
// Is kvi.Block nested inside 'b'
- if (b.known_variables != kvi.Block.known_variables) {
+ if (b.Explicit != kvi.Block.Explicit) {
//
// If a variable by the same name it defined in
a nested block of this
// block, we violate the invariant meaning in a
block.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches