[svn] r6062: nemerle/trunk/ncc/codedom: NemerleCodeCompiler.n
NemerleCodeGenerator.n
malekith
svnadmin at nemerle.org
Fri Jan 20 19:03:24 CET 2006
Log:
Handle 'partial' modifier generated by xsp2 properly. Properly handle files passed to compilation. Patch by Kanru Chen.
Author: malekith
Date: Fri Jan 20 19:03:23 2006
New Revision: 6062
Modified:
nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n
nemerle/trunk/ncc/codedom/NemerleCodeGenerator.n
Modified: nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n
==============================================================================
--- nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n (original)
+++ nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n Fri Jan 20 19:03:23 2006
@@ -39,6 +39,7 @@
using System.Configuration;
using System.IO;
using System.Text;
+using System.Text.RegularExpressions;
using System.Reflection;
using System.Collections;
using System.Collections.Specialized;
@@ -46,6 +47,7 @@
using Nemerle.Assertions;
using Nemerle.Collections;
+using Nemerle.Utility;
namespace Nemerle.Compiler
{
@@ -125,6 +127,15 @@
err_event (true, loc, msg);
}
+ mutable files = [];
+ def opts = Options.GetCommonOptions () + [
+ Getopt.CliOption.NonOption (name = "",
+ help = "Specify file to compile",
+ handler = fun (s) { files = s :: files })
+ ];
+ Getopt.Parse (Message.Error, opts,
+ List.FromArray (Regex.Split (options.CompilerOptions, @"\s")).Filter (fun (t) {t.Length > 0}));
+
def fullOutput = System.IO.StringWriter ();
Message.InitOutput (fullOutput);
Options.ProgressBar = false;
@@ -144,7 +155,7 @@
if (fileNames.Length < 1)
Message.Error ("need at least one file to compile");
else {
- Options.Sources = List.FromArray (fileNames);
+ Options.Sources = files + List.FromArray (fileNames);
Passes.Run ();
succeeded = !failed;
}
Modified: nemerle/trunk/ncc/codedom/NemerleCodeGenerator.n
==============================================================================
--- nemerle/trunk/ncc/codedom/NemerleCodeGenerator.n (original)
+++ nemerle/trunk/ncc/codedom/NemerleCodeGenerator.n Fri Jan 20 19:03:23 2006
@@ -556,6 +556,56 @@
Output.Write("mutable ");
}
+ private OutputTypeAttributes (declaration : CodeTypeDeclaration) : void
+ {
+ def output = Output;
+ def attributes = declaration.TypeAttributes;
+
+ match (attributes & TypeAttributes.VisibilityMask) {
+ | TypeAttributes.Public
+ | TypeAttributes.NestedPublic =>
+ output.Write ("public ");
+ | TypeAttributes.NestedPrivate =>
+ output.Write ("private ");
+ | TypeAttributes.NotPublic
+ | TypeAttributes.NestedFamANDAssem
+ | TypeAttributes.NestedAssembly =>
+ output.Write ("internal ");
+ | TypeAttributes.NestedFamily =>
+ output.Write ("protected ");
+ | TypeAttributes.NestedFamORAssem =>
+ output.Write ("protected internal ");
+ | _ =>
+ ();
+ }
+
+ match (declaration) {
+ | d when d.IsStruct =>
+ when (d.IsPartial) {
+ output.Write ("partial ");
+ }
+ output.Write ("struct ");
+ | d when d.IsEnum =>
+ output.Write ("enum ");
+ | _ =>
+ if ((attributes & TypeAttributes.Interface) != 0) {
+ when (declaration.IsPartial) {
+ output.Write ("partial ");
+ }
+ output.Write ("interface ");
+ } else {
+ when ((attributes & TypeAttributes.Sealed) != 0)
+ output.Write ("sealed ");
+ when ((attributes & TypeAttributes.Abstract) != 0)
+ output.Write ("abstract ");
+ when (declaration.IsPartial) {
+ output.Write ("partial ");
+ }
+ output.Write ("class ");
+ }
+ }
+ }
+
protected override GenerateSnippetMember (member : CodeSnippetTypeMember) : void
{
Output.Write (member.Text);
@@ -749,10 +799,7 @@
when (declaration.CustomAttributes.Count > 0)
OutputAttributeDeclarations ( declaration.CustomAttributes );
- def attributes = declaration.TypeAttributes;
- OutputTypeAttributes (attributes,
- declaration.IsStruct,
- declaration.IsEnum );
+ OutputTypeAttributes (declaration);
output.Write (GetSafeName (declaration.Name));
More information about the svn
mailing list