Author: marek
Date: 2007-02-20 17:09:17 -0500 (Tue, 20 Feb 2007)
New Revision: 73219

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:
2007-02-20  Marek Safar  <[EMAIL PROTECTED]>

        A fix for bug #80650
        * cs-parser.jay: Anonymous container starts at constructor declaration
        and not at block beginning because it has to be usable in constructor
        initializer.

        * statement.cs: Use context location and not block one for error 
reporting.


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2007-02-20 21:55:23 UTC (rev 73218)
+++ trunk/mcs/gmcs/ChangeLog    2007-02-20 22:09:17 UTC (rev 73219)
@@ -1,3 +1,10 @@
+2007-02-20  Marek Safar  <[EMAIL PROTECTED]>
+
+       A fix for bug #80650
+       * cs-parser.jay: Anonymous container starts at constructor declaration
+       and not at block beginning because it has to be usable in constructor
+       initializer.
+
 2007-02-18  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #80493 by Atsushi Enomoto

Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay        2007-02-20 21:55:23 UTC (rev 73218)
+++ trunk/mcs/gmcs/cs-parser.jay        2007-02-20 22:09:17 UTC (rev 73219)
@@ -4,6 +4,7 @@
 //
 // Authors: Miguel de Icaza ([EMAIL PROTECTED])
 //          Ravi Pratap     ([EMAIL PROTECTED])
+//          Marek Safar                ([EMAIL PROTECTED])
 //
 // Licensed under the terms of the GNU GPL
 //
@@ -2285,6 +2286,18 @@
        ;
 
 constructor_declarator
