Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2012-06-01 12:41:45 +0400
committerMarek Safar <marek.safar@gmail.com>2012-06-01 12:43:32 +0400
commit5b1a509563fdc8057246bc9793be623af0eed878 (patch)
tree2f5b8a8f3d74679ade26488b7f1edd60b7807407
parent53f83c9f56f372f4e801227fc5d60f0f4b8d1c8b (diff)
Add new advanced --metadata-only compiler option to produce assembly for references purposes only
-rw-r--r--mcs/build/profiles/net_4_0.make2
-rw-r--r--mcs/mcs/driver.cs3
-rw-r--r--mcs/mcs/method.cs59
-rw-r--r--mcs/mcs/module.cs2
-rw-r--r--mcs/mcs/property.cs14
-rw-r--r--mcs/mcs/settings.cs9
6 files changed, 64 insertions, 25 deletions
diff --git a/mcs/build/profiles/net_4_0.make b/mcs/build/profiles/net_4_0.make
index 0a26e1b9a02..13c6d90c575 100644
--- a/mcs/build/profiles/net_4_0.make
+++ b/mcs/build/profiles/net_4_0.make
@@ -11,7 +11,7 @@ profile-check:
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib --metadata-only -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
FRAMEWORK_VERSION = 4.0
diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs
index cd42b8974c6..d4a2d7e1503 100644
--- a/mcs/mcs/driver.cs
+++ b/mcs/mcs/driver.cs
@@ -344,7 +344,8 @@ namespace Mono.CSharp
tr.Stop (TimeReporter.TimerType.CloseTypes);
tr.Start (TimeReporter.TimerType.Resouces);
- assembly.EmbedResources ();
+ if (!settings.WriteMetadataOnly)
+ assembly.EmbedResources ();
tr.Stop (TimeReporter.TimerType.Resouces);
if (Report.Errors > 0)
diff --git a/mcs/mcs/method.cs b/mcs/mcs/method.cs
index a6b3d1f2088..71b9fea8c59 100644
--- a/mcs/mcs/method.cs
+++ b/mcs/mcs/method.cs
@@ -1213,6 +1213,9 @@ namespace Mono.CSharp {
block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location);
ModFlags |= Modifiers.DEBUGGER_HIDDEN;
}
+
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
}
if ((ModFlags & Modifiers.STATIC) == 0)
@@ -1617,10 +1620,15 @@ namespace Mono.CSharp {
Parent.MemberCache.AddMember (spec);
- // It's here only to report an error
- if (block != null && block.IsIterator) {
- member_type = Compiler.BuiltinTypes.Void;
- Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+ if (block != null) {
+ // It's here only to report an error
+ if (block.IsIterator) {
+ member_type = Compiler.BuiltinTypes.Void;
+ Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+ }
+
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
}
return true;
@@ -1656,14 +1664,14 @@ namespace Mono.CSharp {
BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void);
bc.Set (ResolveContext.Options.ConstructorScope);
- //
- // If we use a "this (...)" constructor initializer, then
- // do not emit field initializers, they are initialized in the other constructor
- //
- if (!(Initializer is ConstructorThisInitializer))
- Parent.PartialContainer.ResolveFieldInitializers (bc);
-
if (block != null) {
+ //
+ // If we use a "this (...)" constructor initializer, then
+ // do not emit field initializers, they are initialized in the other constructor
+ //
+ if (!(Initializer is ConstructorThisInitializer))
+ Parent.PartialContainer.ResolveFieldInitializers (bc);
+
if (!IsStatic) {
if (Initializer == null) {
if (Parent.PartialContainer.Kind == MemberKind.Struct) {
@@ -2150,6 +2158,16 @@ namespace Mono.CSharp {
return true;
}
+ public override bool Define ()
+ {
+ base.Define ();
+
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
+
+ return true;
+ }
+
public override void Emit()
{
var base_type = Parent.PartialContainer.BaseType;
@@ -2513,13 +2531,18 @@ namespace Mono.CSharp {
if (!base.Define ())
return false;
- if (block != null && block.IsIterator) {
- //
- // Current method is turned into automatically generated
- // wrapper which creates an instance of iterator
- //
- Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
- ModFlags |= Modifiers.DEBUGGER_HIDDEN;
+ if (block != null) {
+ if (block.IsIterator) {
+ //
+ // Current method is turned into automatically generated
+ // wrapper which creates an instance of iterator
+ //
+ Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+ ModFlags |= Modifiers.DEBUGGER_HIDDEN;
+ }
+
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
}
// imlicit and explicit operator of same types are not allowed
diff --git a/mcs/mcs/module.cs b/mcs/mcs/module.cs
index 3117053fcf9..bf36e8f20e4 100644
--- a/mcs/mcs/module.cs
+++ b/mcs/mcs/module.cs
@@ -429,7 +429,7 @@ namespace Mono.CSharp
base.EmitContainer ();
- if (Compiler.Report.Errors == 0)
+ if (Compiler.Report.Errors == 0 && !Compiler.Settings.WriteMetadataOnly)
VerifyMembers ();
if (anonymous_types != null) {
diff --git a/mcs/mcs/property.cs b/mcs/mcs/property.cs
index c74b12739bf..ba42c40b4cc 100644
--- a/mcs/mcs/property.cs
+++ b/mcs/mcs/property.cs
@@ -362,8 +362,13 @@ namespace Mono.CSharp
CheckAbstractAndExtern (block != null);
CheckProtectedModifier ();
- if (block != null && block.IsIterator)
- Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+ if (block != null) {
+ if (block.IsIterator)
+ Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
+ }
return null;
}
@@ -906,7 +911,7 @@ namespace Mono.CSharp
public override void Emit (TypeDefinition parent)
{
- if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) {
+ if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 && !Compiler.Settings.WriteMetadataOnly) {
block = new ToplevelBlock (Compiler, ParameterInfo, Location) {
IsCompilerGenerated = true
};
@@ -1194,6 +1199,9 @@ namespace Mono.CSharp
if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName)))
return null;
+ if (Compiler.Settings.WriteMetadataOnly)
+ block = null;
+
MethodBuilder mb = method_data.MethodBuilder;
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags);
diff --git a/mcs/mcs/settings.cs b/mcs/mcs/settings.cs
index 5c5a34b9ed3..83cb9b96e6c 100644
--- a/mcs/mcs/settings.cs
+++ b/mcs/mcs/settings.cs
@@ -159,6 +159,8 @@ namespace Mono.CSharp {
public RuntimeVersion StdLibRuntimeVersion;
+ public bool WriteMetadataOnly;
+
readonly List<string> conditional_symbols;
readonly List<SourceFile> source_files;
@@ -670,8 +672,9 @@ namespace Mono.CSharp {
{
output.WriteLine (
"Other flags in the compiler\n" +
- " --fatal[=COUNT] Makes errors after COUNT fatal\n" +
+ " --fatal[=COUNT] Makes error after COUNT fatal\n" +
" --lint Enhanced warnings\n" +
+ " --metadata-only Produced assembly will contain metadata only\n" +
" --parse Only parses the source file\n" +
" --runtime:VERSION Sets mscorlib.dll metadata version: v1, v2, v4\n" +
" --stacktrace Shows stack trace at error location\n" +
@@ -1425,6 +1428,10 @@ namespace Mono.CSharp {
settings.LoadDefaultReferences = false;
return ParseResult.Success;
+ case "--metadata-only":
+ settings.WriteMetadataOnly = true;
+ return ParseResult.Success;
+
default:
if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
int fatal = 1;