From 048c6c06015963e32aa3f355a98661dca8b189b6 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 11 May 2003 20:07:59 +0000 Subject: [PATCH] 2003-05-11 Martin Baulig * 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 | 7 +++++++ mcs/mcs/cs-parser.jay | 2 +- mcs/mcs/statement.cs | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index a8d7ef3060d..36081b6bece 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,10 @@ +2003-05-11 Martin Baulig + + * 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 * expression.cs (UnaryMutator.LoadOneAndEmitOp): Missing diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 587379855bd..cd5ab6df48f 100755 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -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 { diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index ca99e97ca4f..caaa8bf1371 100755 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -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]); -- 2.25.1