+       : constructor_header
+         {
+               $$ = $1;
+         }
+       | constructor_header constructor_initializer
+         {
+               ((Constructor)$1).Initializer = (ConstructorInitializer) $2;
+               $$ = $1;
+         }
+       ;
+
+constructor_header
        : IDENTIFIER
          {
                if (RootContext.Documentation != null) {
@@ -2295,27 +2308,22 @@
          open_parens opt_formal_parameter_list CLOSE_PARENS
          {
                current_local_parameters = (Parameters) $4;
-         }
-         opt_constructor_initializer
-         {
+               current_block = top_current_block = new ToplevelBlock (null,
+                       current_local_parameters, null, Location.Null);
+                       
                LocatedToken lt = (LocatedToken) $1;
-               $$ = new Constructor (current_class, lt.Value, 0, (Parameters) 
$4,
-                                     (ConstructorInitializer) $7, lt.Location);
+               $$ = new Constructor (current_class, lt.Value, 0, 
current_local_parameters,
+                                     null, lt.Location);
 
                anonymous_host = (IAnonymousHost) $$;
          }
        ;
 
 constructor_body
-       : block
-       | SEMICOLON             { $$ = null; }
+       : block_prepared
+       | SEMICOLON             { current_block = top_current_block = null; $$ 
= null; }
        ;
 
-opt_constructor_initializer
-       : /* empty */                   { $$ = null; }
-       | constructor_initializer
-       ;
-
 constructor_initializer
        : COLON BASE open_parens opt_argument_list CLOSE_PARENS
          {
@@ -3518,7 +3526,7 @@
        ;
 
 opt_anonymous_method_parameter_list
-       : /* empty */   { $$ = null; } 
+       : /* empty */                      { $$ = null; } 
        | anonymous_method_parameter_list  { $$ = $1; }
        ;
 
@@ -4192,6 +4200,14 @@
          }
        ;
 
+block_prepared
+       : OPEN_BRACE 
+         opt_statement_list CLOSE_BRACE 
+         { 
+               $$ = end_block ((Location) $3);
+         }
+       ;
+
 opt_statement_list
        : /* empty */
        | statement_list 

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-02-20 21:55:23 UTC (rev 73218)
+++ trunk/mcs/mcs/ChangeLog     2007-02-20 22:09:17 UTC (rev 73219)
@@ -1,3 +1,12 @@
+2007-02-20  Marek Safar  <[EMAIL PROTECTED]>
+
+       A fix for bug #80650
+       * cs-parser.jay: Anonymous container starts at constructor declaration
+       and not at block beginning because it has to be usable in constructor
+       initializer.
+
+       * statement.cs: Use context location and not block one for error 
reporting.
+
 2007-02-18  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #78712

Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2007-02-20 21:55:23 UTC (rev 73218)
+++ trunk/mcs/mcs/cs-parser.jay 2007-02-20 22:09:17 UTC (rev 73219)
@@ -4,6 +4,7 @@
 //
 // Authors: Miguel de Icaza ([EMAIL PROTECTED])
 //          Ravi Pratap     ([EMAIL PROTECTED])
+//          Marek Safar                ([EMAIL PROTECTED])
 //
 // Licensed under the terms of the GNU GPL
 //
@@ -74,7 +75,7 @@
                bool parsing_indexer;
 
                bool parsing_anonymous_method;
-
+               
                ///
                /// An out-of-band stack.
                ///
@@ -2129,6 +2130,18 @@
        ;
 
 constructor_declarator
+       : constructor_header
+         {
+               $$ = $1;
+         }
+       | constructor_header constructor_initializer
+         {
+               ((Constructor)$1).Initializer = (ConstructorInitializer) $2;
+               $$ = $1;
+         }
+       ;
+
+constructor_header
        : IDENTIFIER
          {
                if (RootContext.Documentation != null) {
@@ -2139,27 +2152,22 @@
          open_parens opt_formal_parameter_list CLOSE_PARENS
          {
                current_local_parameters = (Parameters) $4;
-         }
-         opt_constructor_initializer
-         {
+               current_block = top_current_block = new ToplevelBlock (null,
+                       current_local_parameters, null, Location.Null);
+                       
                LocatedToken lt = (LocatedToken) $1;
-               $$ = new Constructor (current_class, lt.Value, 0, (Parameters) 
$4,
-                                     (ConstructorInitializer) $7, lt.Location);
-
+               $$ = new Constructor (current_class, lt.Value, 0, 
current_local_parameters,
+                                     null, lt.Location);
+                                     
                anonymous_host = (IAnonymousHost) $$;
          }
        ;
 
 constructor_body
-       : block
-       | SEMICOLON             { $$ = null; }
+       : block_prepared
+       | SEMICOLON             { current_block = top_current_block = null; $$ 
= null; }
        ;
 
-opt_constructor_initializer
-       : /* empty */                   { $$ = null; }
-       | constructor_initializer
-       ;
-
 constructor_initializer
        : COLON BASE open_parens opt_argument_list CLOSE_PARENS
          {
@@ -2756,7 +2764,6 @@
          {
                // 7.5.1: Literals
          }
- 
        | member_name
          {
                MemberName mn = (MemberName) $1;
@@ -3800,6 +3807,14 @@
          }
        ;
 
+block_prepared
+       : OPEN_BRACE 
+         opt_statement_list CLOSE_BRACE 
+         { 
+               $$ = end_block ((Location) $3);
+         }
+       ;
+
 opt_statement_list
        : /* empty */
        | statement_list 
@@ -5136,8 +5151,7 @@
 
 static GenericMethod current_generic_method = null;
 
-void 
-start_block (Location loc)
+void start_block (Location loc)
 {
        if (parsing_anonymous_method) {
                top_current_block = new ToplevelBlock (

Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs  2007-02-20 21:55:23 UTC (rev 73218)
+++ trunk/mcs/mcs/statement.cs  2007-02-20 22:09:17 UTC (rev 73219)
@@ -1213,7 +1213,7 @@
                                ec.DefineLocalVariable (name, builder);
                }
 
-               public bool IsThisAssigned (EmitContext ec, Location loc)
+               public bool IsThisAssigned (EmitContext ec)
                {
                        if (VariableInfo == null)
                                throw new Exception ();
@@ -1221,7 +1221,7 @@
                        if (!ec.DoFlowAnalysis || 
ec.CurrentBranching.IsAssigned (VariableInfo))
                                return true;
 
-                       return VariableInfo.TypeInfo.IsFullyInitialized 
(ec.CurrentBranching, VariableInfo, loc);
+                       return VariableInfo.TypeInfo.IsFullyInitialized 
(ec.CurrentBranching, VariableInfo, ec.loc);
                }
 
                public bool IsAssigned (EmitContext ec)
@@ -2735,7 +2735,7 @@
 
                public bool IsThisAssigned (EmitContext ec)
                {
-                       return this_variable == null || 
this_variable.IsThisAssigned (ec, loc);
+                       return this_variable == null || 
this_variable.IsThisAssigned (ec);
                }
 
                public bool ResolveMeta (EmitContext ec, Parameters ip)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to