dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System/CodeDom/Compiler CSharpCodeCom


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System/CodeDom/Compiler CSharpCodeCompiler.cs, 1.4, 1.5 CodeGenerator.cs, 1.5, 1.6
Date: Fri, 25 Jul 2003 03:48:14 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System/CodeDom/Compiler
In directory subversions:/tmp/cvs-serv23265/System/CodeDom/Compiler

Modified Files:
        CSharpCodeCompiler.cs CodeGenerator.cs 
Log Message:


Implement some of the missing C# code generation TODO's in CodeDom.


Index: CSharpCodeCompiler.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System/CodeDom/Compiler/CSharpCodeCompiler.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** CSharpCodeCompiler.cs       29 May 2003 01:22:39 -0000      1.4
--- CSharpCodeCompiler.cs       25 Jul 2003 07:48:11 -0000      1.5
***************
*** 28,31 ****
--- 28,32 ----
  using System.Reflection;
  using System.Globalization;
+ using System.Text;
  
  internal class CSharpCodeCompiler : CodeCompiler
***************
*** 315,318 ****
--- 316,320 ----
                                        case "System.Decimal":  type = 
"decimal"; break;
                                        case "System.String":   type = 
"string"; break;
+                                       case "System.Object":   type = 
"object"; break;
                                        default:                                
break;
                                }
***************
*** 464,472 ****
                                Output.Write(")");
                        }
-       protected override void GenerateParameterDeclarationExpression
-                               (CodeParameterDeclarationExpression e)
-                       {
-                               // TODO
-                       }
        protected override void GeneratePropertyReferenceExpression
                                (CodePropertyReferenceExpression e)
--- 466,469 ----
***************
*** 503,507 ****
        private void StartBlock()
                        {
!                               Output.WriteLine("{");
                                Indent += 1;
                        }
--- 500,512 ----
        private void StartBlock()
                        {
!                               if(Options.BracingStyle == "C")
!                               {
!                                       Output.WriteLine();
!                                       Output.WriteLine("{");
!                               }
!                               else
!                               {
!                                       Output.WriteLine(" {");
!                               }
                                Indent += 1;
                        }
***************
*** 539,543 ****
                                Output.Write("if (");
                                GenerateExpression(e.Condition);
!                               Output.WriteLine(")");
                                StartBlock();
                                GenerateStatements(e.TrueStatements);
--- 544,548 ----
                                Output.Write("if (");
                                GenerateExpression(e.Condition);
!                               Output.Write(")");
                                StartBlock();
                                GenerateStatements(e.TrueStatements);
***************
*** 546,550 ****
                                if(stmts.Count > 0 || Options.ElseOnClosing)
                                {
!                                       Output.WriteLine("else");
                                        StartBlock();
                                        GenerateStatements(stmts);
--- 551,555 ----
                                if(stmts.Count > 0 || Options.ElseOnClosing)
                                {
!                                       Output.Write("else");
                                        StartBlock();
                                        GenerateStatements(stmts);
***************
*** 578,582 ****
                                        Output.Write("while (");
                                        GenerateExpression(e.TestExpression);
!                                       Output.WriteLine(")");
                                        StartBlock();
                                        GenerateStatements(e.Statements);
--- 583,587 ----
                                        Output.Write("while (");
                                        GenerateExpression(e.TestExpression);
!                                       Output.Write(")");
                                        StartBlock();
                                        GenerateStatements(e.Statements);
***************
*** 603,607 ****
                                        }
                                        outputForInit = false;
!                                       Output.WriteLine(")");
                                        StartBlock();
                                        GenerateStatements(e.Statements);
--- 608,612 ----
                                        }
                                        outputForInit = false;
!                                       Output.Write(")");
                                        StartBlock();
                                        GenerateStatements(e.Statements);
***************
*** 657,661 ****
                                (CodeTryCatchFinallyStatement e)
                        {
!                               Output.WriteLine("try");
                                StartBlock();
                                GenerateStatements(e.TryStatements);
--- 662,666 ----
                                (CodeTryCatchFinallyStatement e)
                        {
!                               Output.Write("try");
                                StartBlock();
                                GenerateStatements(e.TryStatements);
***************
*** 675,683 ****
                                                                
OutputIdentifier(clause.LocalName);
                                                        }
!                                                       Output.WriteLine(")");
                                                }
                                                else
                                                {
!                                                       
Output.WriteLine("catch");
                                                }
                                                StartBlock();
