diff options
author | Marek Safar <marek.safar@gmail.com> | 2004-09-01 22:45:52 +0400 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2004-09-01 22:45:52 +0400 |
commit | fb98c026008f10137b0852fba81d524f8a477a65 (patch) | |
tree | a5bc08207db2958e5056c94dbef3bbc03fb5f998 /mcs/class | |
parent | ce528ab34fa2949946208685c28958495bf5af7a (diff) |
I fixed mono CodeDom bugs to pass on the latest Microsoft CodeDom Test Suite.
svn path=/trunk/mcs/; revision=33172
Diffstat (limited to 'mcs/class')
8 files changed, 86 insertions, 26 deletions
diff --git a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs index c22c8fc653d..9bb5a5b767d 100644 --- a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs +++ b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs @@ -40,11 +40,16 @@ namespace Mono.CSharp internal class CSharpCodeGenerator : CodeGenerator { + + // It is used for beautiful "for" syntax + bool dont_write_semicolon; + // // Constructors // public CSharpCodeGenerator() { + dont_write_semicolon = false; } // @@ -87,7 +92,7 @@ namespace Mono.CSharp OutputType( createType ); - output.WriteLine( "[] {" ); + output.WriteLine( "{" ); ++Indent; OutputExpressionList( initializers, true ); --Indent; @@ -278,13 +283,16 @@ namespace Mono.CSharp protected override void GenerateExpressionStatement( CodeExpressionStatement statement ) { GenerateExpression( statement.Expression ); + if (dont_write_semicolon) + return; Output.WriteLine( ';' ); } protected override void GenerateIterationStatement( CodeIterationStatement statement ) { TextWriter output = Output; - + + dont_write_semicolon = true; output.Write( "for (" ); GenerateStatement( statement.InitStatement ); output.Write( "; " ); @@ -292,7 +300,12 @@ namespace Mono.CSharp output.Write( "; " ); GenerateStatement( statement.IncrementStatement ); output.Write( ") " ); + dont_write_semicolon = false; + output.WriteLine ('{'); + ++Indent; GenerateStatements( statement.Statements ); + --Indent; + output.WriteLine ('}'); } protected override void GenerateThrowExceptionStatement( CodeThrowExceptionStatement statement ) @@ -410,6 +423,8 @@ namespace Mono.CSharp GenerateExpression( statement.Left ); output.Write( " = " ); GenerateExpression( statement.Right ); + if (dont_write_semicolon) + return; output.WriteLine( ';' ); } @@ -485,6 +500,9 @@ namespace Mono.CSharp protected override void GenerateEvent( CodeMemberEvent eventRef, CodeTypeDeclaration declaration ) { + if (eventRef.CustomAttributes.Count > 0) + OutputAttributeDeclarations (eventRef.CustomAttributes); + OutputMemberAccessModifier (eventRef.Attributes); OutputMemberScopeModifier (eventRef.Attributes | MemberAttributes.Final); // Don't output "virtual" Output.Write ("event "); @@ -499,14 +517,15 @@ namespace Mono.CSharp if (field.CustomAttributes.Count > 0) OutputAttributeDeclarations( field.CustomAttributes ); - MemberAttributes attributes = field.Attributes; - OutputMemberAccessModifier( attributes ); - OutputFieldScopeModifier( attributes ); - if (IsCurrentEnum) Output.Write(field.Name); - else + else { + MemberAttributes attributes = field.Attributes; + OutputMemberAccessModifier( attributes ); + OutputFieldScopeModifier( attributes ); + OutputTypeNamePair( field.Type, GetSafeName (field.Name) ); + } CodeExpression initExpression = field.InitExpression; if ( initExpression != null ) { @@ -642,6 +661,9 @@ namespace Mono.CSharp protected override void GenerateConstructor( CodeConstructor constructor, CodeTypeDeclaration declaration ) { + if (constructor.CustomAttributes.Count > 0) + OutputAttributeDeclarations (constructor.CustomAttributes); + OutputMemberAccessModifier (constructor.Attributes); Output.Write (GetSafeName (CurrentTypeName) + " ("); OutputParameters (constructor.Parameters); @@ -796,6 +818,7 @@ namespace Mono.CSharp Output.Write( GetTypeOutput( type ) ); } + [MonoTODO ("Implement missing special characters")] protected override string QuoteSnippetString( string value ) { // FIXME: this is weird, but works. @@ -882,59 +905,60 @@ namespace Mono.CSharp if ( arrayType != null ) output = GetTypeOutput( arrayType ); else { - switch ( type.BaseType ) { - case "System.Decimal": + switch ( type.BaseType.ToLower (System.Globalization.CultureInfo.InvariantCulture)) { + + case "system.decimal": output = "decimal"; break; - case "System.Double": + case "system.double": output = "double"; break; - case "System.Single": + case "system.single": output = "float"; break; - case "System.Byte": + case "system.byte": output = "byte"; break; - case "System.SByte": + case "system.sbyte": output = "sbyte"; break; - case "System.Int32": + case "system.int32": output = "int"; break; - case "System.UInt32": + case "system.uint32": output = "uint"; break; - case "System.Int64": + case "system.int64": output = "long"; break; - case "System.UInt64": + case "system.uint64": output = "ulong"; break; - case "System.Int16": + case "system.int16": output = "short"; break; - case "System.UInt16": + case "system.uint16": output = "ushort"; break; - case "System.Boolean": + case "system.boolean": output = "bool"; break; - case "System.Char": + case "system.char": output = "char"; break; - case "System.String": + case "system.string": output = "string"; break; - case "System.Object": + case "system.object": output = "object"; break; - case "System.Void": + case "system.void": output = "void"; break; @@ -954,7 +978,7 @@ namespace Mono.CSharp output += "]"; } - return output; + return output.Replace ('+', '.'); } protected override bool IsValidIdentifier ( string identifier ) diff --git a/mcs/class/System/Microsoft.CSharp/ChangeLog b/mcs/class/System/Microsoft.CSharp/ChangeLog index 611bee1616e..1fd92b908e0 100644 --- a/mcs/class/System/Microsoft.CSharp/ChangeLog +++ b/mcs/class/System/Microsoft.CSharp/ChangeLog @@ -1,3 +1,13 @@ +2004-09-01 Marek Safar <marek.safar@seznam.cz> + + * CSharpCodeGenerator.cs : New private member dont_write_semicolon. + Used for one row "for" syntax. + (GenerateEvent): Added attributes output. + (GenerateField): Don't output access and scope modifier for enum field. + (GenerateConstructor): Added attributes output. + (QuoteSnippetString): Fixed mixed case type conversion. Replace '+' + with '.' for nested classes. + 2004-07-21 Lluis Sanchez Gual <lluis@novell.com> * CSharpCodeCompiler.cs: Hack to make code generation work in 2.0. diff --git a/mcs/class/System/System.CodeDom.Compiler/ChangeLog b/mcs/class/System/System.CodeDom.Compiler/ChangeLog index a2f6ee391a4..6956bd1fff9 100755 --- a/mcs/class/System/System.CodeDom.Compiler/ChangeLog +++ b/mcs/class/System/System.CodeDom.Compiler/ChangeLog @@ -1,3 +1,9 @@ +2004-09-01 Marek Safar <marek.safar@seznam.cz> + + * CodeGenerator.cs : Added newline after global attributes output. + (OutputAttributeDeclaration): Replace '+' with '.' for nested + attribute types. + 2004-08-09 Atsushi Enomoto <atsushi@ximian.com> * CodeGenerator.cs : diff --git a/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs index b3f563211bb..9b051bae070 100755 --- a/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs +++ b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs @@ -199,6 +199,7 @@ namespace System.CodeDom.Compiler { OutputAttributeDeclaration (att); GenerateAttributeDeclarationsEnd (attributes); } + output.WriteLine (); } foreach (CodeNamespace ns in compileUnit.Namespaces) @@ -642,7 +643,7 @@ namespace System.CodeDom.Compiler { private void OutputAttributeDeclaration (CodeAttributeDeclaration attribute) { - output.Write (attribute.Name); + output.Write (attribute.Name.Replace ('+', '.')); output.Write ('('); IEnumerator enumerator = attribute.Arguments.GetEnumerator(); if (enumerator.MoveNext()) { diff --git a/mcs/class/System/System.CodeDom/ChangeLog b/mcs/class/System/System.CodeDom/ChangeLog index 4db765c3319..450d15fdba0 100644 --- a/mcs/class/System/System.CodeDom/ChangeLog +++ b/mcs/class/System/System.CodeDom/ChangeLog @@ -1,3 +1,14 @@ +2004-09-01 Marek Safar <marek.safar@seznam.cz> + + * CodeCatchClause.cs: System.Exception is default type + for string constructor. + + * CodeTypeMember.cs: Default member attributes are + private and final. + + * CodeTypeReference.cs: Implemented array info extraction + from Type. + 2004-08-09 Gonzalo Paniagua Javier <gonzalo@ximian.com> * CodeEntryPointMethod.cs: patch by Fawad Halim that makes the entry diff --git a/mcs/class/System/System.CodeDom/CodeCatchClause.cs b/mcs/class/System/System.CodeDom/CodeCatchClause.cs index 683185376d4..20713c07348 100755 --- a/mcs/class/System/System.CodeDom/CodeCatchClause.cs +++ b/mcs/class/System/System.CodeDom/CodeCatchClause.cs @@ -52,6 +52,7 @@ namespace System.CodeDom public CodeCatchClause ( string localName ) { this.localName = localName; + this.catchExceptionType = new CodeTypeReference (typeof (Exception)); } public CodeCatchClause ( string localName, diff --git a/mcs/class/System/System.CodeDom/CodeTypeMember.cs b/mcs/class/System/System.CodeDom/CodeTypeMember.cs index 088901d3371..829c131779c 100755 --- a/mcs/class/System/System.CodeDom/CodeTypeMember.cs +++ b/mcs/class/System/System.CodeDom/CodeTypeMember.cs @@ -50,6 +50,7 @@ namespace System.CodeDom // public CodeTypeMember() { + attributes = (MemberAttributes.Private | MemberAttributes.Final); } // diff --git a/mcs/class/System/System.CodeDom/CodeTypeReference.cs b/mcs/class/System/System.CodeDom/CodeTypeReference.cs index 9d507f43593..88c0d1d5418 100644 --- a/mcs/class/System/System.CodeDom/CodeTypeReference.cs +++ b/mcs/class/System/System.CodeDom/CodeTypeReference.cs @@ -45,6 +45,7 @@ namespace System.CodeDom // // Constructors // + [MonoTODO ("Missing implementation. Implement array info extraction from the string")] public CodeTypeReference( string baseType ) { this.baseType = baseType; @@ -52,6 +53,11 @@ namespace System.CodeDom public CodeTypeReference( Type baseType ) { + if (baseType.IsArray) { + this.rank = baseType.GetArrayRank (); + this.arrayType = new CodeTypeReference (baseType.GetElementType ()); + return; + } this.baseType = baseType.FullName; } |