[svn] r7268: nemerle/trunk/tools/reflector-addon:
reflector-addon.nproj src/AssemblyInfo.n src/CustomAttri...
pbludov
svnadmin at nemerle.org
Mon Jan 15 08:28:44 CET 2007
Log:
reflector-addon changes. Parameter declarations & method bodies (incomplete).
Author: pbludov
Date: Mon Jan 15 08:28:39 2007
New Revision: 7268
Modified:
nemerle/trunk/tools/reflector-addon/reflector-addon.nproj
nemerle/trunk/tools/reflector-addon/src/AssemblyInfo.n
nemerle/trunk/tools/reflector-addon/src/CustomAttributeWrapper.n
nemerle/trunk/tools/reflector-addon/src/Helper.n
nemerle/trunk/tools/reflector-addon/src/Language.n
nemerle/trunk/tools/reflector-addon/src/LanguageWriter.n
nemerle/trunk/tools/reflector-addon/src/LanguageWriterConfiguration.n
Modified: nemerle/trunk/tools/reflector-addon/reflector-addon.nproj
==============================================================================
--- nemerle/trunk/tools/reflector-addon/reflector-addon.nproj (original)
+++ nemerle/trunk/tools/reflector-addon/reflector-addon.nproj Mon Jan 15 08:28:39 2007
@@ -40,28 +40,37 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
- <Reference Include="..\..\boot\Nemerle.dll" />
- <Reference Include="lib\Reflector.exe" />
+ <Reference Include="Nemerle">
+ <Name>Nemerle</Name>
+ <AssemblyName>Nemerle.dll</AssemblyName>
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\boot\Nemerle.dll</HintPath>
+ </Reference>
+ <Reference Include="Reflector">
+ <Name>Reflector</Name>
+ <AssemblyName>Reflector.exe</AssemblyName>
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\Reflector.exe</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="src\" />
<Folder Include="src\CodeModel\" />
</ItemGroup>
<ItemGroup>
- <Compile Include="src\Package.n" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="src\Language.n" />
- </ItemGroup>
- <ItemGroup>
<Compile Include="src\CodeModel\LanguageWriterBase.n" />
<Compile Include="src\CodeModel\VisitorBase.n" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Include="src\AssemblyInfo.n" />
<Compile Include="src\CustomAttributeWrapper.n" />
<Compile Include="src\Helper.n " />
+ <Compile Include="src\Language.n" />
<Compile Include="src\LanguageWriter.n" />
<Compile Include="src\LanguageWriterConfiguration.n" />
+ <Compile Include="src\Package.n" />
<Compile Include="src\UsingNamespaceVisitor.n" />
</ItemGroup>
+
<Import Project="..\..\boot\Nemerle.MSBuild.targets" />
</Project>
\ No newline at end of file
Modified: nemerle/trunk/tools/reflector-addon/src/AssemblyInfo.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/AssemblyInfo.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/AssemblyInfo.n Mon Jan 15 08:28:39 2007
@@ -37,48 +37,22 @@
//
[assembly: AssemblyTitle ("Reflector.NemerleLanguage")]
[assembly: AssemblyDescription("Nemerle (http://nemerle.org) Language for Reflector")]
-[assembly: AssemblyCompany ("University of Wroclaw")]
[assembly: AssemblyProduct ("Reflector.NemerleLanguage")]
[assembly: AssemblyCopyright ("Copyright \xA9 University of Wroclaw 2003-2007.")]
+// Lutz uses this attribute as the destination for crash reporting.
//
-// Version information for an assembly consists of the following four values:
+[assembly: AssemblyCompany ("mailto:devel-en at nemerle.org")]
+
+// Compatible with Reflector.exe version 4.2.
+//
+[assembly: AssemblyInformationalVersion("4.2.0.0")]
+
+// Real version.
+//
+[assembly: AssemblyVersion("4.2.0.*")]
+
+// Signing.
//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("4.2.0.0")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-//[assembly: AssemblyDelaySign(false)]
-//[assembly: AssemblyKeyFile("..\\..\\..\\Nemerle.snk")]
-//[assembly: AssemblyKeyName("")]
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile(@"..\..\misc\keys\Nemerle.snk")]
Modified: nemerle/trunk/tools/reflector-addon/src/CustomAttributeWrapper.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/CustomAttributeWrapper.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/CustomAttributeWrapper.n Mon Jan 15 08:28:39 2007
@@ -65,6 +65,29 @@
);
}
}
+ | Parameter
+ {
+ [Accessor] mutable _isIn : bool;
+ [Accessor] mutable _isOut : bool;
+ [Accessor] mutable _isOptional : bool;
+ [Accessor] mutable _isParamArray : bool;
+
+ public this(value : IParameterDeclaration)
+ {
+ Init(value.Attributes, attr =>
+ {
+ match (attr.Constructor.DeclaringType.GetTypeName())
+ {
+ | ("System.Runtime.InteropServices", "InAttribute") => _isIn = true; true;
+ | ("System.Runtime.InteropServices", "OutAttribute") => _isOut = true; true;
+ | ("System.Runtime.InteropServices", "OptionalAttribute") => _isOptional = true; true;
+ | ("System", "ParamArrayAttribute") => _isParamArray = true; true;
+ | _ => false
+ }
+ }
+ );
+ }
+ }
| Type
{
[Accessor] mutable _typeAlias : string;
Modified: nemerle/trunk/tools/reflector-addon/src/Helper.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/Helper.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/Helper.n Mon Jan 15 08:28:39 2007
@@ -41,6 +41,21 @@
value.Name == ".ctor" || value.Name == ".cctor";
}
+ public IsGenerated(this value : IMemberReference) : bool
+ {
+ value.Name.StartsWith("_N_");
+ }
+
+ public IsGenerated(this value : IParameterReference) : bool
+ {
+ value.Name.StartsWith("_N_");
+ }
+
+ public IsGenerated(this value : ITypeReference) : bool
+ {
+ value.Name.StartsWith("_N_");
+ }
+
public IsInterface(this value : IType) : bool
{
| typeRef is ITypeReference =>
@@ -149,6 +164,24 @@
value.DeclaringType.GetUserFriendlyName() + "." + value.Name
}
+ public GetAssembly(this value : ITypeReference) : IAssemblyReference
+ {
+ match (value.Owner)
+ {
+ | null => null;
+ | tyref is ITypeReference => GetAssembly(tyref);
+ | modref is IModuleReference =>
+ match (modref.Resolve())
+ {
+ | null => null;
+ | mod => mod.Assembly;
+ }
+ | asmref is IAssemblyReference => asmref;
+ | _ => throw NotSupportedException();
+ }
+ }
+
+
public static GetVisibility(this value : IEventDeclaration) : MethodVisibility
{
def addMethod = if (value.AddMethod != null) value.AddMethod.Resolve() else null;
Modified: nemerle/trunk/tools/reflector-addon/src/Language.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/Language.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/Language.n Mon Jan 15 08:28:39 2007
@@ -52,7 +52,7 @@
public Translate : bool
{
- get { false }
+ get { true }
}
}
}
Modified: nemerle/trunk/tools/reflector-addon/src/LanguageWriter.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/LanguageWriter.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/LanguageWriter.n Mon Jan 15 08:28:39 2007
@@ -65,8 +65,7 @@
Write($", Version $(value.Version)");
WriteLine();
-
- WriteCustomAttributeList(value.Attributes.ToList(), "assembly");
+ WriteCustomAttributeList(value);
WriteProperty("Location", value.Location);
WriteProperty("Name", value.ToString());
@@ -96,7 +95,7 @@
WriteDeclaration(value.Name);
WriteLine();
- WriteCustomAttributeList(value.Attributes.ToList(), "module");
+ WriteCustomAttributeList(value);
WriteProperty("Version", value.Version.ToString());
WriteProperty("Location", value.Location);
@@ -382,7 +381,7 @@
public override WriteEventDeclaration([NotNull] value : IEventDeclaration) : void
{
WriteDocumentation(value);
- WriteCustomAttributeList(value.Attributes.ToList());
+ WriteCustomAttributeList(value);
unless (value.DeclaringType.IsInterface())
WriteMethodVisibility(value.GetVisibility());
@@ -392,13 +391,16 @@
WriteDeclaration(value.Name);
Write(" : ");
WriteType(value.EventType);
- WriteLine(";");
+ Write(";");
+
+ when (_configuration.ShowMethodDeclarationBody)
+ WriteDeclaringTypeProperties(value.DeclaringType :> ITypeReference);
}
public override WriteFieldDeclaration(value : IFieldDeclaration) : void
{
WriteDocumentation(value);
- WriteCustomAttributeList(value.Attributes.ToList());
+ WriteCustomAttributeList(value);
match (value.GetVisibility())
{
@@ -440,7 +442,10 @@
WriteExpression(value.Initializer);
}
- WriteLine(";");
+ Write(";");
+
+ when (_configuration.ShowMethodDeclarationBody)
+ WriteDeclaringTypeProperties(value.DeclaringType :> ITypeReference);
}
public override WriteMethodDeclaration(value : IMethodDeclaration) : void
@@ -448,9 +453,10 @@
def wrapper = CustomAttributeWrapper.Method(value);
WriteDocumentation(value);
WriteCustomAttributeList(wrapper.Attributes);
- WriteCustomAttributeList(value.ReturnType.Attributes.ToList(), "return");
+ WriteCustomAttributeList(value.ReturnType);
unless (value.DeclaringType.IsInterface())
+ {
WriteMethodVisibility(value.GetVisibility());
when (value.Static)
@@ -458,6 +464,7 @@
WriteKeyword("static");
Write(" ");
}
+ }
if (value.IsConstructor())
{
@@ -492,13 +499,17 @@
WriteList(overrides, WriteMethodReference);
}
}
- WriteLine(";");
+
+ WriteMethodBody(value.Body);
+
+ when (_configuration.ShowMethodDeclarationBody)
+ WriteDeclaringTypeProperties(value.DeclaringType :> ITypeReference);
}
public override WritePropertyDeclaration(value : IPropertyDeclaration) : void
{
WriteDocumentation(value);
- WriteCustomAttributeList(value.Attributes.ToList());
+ WriteCustomAttributeList(value);
def getMethod = if (value.GetMethod != null) value.GetMethod.Resolve() else null;
def setMethod = if (value.SetMethod != null) value.SetMethod.Resolve() else null;
@@ -526,7 +537,7 @@
WriteMethodVisibility(getMethod.GetVisibility());
WriteKeyword("get");
- Write("; ");
+ WriteMethodBody(getMethod.Body);
}
unless (setMethod == null)
@@ -537,12 +548,14 @@
WriteMethodVisibility(setMethod.GetVisibility());
WriteKeyword("set");
- Write("; ");
+ WriteMethodBody(setMethod.Body);
}
Write("}");
}
- WriteLine();
+
+ when (_configuration.ShowMethodDeclarationBody)
+ WriteDeclaringTypeProperties(value.DeclaringType :> ITypeReference);
}
#endregion
@@ -814,10 +827,10 @@
WriteIndent();
def events = value.Events .ToList().Filter(e => !e.RuntimeSpecialName);
- def fields = value.Fields .ToList().Filter(e => !e.Name.StartsWith("_N_") && !e.RuntimeSpecialName);
- def innerTypes = value.NestedTypes.ToList().Filter(e => !e.Name.StartsWith("_N_"));
- def properties = value.Properties .ToList().Filter(e => !e.Name.StartsWith("_N_"));
- mutable methods = value.Methods .ToList().Filter(e => !e.Name.StartsWith("_N_"));
+ def fields = value.Fields .ToList().Filter(e => !e.IsGenerated() && !e.RuntimeSpecialName);
+ def innerTypes = value.NestedTypes.ToList().Filter(e => !e.IsGenerated());
+ def properties = value.Properties .ToList().Filter(e => !e.IsGenerated());
+ mutable methods = value.Methods .ToList().Filter(e => !e.IsGenerated());
events.Iter(e : IEventDeclaration =>
{
@@ -843,11 +856,11 @@
WriteMembersDeclaration(fields, "Fields", WriteFieldDeclaration);
WriteMembersDeclaration(methods, "Methods", WriteMethodDeclaration);
WriteMembersDeclaration(properties, "Properties", WritePropertyDeclaration);
- }
WriteOutdent();
WriteLine("}");
}
+ }
private WriteMembersDeclaration['a](lst : list['a], name : string, writer : 'a -> void) : void
{
@@ -858,7 +871,11 @@
WriteLine(name);
WriteLine();
- lst.Iter(writer);
+ lst.Iter(m =>
+ {
+ writer(m);
+ WriteLine();
+ });
WriteLine();
WriteKeyword("#endregion");
@@ -1048,22 +1065,33 @@
WriteList(value.Arguments.ToList(), "(", ")", WriteExpression);
}
- private WriteCustomAttributeList
- ( attrs : list[ICustomAttribute]
- ) : void
+ private WriteCustomAttributeList(attrs : list[ICustomAttribute]) : void
{
- WriteCustomAttributeList(attrs, null)
+ when (_configuration.ShowCustomAttributes && !attrs.IsEmpty)
+ {
+ WriteList(attrs, "[", "]", WriteCustomAttribute);
+ WriteLine();
+ }
}
- private WriteCustomAttributeList
- ( attrs : list[ICustomAttribute]
- , target : string
- ) : void
+ private WriteCustomAttributeList(provider : ICustomAttributeProvider) : void
{
+ def attrs = provider.Attributes.ToList();
when (_configuration.ShowCustomAttributes && !attrs.IsEmpty)
{
+ def target =
+ match (provider)
+ {
+ | _ is IAssembly => "assembly";
+ | _ is IModule => "module";
+ | _ is IMethodReturnType => "return";
+ | _ => null;
+ }
+
if (target != null)
{
+ // Special attributes are written one per line.
+ //
attrs.Iter(attr =>
{
Write("[");
@@ -1075,6 +1103,7 @@
}
else
WriteList(attrs, "[", "]", WriteCustomAttribute);
+
WriteLine();
}
}
@@ -1142,14 +1171,66 @@
);
}
- private WriteParameterDeclaration(value : IParameterDeclaration ) : void
+ private WriteParameterDeclaration(value : IParameterDeclaration) : void
{
- WriteList(value.Attributes.ToList(), "[", "] ", WriteCustomAttribute);
- // TODO: out/ref, parms; default value
- def name = if (value.Name.StartsWith("_N_")) "_" else value.Name;
- WriteIdentifier(name);
+ def wrapper = CustomAttributeWrapper.Parameter(value);
+ WriteList(wrapper.Attributes, "[", "] ", WriteCustomAttribute);
+
+ when (wrapper.IsParamArray)
+ {
+ WriteKeyword("params");
+ Write(" ");
+ }
+
+ WriteIdentifier(if (value.IsGenerated()) "_" else value.Name);
Write(" : ");
+
+ if (wrapper.IsOut && !wrapper.IsIn && value.ParameterType is IReferenceType)
+ {
+ // The 'out' parameter is actually a 'ref' parameter
+ // wich must be initialized until return.
+ //
+ WriteKeyword("out");
+ Write(" ");
+ WriteType((value.ParameterType :> IReferenceType).ElementType);
+ }
+ else
WriteType(value.ParameterType);
+
+ unless (value.DefaultValue == null)
+ {
+ Write(" = ");
+ WriteExpression(value.DefaultValue);
+ }
+ }
+
+ private WriteDeclaringTypeProperties(value : ITypeReference) : void
+ {
+ WriteProperty("Declaring Type", value.GetUserFriendlyName());
+ match (value.GetAssembly())
+ {
+ | null
+ | a when a.Name == null =>()
+ | a =>
+ def ver = if (a.Version == null) string.Empty else ", Version=" + a.Version.ToString();
+ WriteProperty("Assembly", a.Name + ver);
+ }
+ }
+
+ private WriteMethodBody(value : object) : void
+ {
+ | s is IStatement
+ when _configuration.ShowMethodDeclarationBody =>
+ WriteLine();
+ WriteLine("{");
+ WriteIndent();
+
+ WriteStatement(s);
+
+ WriteOutdent();
+ Write("}");
+ | _ =>
+ Write(";");
}
private WriteMethodVisibility(value : MethodVisibility) : void
@@ -1190,7 +1271,7 @@
| '"' => @"""";
| _ when value < ' ' =>
@"\x" + (value :> IFormattable).ToString("X2", CultureInfo.InvariantCulture);
- | _ when value > '\x100' =>
+ | _ when value > '\xFF' =>
@"\u" + (value :> IFormattable).ToString("X4", CultureInfo.InvariantCulture);
| _ =>
value.ToString();
Modified: nemerle/trunk/tools/reflector-addon/src/LanguageWriterConfiguration.n
==============================================================================
--- nemerle/trunk/tools/reflector-addon/src/LanguageWriterConfiguration.n (original)
+++ nemerle/trunk/tools/reflector-addon/src/LanguageWriterConfiguration.n Mon Jan 15 08:28:39 2007
@@ -60,6 +60,11 @@
get { _configuration["ShowNamespaceImports"] == "true" }
}
+ public ShowMethodDeclarationBody : bool
+ {
+ get { _configuration["ShowMethodDeclarationBody"] == "true" }
+ }
+
public ShowTypeDeclarationBody : bool
{
get { _configuration["ShowTypeDeclarationBody"] == "true" }
More information about the svn
mailing list