2003-05-11 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Sun, 11 May 2003 20:07:59 +0000 (20:07 -0000)
committerMartin Baulig <martin@novell.com>
Sun, 11 May 2003 20:07:59 +0000 (20:07 -0000)
* statement.cs (Block.CreateSwitchBlock): New method.  Creates a
new block for a switch section.
(Block.AddLabel, Block.LookupLabel): If we're a switch section, do
the adding/lookup in the switch block.  Fixes #39828.

svn path=/trunk/mcs/; revision=14495

mcs/mcs/ChangeLog
mcs/mcs/cs-parser.jay
mcs/mcs/statement.cs

index a8d7ef3060d3e103301907104cd622a5336da441..36081b6bece33707e079324f0f992b88fdc96dd6 100755 (executable)
@@ -1,3 +1,10 @@
+2003-05-11  Martin Baulig  <martin@ximian.com>
+
+       * statement.cs (Block.CreateSwitchBlock): New method.  Creates a
+       new block for a switch section.
+       (Block.AddLabel, Block.LookupLabel): If we're a switch section, do
+       the adding/lookup in the switch block.  Fixes #39828.
+
 2003-05-09  Miguel de Icaza  <miguel@ximian.com>
 
        * expression.cs (UnaryMutator.LoadOneAndEmitOp): Missing
index 587379855bddd982932b279f01b20bc1b95ab17e..cd5ab6df48fe746a38d3d39af7d3f3745158b12f 100755 (executable)
@@ -3037,7 +3037,7 @@ switch_sections
 switch_section
        : switch_labels
          {
-               current_block = new Block (current_block, lexer.Location, lexer.Location);
+               current_block = current_block.CreateSwitchBlock (lexer.Location);
          }
          statement_list 
          {
index ca99e97ca4f6119f65d3f724cf71a3293aadd161..caaa8bf1371605f116700549b87719c387c18158 100755 (executable)
@@ -2600,6 +2600,11 @@ namespace Mono.CSharp {
                // Keeps track of constants
                Hashtable constants;
 
+               //
+               // If this is a switch section, the enclosing switch block.
+               //
+               Block switch_block;
+
                bool used = false;
 
                static int id;
@@ -2646,6 +2651,13 @@ namespace Mono.CSharp {
                        statements = new ArrayList ();
                }
 
+               public Block CreateSwitchBlock (Location start)
+               {
+                       Block new_block = new Block (this, start, start);
+                       new_block.switch_block = this;
+                       return new_block;
+               }
+
                public int ID {
                        get {
                                return this_id;
@@ -2676,6 +2688,9 @@ namespace Mono.CSharp {
                ///
                public bool AddLabel (string name, LabeledStatement target)
                {
+                       if (switch_block != null)
+                               return switch_block.AddLabel (name, target);
+
                        if (labels == null)
                                labels = new Hashtable ();
                        if (labels.Contains (name))
@@ -2687,6 +2702,9 @@ namespace Mono.CSharp {
 
                public LabeledStatement LookupLabel (string name)
                {
+                       if (switch_block != null)
+                               return switch_block.LookupLabel (name);
+
                        if (labels != null){
                                if (labels.Contains (name))
                                        return ((LabeledStatement) labels [name]);