Author: duncan
Date: 2005-06-10 01:58:45 -0400 (Fri, 10 Jun 2005)
New Revision: 45734

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/assign.cs
   trunk/mcs/mcs/convert.cs
   trunk/mcs/mcs/cs-tokenizer.cs
Log:
2005-06-10  Duncan Mak  <[EMAIL PROTECTED]>

        * cs-tokenizer.cs (process_directives): New flag for controlling
        the processing of preprocessor directives.
        (x_token): After seeing a '#', return Token.NONE instead of going
        to handle_preprocessing_directive() when not processing
        directives. This avoids unnecessary processing during the token peek in
        is_punct().

        This fixes #74939.

        * cs-tokenizer.cs (handle_preprocessing_directive, xtoken):
        Use the existing error reporting methods instead of
        Report.Error.

        * convert.cs (priv_fmt_expr): Remove. It's not needed anymore
        after Raja's rewrite.


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-06-10 05:14:06 UTC (rev 45733)
+++ trunk/mcs/mcs/ChangeLog     2005-06-10 05:58:45 UTC (rev 45734)
@@ -1,3 +1,20 @@
+2005-06-10  Duncan Mak  <[EMAIL PROTECTED]>
+
+       * cs-tokenizer.cs (process_directives): New flag for controlling
+       the processing of preprocessor directives.
+       (x_token): After seeing a '#', return Token.NONE instead of going
+       to handle_preprocessing_directive() when not processing
+       directives. This avoids unnecessary processing during the token peek in
+       is_punct().
+
+       This fixes #74939.
+
+       * cs-tokenizer.cs (handle_preprocessing_directive, xtoken): Use
+       the existing error reporting methods instead of Report.Error.
+
+       * convert.cs (priv_fmt_expr): Remove. It's not needed anymore
+       after Raja's rewrite.
+
 2005-06-08  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * class.cs: Small fix.

Modified: trunk/mcs/mcs/assign.cs
===================================================================
--- trunk/mcs/mcs/assign.cs     2005-06-10 05:14:06 UTC (rev 45733)
+++ trunk/mcs/mcs/assign.cs     2005-06-10 05:58:45 UTC (rev 45734)
@@ -442,7 +442,7 @@
                        }
                        
                        //
-                       // If this assignemnt/operator was part of a compound 
binary
+                       // If this assignment/operator was part of a compound 
binary
                        // operator, then we allow an explicit conversion, as 
detailed
                        // in the spec. 
                        //
@@ -482,8 +482,8 @@
                                        return null;
                                }
                        }
-
                        source = Convert.ImplicitConversionRequired (ec, 
source, target_type, loc);
+                       
                        if (source == null)
                                return null;
 

Modified: trunk/mcs/mcs/convert.cs
===================================================================
--- trunk/mcs/mcs/convert.cs    2005-06-10 05:14:06 UTC (rev 45733)
+++ trunk/mcs/mcs/convert.cs    2005-06-10 05:58:45 UTC (rev 45734)
@@ -816,11 +816,6 @@
                        else
                                return FindMostEncompassedType (ec, 
src_types_set);
                }
-
-               //
-               // Useful in avoiding proliferation of objects
-               //
-               static EmptyExpression priv_fmt_expr;
                
                /// <summary>
                ///  Finds the most specific target Tx according to section 
13.4.4

Modified: trunk/mcs/mcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/mcs/cs-tokenizer.cs       2005-06-10 05:14:06 UTC (rev 45733)
+++ trunk/mcs/mcs/cs-tokenizer.cs       2005-06-10 05:58:45 UTC (rev 45734)
@@ -457,7 +457,11 @@
 
                                // Save current position and parse next token.
                                int old = reader.Position;
+
+                               // disable preprocessing directives when peeking
+                               process_directives = false;
                                int new_token = token ();
+                               process_directives = true;
                                reader.Position = old;
                                putback_char = -1;
 
@@ -1543,6 +1547,11 @@
                }
                
                //
+               // Set to false to stop handling preprocesser directives
+               // 
+               bool process_directives = true;
+
+               //
                // if true, then the code continues processing the code
                // if false, the code stays in a loop until another directive is
                // reached.
@@ -1678,9 +1687,7 @@
 
                        case "else":
                                if (ifstack == null || ifstack.Count == 0){
-                                       Report.Error (
-                                               1028, Location,
-                                               "Unexpected processor directive 
(no #if for this #else)");
+                                       Error_UnexpectedDirective ("no #if for 
this #else");
                                        return true;
                                } else {
                                        int state = (int) ifstack.Peek ();
@@ -1751,7 +1758,7 @@
 
                }
 
-               private int consume_string (bool quoted) 
+               private int consume_string (bool quoted)
                {
                        int c;
                        string_builder.Length = 0;
@@ -2050,11 +2057,14 @@
                                // FIXME: In C# the '#' is not limited to appear
                                // on the first column.
                                if (c == '#') {
+                                       // return NONE if we're not processing 
directives (during token peeks)
+                                       if (!process_directives)
+                                               return Token.NONE;
+
                                        bool cont = true;
-                                       
                                        if (tokens_seen || comments_seen) {
-                                               error_details = "Preprocessor 
directives must appear as the first non-whitespace " +
-                                                       "character on a line.";
+                                               error_details = "Preprocessor 
directives must appear as the first" +
+                                              " non-whitespace character on a 
line.";
 
                                                Report.Error (1040, Location, 
error_details);
 

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

Reply via email to