--- 680,688 ----
                                                                
OutputIdentifier(clause.LocalName);
                                                        }
!                                                       Output.Write(")");
                                                }
                                                else
                                                {
!                                                       Output.Write("catch");
                                                }
                                                StartBlock();
***************
*** 689,693 ****
                                if(fin.Count > 0)
                                {
!                                       Output.WriteLine("finally");
                                        StartBlock();
                                        GenerateStatements(fin);
--- 694,698 ----
                                if(fin.Count > 0)
                                {
!                                       Output.Write("finally");
                                        StartBlock();
                                        GenerateStatements(fin);
***************
*** 714,723 ****
                                (CodeAttributeDeclarationCollection attributes)
                        {
!                               // TODO
                        }
        protected override void GenerateAttributeDeclarationsEnd
                                (CodeAttributeDeclarationCollection attributes)
                        {
!                               // TODO
                        }
        protected override void GenerateConstructor
--- 719,728 ----
                                (CodeAttributeDeclarationCollection attributes)
                        {
!                               Output.Write("[");
                        }
        protected override void GenerateAttributeDeclarationsEnd
                                (CodeAttributeDeclarationCollection attributes)
                        {
!                               Output.Write("]");
                        }
        protected override void GenerateConstructor
***************
*** 752,760 ****
        protected override void GenerateNamespaceStart(CodeNamespace e)
                        {
!                               // TODO
                        }
        protected override void GenerateNamespaceEnd(CodeNamespace e)
                        {
!                               // TODO
                        }
        protected override void GenerateNamespaceImport(CodeNamespaceImport e)
--- 757,775 ----
        protected override void GenerateNamespaceStart(CodeNamespace e)
                        {
!                               String name = e.Name;
!                               if(name != null && name.Length != 0)
!                               {
!                                       Output.Write("namespace ");
!                                       OutputIdentifier(name);
!                                       StartBlock();
!                               }
                        }
        protected override void GenerateNamespaceEnd(CodeNamespace e)
                        {
!                               String name = e.Name;
!                               if(name != null && name.Length != 0)
!                               {
!                                       EndBlock();
!                               }
                        }
        protected override void GenerateNamespaceImport(CodeNamespaceImport e)
***************
*** 778,782 ****
        protected override void GenerateTypeEnd(CodeTypeDeclaration e)
                        {
!                               // TODO
                        }
  
--- 793,801 ----
        protected override void GenerateTypeEnd(CodeTypeDeclaration e)
                        {
!                               if(!IsCurrentDelegate)
!                               {
!                                       --Indent;
!                                       Output.WriteLine("}");
!                               }
                        }
  
***************
*** 784,788 ****
        protected override void GenerateComment(CodeComment e)
                        {
!                               // TODO
                        }
        protected override void GenerateLinePragmaStart(CodeLinePragma e)
--- 803,842 ----
        protected override void GenerateComment(CodeComment e)
                        {
!                               String text = e.Text;
!                               String commentSeq = (e.DocComment ? "/// " : 
"// ");
!                               if(text == null)
!                               {
!                                       return;
!                               }
!                               int posn = 0;
!                               int end, next;
!                               while(posn < text.Length)
!                               {
!                                       end = posn;
!                                       next = end;
!                                       while(end < text.Length)
!                                       {
!                                               if(text[end] == '\r')
!                                               {
!                                                       if((end + 1) < 
text.Length &&
!                                                          text[end + 1] == 
'\n')
!                                                       {
!                                                               next = end + 1;
!                                                       }
!                                                       break;
!                                               }
!                                               else if(text[end] == '\n' ||
!                                                               text[end] == 
'\u2028' ||
!                                                               text[end] == 
'\u2029')
!                                               {
!                                                       break;
!                                               }
!                                               ++end;
!                                               next = end;
!                                       }
!                                       Output.Write(commentSeq);
!                                       Output.WriteLine(text.Substring(posn, 
end - posn));
!                                       posn = next + 1;
!                               }
                        }
        protected override void GenerateLinePragmaStart(CodeLinePragma e)
***************
*** 799,804 ****
        protected override String GetTypeOutput(CodeTypeReference value)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 853,878 ----
        protected override String GetTypeOutput(CodeTypeReference value)
                        {
!                               String baseType;
!                               if(value.ArrayElementType != null)
!                               {
!                                       baseType = 
GetTypeOutput(value.ArrayElementType);
!                               }
!                               else
!                               {
!                                       baseType = value.BaseType;
!                               }
!                               baseType = NormalizeTypeName(baseType);
!                               int rank = value.ArrayRank;
!                               if(rank > 0)
!                               {
!                                       baseType += "[";
!                                       while(rank > 1)
!                                       {
!                                               baseType += ",";
!                                               --rank;
!                                       }
!                                       baseType += "]";
!                               }
!                               return baseType;
                        }
  
***************
*** 806,811 ****
        protected override bool IsValidIdentifier(String value)
                        {
!                               // TODO
!                               return true;
                        }
  
--- 880,901 ----
        protected override bool IsValidIdentifier(String value)
                        {
!                               if(value == null || value.Length == 0)
!                               {
!                                       return false;
!                               }
!                               else if(Array.IndexOf(reservedWords, value) != 
-1)
!                               {
!                                       return false;
!                               }
!                               else
!                               {
!                                       return 
IsValidLanguageIndependentIdentifier(value);
!                               }
!                       }
! 
!       // Output an identifier.
!       protected override void OutputIdentifier(String ident)
!                       {
!                               Output.Write(CreateEscapedIdentifier(ident));
                        }
  
***************
*** 816,824 ****
                        }
  
        // Quote a snippet string.
        protected override String QuoteSnippetString(String value)
                        {
!                               // TODO
!                               return value;
                        }
  
--- 906,969 ----
                        }
  
+       // Hex characters for use in "QuoteSnippetString".
+       private const String hexchars = "0123456789abcdef";
+ 
        // Quote a snippet string.
        protected override String QuoteSnippetString(String value)
                        {
!                               StringBuilder builder = new 
StringBuilder(value.Length + 16);
!                               builder.Append('"');
!                               int length = 0;
!                               foreach(char ch in value)
!                               {
!                                       if(ch == '\0')
!                                       {
!                                               builder.Append("\\0");
!                                               length += 2;
!                                       }
!                                       else if(ch == '\r')
!                                       {
!                                               builder.Append("\\r");
!                                               length += 2;
!                                       }
!                                       else if(ch == '\n')
!                                       {
!                                               builder.Append("\\n");
!                                               length += 2;
!                                       }
!                                       else if(ch == '\t')
!                                       {
!                                               builder.Append("\\t");
!                                               length += 2;
!                                       }
!                                       else if(ch == '\\' || ch == '"')
!                                       {
!                                               builder.Append('\\');
!                                               builder.Append(ch);
!                                               length += 2;
!                                       }
!                                       else if(ch < 0x0020 || ch > 0x007E)
!                                       {
!                                               builder.Append('\\');
!                                               builder.Append('u');
!                                               builder.Append(hexchars[(ch >> 
12) & 0x0F]);
!                                               builder.Append(hexchars[(ch >> 
8) & 0x0F]);
!                                               builder.Append(hexchars[(ch >> 
4) & 0x0F]);
!                                               builder.Append(hexchars[ch & 
0x0F]);
!                                               length += 6;
!                                       }
!                                       else
!                                       {
!                                               builder.Append(ch);
!                                               ++length;
!                                       }
!                                       if(length >= 60)
!                                       {
!                                               builder.Append("\" +" + 
Output.NewLine + "\"");
!                                               length = 0;
!                                       }
!                               }
!                               builder.Append('"');
!                               return builder.ToString();
                        }
  

Index: CodeGenerator.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System/CodeDom/Compiler/CodeGenerator.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** CodeGenerator.cs    21 Jul 2003 10:11:58 -0000      1.5
--- CodeGenerator.cs    25 Jul 2003 07:48:11 -0000      1.6
***************
*** 191,194 ****
--- 191,198 ----
                                get
                                {
+                                       if(options == null)
+                                       {
+                                               options = new 
CodeGeneratorOptions();
+                                       }
                                        return options;
                                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]