}
importer.Initialize ();
- // Import all currently loaded assemblies
- var ns = cc.GlobalRootNamespace;
- var domain = AppDomain.CurrentDomain;
//
// Any later loaded assemblies are handled internally by GetAssemblyDefinition
//
Compiler.RootContext.ToplevelTypes = new Compiler.ModuleContainer (cc);
var temp = Compiler.RootContext.ToplevelTypes.MakeExecutable ("dynamic");
- temp.Create (AppDomain.CurrentDomain, System.Reflection.Emit.AssemblyBuilderAccess.Run);
+
+ // Import all currently loaded assemblies
+ var domain = AppDomain.CurrentDomain;
+
+ temp.Create (domain, System.Reflection.Emit.AssemblyBuilderAccess.Run);
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
- ns.AddAssemblyReference (a);
- importer.ImportAssembly (ns.CreateAssemblyDefinition (a), ns);
+ importer.ImportAssembly (a, Compiler.RootContext.ToplevelTypes.GlobalRootNamespace);
}
if (!Compiler.RootContext.EvalMode) {
- Compiler.TypeManager.InitCoreTypes (cc, core_types);
+ Compiler.TypeManager.InitCoreTypes (Compiler.RootContext.ToplevelTypes, core_types);
Compiler.TypeManager.InitOptionalCoreTypes (cc);
}
-// CS1681: You cannot redefine the global extern alias
+// CS1681: The global extern alias cannot be redefined
// Line: 0
// Compiler options: -r:global=CS1681-2-lib.dll
-// cs1681.cs: You cannot redefine the global extern alias
+// CS1681: The global extern alias cannot be redefined
// Line: 3
extern alias global;
using System;
{
// TODO: make it private and move all builder based methods here
public AssemblyBuilder Builder;
+ AssemblyBuilderExtension builder_extra;
+
bool is_cls_compliant;
bool wrap_non_exception_throws;
bool wrap_non_exception_throws_custom;
Attribute cls_attribute;
+ List<ImportedModuleDefinition> added_modules;
Dictionary<SecurityAction, PermissionSet> declarative_security;
- MethodInfo add_type_forwarder;
Dictionary<ITypeDefinition, Attribute> emitted_forwarders;
+ AssemblyAttributesPlaceholder module_target_attrs;
//
// In-memory only assembly container
#endregion
+ public void AddModule (string moduleFile)
+ {
+ var mod = builder_extra.AddModule (moduleFile);
+ var imported = Compiler.MetaImporter.ImportModule (mod, module.GlobalRootNamespace);
+
+ if (added_modules == null) {
+ added_modules = new List<ImportedModuleDefinition> ();
+ added_modules.Add (imported);
+ }
+ }
+
public void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.IsValidSecurityAttribute ()) {
return;
}
- try {
- var fi = typeof (AssemblyBuilder).GetField ("culture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
- fi.SetValue (Builder, value == "neutral" ? "" : value);
- } catch {
- Report.RuntimeMissingSupport (a.Location, "AssemblyCultureAttribute setting");
+ if (value == "neutral")
+ value = "";
+
+ if (RootContext.Target == Target.Module) {
+ SetCustomAttribute (ctor, cdata);
+ } else {
+ builder_extra.SetCulture (value, a.Location);
}
return;
return;
}
- try {
- var fi = typeof (AssemblyBuilder).GetField ("version", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
- fi.SetValue (Builder, vinfo);
- } catch {
- Report.RuntimeMissingSupport (a.Location, "AssemblyVersionAttribute setting");
+ if (RootContext.Target == Target.Module) {
+ SetCustomAttribute (ctor, cdata);
+ } else {
+ builder_extra.SetVersion (vinfo, a.Location);
}
return;
alg |= ((uint) cdata [pos + 2]) << 16;
alg |= ((uint) cdata [pos + 3]) << 24;
- try {
- var fi = typeof (AssemblyBuilder).GetField ("algid", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
- fi.SetValue (Builder, alg);
- } catch {
- Report.RuntimeMissingSupport (a.Location, "AssemblyAlgorithmIdAttribute setting");
+ if (RootContext.Target == Target.Module) {
+ SetCustomAttribute (ctor, cdata);
+ } else {
+ builder_extra.SetAlgorithmId (alg, a.Location);
}
return;
if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && public_key == null)
flags &= ~(uint) AssemblyNameFlags.PublicKey;
- try {
- var fi = typeof (AssemblyBuilder).GetField ("flags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
- fi.SetValue (Builder, flags);
- } catch {
- Report.RuntimeMissingSupport (a.Location, "AssemblyFlagsAttribute setting");
+ if (RootContext.Target == Target.Module) {
+ SetCustomAttribute (ctor, cdata);
+ } else {
+ builder_extra.SetFlags (flags, a.Location);
}
return;
return;
}
- if (add_type_forwarder == null) {
- add_type_forwarder = typeof (AssemblyBuilder).GetMethod ("AddTypeForwarder",
- BindingFlags.NonPublic | BindingFlags.Instance);
-
- if (add_type_forwarder == null) {
- Report.RuntimeMissingSupport (a.Location, "TypeForwardedTo attribute");
- return;
- }
- }
-
- add_type_forwarder.Invoke (Builder, new object[] { t.GetMetaInfo () });
+ builder_extra.AddTypeForwarder (t, a.Location);
return;
}
wrap_non_exception_throws_custom = true;
}
- Builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
+ SetCustomAttribute (ctor, cdata);
}
//
{
// TODO: It should check only references assemblies but there is
// no working SRE API
- foreach (var a in Compiler.GlobalRootNamespace.Assemblies) {
+ foreach (var a in Compiler.MetaImporter.Assemblies) {
if (public_key != null && !a.HasStrongName) {
Report.Error (1577, "Referenced assembly `{0}' does not have a strong name",
a.FullName);
throw;
}
+ builder_extra = new AssemblyBuilderExtension (Builder, Compiler);
+
return true;
}
public void Emit ()
{
- module.Emit ();
+ if (RootContext.Target == Target.Module) {
+ module_target_attrs = new AssemblyAttributesPlaceholder (module);
+ module_target_attrs.CreateType ();
+ module_target_attrs.DefineType ();
+ module_target_attrs.Define ();
+ module.AddCompilerGeneratedClass (module_target_attrs);
+ } else if (added_modules != null) {
+ ReadModulesAssemblyAttributes ();
+ }
- if (module.HasExtensionMethod)
- Compiler.PredefinedAttributes.Extension.EmitAttribute (Builder);
+ module.Emit ();
- PredefinedAttribute pa = Compiler.PredefinedAttributes.RuntimeCompatibility;
- if (pa.IsDefined && !wrap_non_exception_throws_custom) {
- var ci = TypeManager.GetPredefinedConstructor (pa.Type, Location.Null, TypeSpec.EmptyTypes);
- PropertyInfo [] pis = new PropertyInfo [1];
+ if (module.HasExtensionMethod) {
+ var pa = Compiler.PredefinedAttributes.Extension;
+ if (pa.IsDefined) {
+ SetCustomAttribute (pa.Constructor, AttributeEncoder.Empty);
+ }
+ }
- pis [0] = TypeManager.GetPredefinedProperty (pa.Type,
- "WrapNonExceptionThrows", Location.Null, TypeManager.bool_type).MetaInfo;
- object [] pargs = new object [1];
- pargs [0] = true;
- Builder.SetCustomAttribute (new CustomAttributeBuilder ((ConstructorInfo) ci.GetMetaInfo (), new object[0], pis, pargs));
+ if (!wrap_non_exception_throws_custom) {
+ PredefinedAttribute pa = Compiler.PredefinedAttributes.RuntimeCompatibility;
+ if (pa.IsDefined && pa.ResolveBuilder ()) {
+ var prop = pa.GetProperty ("WrapNonExceptionThrows", TypeManager.bool_type, Location.Null);
+ if (prop != null) {
+ AttributeEncoder encoder = new AttributeEncoder (false);
+ encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (true, Location.Null));
+ SetCustomAttribute (pa.Constructor, encoder.ToArray ());
+ }
+ }
}
if (declarative_security != null) {
}
}
+ void ReadModulesAssemblyAttributes ()
+ {
+ foreach (var m in added_modules) {
+ var cattrs = m.ReadAssemblyAttributes ();
+ if (cattrs == null)
+ continue;
+
+ module.OptAttributes.AddAttributes (cattrs);
+ }
+ }
+
public void Resolve ()
{
if (RootContext.Unsafe) {
Arguments named = new Arguments (1);
named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (true, loc)));
- GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (Compiler, null, null, null), "assembly",
+ GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (module, null, null, null), "assembly",
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (module, module);
is_cls_compliant = cls_attribute.GetClsCompliantAttributeValue ();
}
+ if (added_modules != null && RootContext.VerifyClsCompliance && is_cls_compliant) {
+ foreach (var m in added_modules) {
+ if (!m.IsCLSCompliant) {
+ Report.Error (3013,
+ "Added modules must be marked with the CLSCompliant attribute to match the assembly",
+ m.Name);
+ }
+ }
+ }
+
Attribute a = module.ResolveAssemblyAttribute (Compiler.PredefinedAttributes.RuntimeCompatibility);
if (a != null) {
var val = a.GetPropertyValue ("WrapNonExceptionThrows") as BoolConstant;
machine = ImageFileMachine.I386;
break;
}
+
+ if (RootContext.Target == Target.Module) {
+ builder_extra.SetModuleTarget ();
+ }
+
try {
Builder.Save (module.Builder.ScopeName, pekind, machine);
- } catch (System.Runtime.InteropServices.COMException) {
- if ((RootContext.StrongNameKeyFile == null) || (!RootContext.StrongNameDelaySign))
- throw;
-
- // FIXME: it seems Microsoft AssemblyBuilder doesn't like to delay sign assemblies
- Report.Error (1548, "Couldn't delay-sign the assembly with the '" +
- RootContext.StrongNameKeyFile +
- "', Use MCS with the Mono runtime or CSC to compile this assembly.");
} catch (System.IO.IOException io) {
Report.Error (16, "Could not write to file `" + name + "', cause: " + io.Message);
return;
}
}
+ void SetCustomAttribute (MethodSpec ctor, byte[] data)
+ {
+ if (module_target_attrs != null)
+ module_target_attrs.AddAssemblyAttribute (ctor, data);
+ else
+ Builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), data);
+ }
+
void Error_ObsoleteSecurityAttribute (Attribute a, string option)
{
Report.Warning (1699, 1, a.Location,
return new Version (v.Major, System.Math.Max (0, v.Minor), System.Math.Max (0, v.Build), System.Math.Max (0, v.Revision)).ToString (4);
}
+ }
+
+ //
+ // A placeholder class for assembly attributes when emitting module
+ //
+ class AssemblyAttributesPlaceholder : CompilerGeneratedClass
+ {
+ public static readonly string TypeName = "<$AssemblyAttributes>";
+ public static readonly string AssemblyFieldName = "attributes";
+
+ Field assembly;
+
+ public AssemblyAttributesPlaceholder (ModuleContainer parent)
+ : base (parent, new MemberName (TypeName), Modifiers.STATIC)
+ {
+ assembly = new Field (this, new TypeExpression (TypeManager.object_type, Location), Modifiers.PUBLIC | Modifiers.STATIC,
+ new MemberName (AssemblyFieldName), null);
+
+ AddField (assembly);
+ }
+ public void AddAssemblyAttribute (MethodSpec ctor, byte[] data)
+ {
+ assembly.SetCustomAttribute (ctor, data);
+ }
+ }
- // Wrapper for AssemblyBuilder.AddModule
+ //
+ // Extension to System.Reflection.Emit.AssemblyBuilder to have fully compatible
+ // compiler
+ //
+ class AssemblyBuilderExtension
+ {
static MethodInfo adder_method;
- static public MethodInfo AddModule_Method {
- get {
+ static MethodInfo set_module_only;
+ static MethodInfo add_type_forwarder;
+ static FieldInfo assembly_version;
+ static FieldInfo assembly_algorithm;
+ static FieldInfo assembly_culture;
+ static FieldInfo assembly_flags;
+
+ AssemblyBuilder builder;
+ CompilerContext ctx;
+
+ public AssemblyBuilderExtension (AssemblyBuilder ab, CompilerContext ctx)
+ {
+ this.builder = ab;
+ this.ctx = ctx;
+ }
+
+ public Module AddModule (string module)
+ {
+ try {
if (adder_method == null)
- adder_method = typeof (AssemblyBuilder).GetMethod ("AddModule", BindingFlags.Instance|BindingFlags.NonPublic);
- return adder_method;
+ adder_method = typeof (AssemblyBuilder).GetMethod ("AddModule", BindingFlags.Instance | BindingFlags.NonPublic);
+
+ return (Module) adder_method.Invoke (builder, new object[] { module });
+ } catch {
+ ctx.Report.RuntimeMissingSupport (Location.Null, "-addmodule");
+ return null;
}
}
- public Module AddModule (string module)
+
+ public void AddTypeForwarder (TypeSpec type, Location loc)
{
- MethodInfo m = AddModule_Method;
- if (m == null) {
- Report.RuntimeMissingSupport (Location.Null, "/addmodule");
- Environment.Exit (1);
+ try {
+ if (add_type_forwarder == null) {
+ add_type_forwarder = typeof (AssemblyBuilder).GetMethod ("AddTypeForwarder", BindingFlags.NonPublic | BindingFlags.Instance);
+ }
+
+ add_type_forwarder.Invoke (builder, new object[] { type.GetMetaInfo () });
+ } catch {
+ ctx.Report.RuntimeMissingSupport (loc, "TypeForwardedToAttribute");
}
+ }
+ public void SetAlgorithmId (uint value, Location loc)
+ {
try {
- return (Module) m.Invoke (Builder, new object [] { module });
- } catch (TargetInvocationException ex) {
- throw ex.InnerException;
+ if (assembly_algorithm == null)
+ assembly_algorithm = typeof (AssemblyBuilder).GetField ("algid", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+
+ assembly_algorithm.SetValue (builder, value);
+ } catch {
+ ctx.Report.RuntimeMissingSupport (loc, "AssemblyAlgorithmIdAttribute");
}
- }
+ }
+
+ public void SetCulture (string culture, Location loc)
+ {
+ try {
+ if (assembly_culture == null)
+ assembly_culture = typeof (AssemblyBuilder).GetField ("culture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+
+ assembly_culture.SetValue (builder, culture);
+ } catch {
+ ctx.Report.RuntimeMissingSupport (loc, "AssemblyCultureAttribute");
+ }
+ }
+
+
+ public void SetFlags (uint flags, Location loc)
+ {
+ try {
+ if (assembly_flags == null)
+ assembly_flags = typeof (AssemblyBuilder).GetField ("flags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+
+ assembly_flags.SetValue (builder, flags);
+ } catch {
+ ctx.Report.RuntimeMissingSupport (loc, "AssemblyFlagsAttribute");
+ }
+
+ }
+
+ public void SetVersion (string version, Location loc)
+ {
+ try {
+ if (assembly_version == null)
+ assembly_version = typeof (AssemblyBuilder).GetField ("version", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+
+ assembly_version.SetValue (builder, version);
+ } catch {
+ ctx.Report.RuntimeMissingSupport (loc, "AssemblyVersionAttribute");
+ }
+ }
+
+ public void SetModuleTarget ()
+ {
+ try {
+ if (set_module_only == null) {
+ var module_only = typeof (AssemblyBuilder).GetProperty ("IsModuleOnly", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ set_module_only = module_only.GetSetMethod (true);
+ }
+
+ set_module_only.Invoke (builder, new object[] { true });
+ } catch {
+ ctx.Report.RuntimeMissingSupport (Location.Null, "-target:module");
+ }
+ }
}
}
static Assembly orig_sec_assembly;
public static readonly object[] EmptyObject = new object [0];
- IList<KeyValuePair<MemberExpr, NamedArgument>> named_values;
+ List<KeyValuePair<MemberExpr, NamedArgument>> named_values;
// Cache for parameter-less attributes
static Dictionary<TypeSpec, MethodSpec> att_cache;
na.Value.Expr.EncodeAttributeValue (context, encoder, na.Key.Type);
}
} else {
- encoder.Stream.Write ((ushort) 0);
+ encoder.EncodeEmptyNamedArguments ();
}
byte[] cdata = encoder.ToArray ();
TypeParameter = 1 << 1
}
+ const ushort Version = 1;
+
+ public static readonly byte[] Empty;
+
public readonly BinaryWriter Stream;
+ static AttributeEncoder ()
+ {
+ Empty = new byte[4];
+ Array.Copy (BitConverter.GetBytes (Version), Empty, 2);
+ }
+
public AttributeEncoder (bool empty)
{
if (empty) {
}
Stream = new BinaryWriter (new MemoryStream ());
- const ushort version = 1;
- Stream.Write (version);
+ Stream.Write (Version);
+ }
+
+ public void Encode (byte value)
+ {
+ Stream.Write (value);
+ }
+
+ public void Encode (int value)
+ {
+ Stream.Write (value);
+ }
+
+ public void Encode (uint value)
+ {
+ Stream.Write (value);
}
public void Encode (string value)
Encode (type.MemberDefinition.IsImported ? old_type.AssemblyQualifiedName : old_type.FullName);
}
+ //
+ // Encodes single property named argument per call
+ //
+ public void EncodeNamedPropertyArgument (PropertySpec property, Constant value)
+ {
+ Stream.Write ((ushort) 1); // length
+ Stream.Write ((byte) 0x54); // property
+ Encode (property.MemberType);
+ Encode (property.Name);
+ value.EncodeAttributeValue (null, this, property.MemberType);
+ }
+
+ //
+ // Encodes single field named argument per call
+ //
+ public void EncodeNamedFieldArgument (FieldSpec field, Constant value)
+ {
+ Stream.Write ((ushort) 1); // length
+ Stream.Write ((byte) 0x53); // field
+ Encode (field.MemberType);
+ Encode (field.Name);
+ value.EncodeAttributeValue (null, this, field.MemberType);
+ }
+
+ public void EncodeEmptyNamedArguments ()
+ {
+ Stream.Write ((ushort) 0);
+ }
+
void WriteCompressedValue (int value)
{
if (value < 0x80) {
return result;
}
- public static void VerifyModulesClsCompliance (CompilerContext ctx)
- {
- Module[] modules = ctx.GlobalRootNamespace.Modules;
- if (modules == null)
- return;
-
- // The first module is generated assembly
- for (int i = 1; i < modules.Length; ++i) {
- Module module = modules [i];
- if (!GetClsCompliantAttributeValue (module, null)) {
- ctx.Report.Error (3013, "Added modules must be marked with the CLSCompliant attribute " +
- "to match the assembly", module.Name);
- return;
- }
- }
- }
-
static bool GetClsCompliantAttributeValue (ICustomAttributeProvider attribute_provider, Assembly a)
{
object[] cls_attr = attribute_provider.GetCustomAttributes (typeof (CLSCompliantAttribute), false);
public readonly PredefinedAttribute AttributeUsage;
public readonly PredefinedAttribute DefaultParameterValue;
public readonly PredefinedAttribute OptionalParameter;
+ public readonly PredefinedAttribute UnverifiableCode;
// New in .NET 2.0
public readonly PredefinedAttribute DefaultCharset;
// Optional types which are used as types and for member lookup
//
public readonly PredefinedAttribute DefaultMember;
- public readonly PredefinedAttribute DecimalConstant;
+ public readonly PredefinedDecimalAttribute DecimalConstant;
public readonly PredefinedAttribute StructLayout;
public readonly PredefinedAttribute FieldOffset;
AttributeUsage = new PredefinedAttribute ("System", "AttributeUsageAttribute");
DefaultParameterValue = new PredefinedAttribute ("System.Runtime.InteropServices", "DefaultParameterValueAttribute");
OptionalParameter = new PredefinedAttribute ("System.Runtime.InteropServices", "OptionalAttribute");
+ UnverifiableCode = new PredefinedAttribute ("System.Security", "UnverifiableCodeAttribute");
DefaultCharset = new PredefinedAttribute ("System.Runtime.InteropServices", "DefaultCharSetAttribute");
TypeForwarder = new PredefinedAttribute ("System.Runtime.CompilerServices", "TypeForwardedToAttribute");
Dynamic = new PredefinedDynamicAttribute ("System.Runtime.CompilerServices", "DynamicAttribute");
DefaultMember = new PredefinedAttribute ("System.Reflection", "DefaultMemberAttribute");
- DecimalConstant = new PredefinedAttribute ("System.Runtime.CompilerServices", "DecimalConstantAttribute");
+ DecimalConstant = new PredefinedDecimalAttribute ("System.Runtime.CompilerServices", "DecimalConstantAttribute");
StructLayout = new PredefinedAttribute ("System.Runtime.InteropServices", "StructLayoutAttribute");
FieldOffset = new PredefinedAttribute ("System.Runtime.InteropServices", "FieldOffsetAttribute");
}
public class PredefinedAttribute
{
protected TypeSpec type;
- CustomAttributeBuilder cab;
- MethodSpec ctor;
+ protected MethodSpec ctor;
readonly string ns, name;
CompilerContext compiler;
+ List<FieldSpec> fields;
+ List<PropertySpec> properties;
static readonly TypeSpec NotFound = InternalType.Null;
this.name = name;
}
+ #region Properties
+
+ public MethodSpec Constructor {
+ get {
+ return ctor;
+ }
+ }
+
+ public bool IsDefined {
+ get {
+ return type != null && type != NotFound;
+ }
+ }
+
+ public TypeSpec Type {
+ get {
+ return type;
+ }
+ }
+
+ #endregion
+
+
public static bool operator == (TypeSpec type, PredefinedAttribute pa)
{
return type == pa.type;
return type != pa.type;
}
- public ConstructorInfo Constructor {
- get { return ctor == null ? null : (ConstructorInfo) ctor.GetMetaInfo (); }
- }
-
public override int GetHashCode ()
{
return base.GetHashCode ();
public void EmitAttribute (ConstructorBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
}
public void EmitAttribute (MethodBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
}
public void EmitAttribute (PropertyBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
}
public void EmitAttribute (FieldBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
+ }
+
+ public void EmitAttribute (FieldBuilder builder, AttributeEncoder argsEncoded)
+ {
+ builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ());
}
public void EmitAttribute (TypeBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
+ }
+
+ public void EmitAttribute (TypeBuilder builder, AttributeEncoder argsEncoded)
+ {
+ builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ());
}
public void EmitAttribute (AssemblyBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
+ }
+
+ public void EmitAttribute (ModuleBuilder builder)
+ {
+ if (ResolveBuilder ())
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
}
public void EmitAttribute (ParameterBuilder builder)
{
if (ResolveBuilder ())
- builder.SetCustomAttribute (cab);
+ builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty);
}
- public bool IsDefined {
- get { return type != null && type != NotFound; }
+ public void EmitAttribute (ParameterBuilder builder, AttributeEncoder argsEncoded)
+ {
+ builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ());
+ }
+
+ ConstructorInfo GetCtorMetaInfo ()
+ {
+ return (ConstructorInfo) ctor.GetMetaInfo ();
+ }
+
+ public FieldSpec GetField (string name, TypeSpec memberType, Location loc)
+ {
+ FieldSpec spec;
+ if (fields != null) {
+ spec = fields.Find (l => l.Name == name);
+ } else {
+ spec = null;
+ }
+
+ if (spec == null) {
+ spec = TypeManager.GetPredefinedField (type, name, loc, memberType);
+
+ if (spec != null) {
+ if (fields == null) {
+ fields = new List<FieldSpec> ();
+ }
+
+ fields.Add (spec);
+ }
+ }
+
+ return spec;
+ }
+
+ public PropertySpec GetProperty (string name, TypeSpec memberType, Location loc)
+ {
+ PropertySpec spec;
+
+ if (properties != null) {
+ spec = properties.Find (l => l.Name == name);
+ } else {
+ spec = null;
+ }
+
+ if (spec == null) {
+ spec = TypeManager.GetPredefinedProperty (type, name, loc, memberType);
+
+ if (spec != null) {
+ if (properties == null) {
+ properties = new List<PropertySpec> ();
+ }
+
+ properties.Add (spec);
+ }
+ }
+
+ return spec;
}
public void Initialize (CompilerContext ctx, bool canFail)
return true;
}
- bool ResolveBuilder ()
+ public bool ResolveBuilder ()
{
- if (cab != null)
+ if (ctor != null)
return true;
//
if (!Resolve (true))
return false;
- var ci = TypeManager.GetPredefinedConstructor (type, Location.Null, TypeSpec.EmptyTypes);
- if (ci == null)
- return false;
-
- cab = new CustomAttributeBuilder ((ConstructorInfo) ci.GetMetaInfo (), new object[0]);
- return true;
+ ctor = TypeManager.GetPredefinedConstructor (type, Location.Null, TypeSpec.EmptyTypes);
+ return ctor != null;
}
public bool ResolveConstructor (Location loc, params TypeSpec[] argType)
ctor = TypeManager.GetPredefinedConstructor (type, loc, argType);
return ctor != null;
}
+ }
- public TypeSpec Type {
- get { return type; }
+ public class PredefinedDecimalAttribute : PredefinedAttribute
+ {
+ public PredefinedDecimalAttribute (string ns, string name)
+ : base (ns, name)
+ {
+ }
+
+ public void EmitAttribute (ParameterBuilder builder, decimal value, Location loc)
+ {
+ if (!Resolve (false))
+ return;
+
+ if (ctor == null && !ResolveConstructor (loc, TypeManager.byte_type, TypeManager.byte_type, TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type))
+ return;
+
+ int[] bits = decimal.GetBits (value);
+ AttributeEncoder encoder = new AttributeEncoder (false);
+ encoder.Encode ((byte) (bits[3] >> 16));
+ encoder.Encode ((byte) (bits[3] >> 31));
+ encoder.Encode ((uint) bits[2]);
+ encoder.Encode ((uint) bits[1]);
+ encoder.Encode ((uint) bits[0]);
+ encoder.EncodeEmptyNamedArguments ();
+
+ EmitAttribute (builder, encoder);
+ }
+
+ public void EmitAttribute (FieldBuilder builder, decimal value, Location loc)
+ {
+ if (!Resolve (false))
+ return;
+
+ if (ctor == null && !ResolveConstructor (loc, TypeManager.byte_type, TypeManager.byte_type, TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type))
+ return;
+
+ int[] bits = decimal.GetBits (value);
+ AttributeEncoder encoder = new AttributeEncoder (false);
+ encoder.Encode ((byte) (bits[3] >> 16));
+ encoder.Encode ((byte) (bits[3] >> 31));
+ encoder.Encode ((uint) bits[2]);
+ encoder.Encode ((uint) bits[1]);
+ encoder.Encode ((uint) bits[0]);
+ encoder.EncodeEmptyNamedArguments ();
+
+ EmitAttribute (builder, encoder);
}
}
int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0;
if (IsTopLevel) {
- if (Compiler.GlobalRootNamespace.IsNamespace (Name)) {
+ // TODO: Completely wrong
+ if (Module.GlobalRootNamespace.IsNamespace (Name)) {
Report.Error (519, Location, "`{0}' clashes with a predefined namespace", Name);
}
!pa.ResolveConstructor (Location, TypeManager.string_type))
return;
- CustomAttributeBuilder cb = new CustomAttributeBuilder (pa.Constructor, new string [] { GetAttributeDefaultMember () });
- TypeBuilder.SetCustomAttribute (cb);
+ var encoder = new AttributeEncoder (false);
+ encoder.Encode (GetAttributeDefaultMember ());
+ encoder.EncodeEmptyNamedArguments ();
+
+ pa.EmitAttribute (TypeBuilder, encoder);
}
protected virtual void CheckEqualsAndGetHashCode ()
{
var c = ((ConstSpec) spec).Value as Constant;
if (c.Type == TypeManager.decimal_type) {
- FieldBuilder.SetCustomAttribute (CreateDecimalConstantAttribute (c, Compiler.PredefinedAttributes));
+ Compiler.PredefinedAttributes.DecimalConstant.EmitAttribute (FieldBuilder, (decimal) c.GetValue (), c.Location);
} else {
FieldBuilder.SetConstant (c.GetTypedValue ());
}
base.Emit ();
}
- public static CustomAttributeBuilder CreateDecimalConstantAttribute (Constant c, PredefinedAttributes pa)
- {
- PredefinedAttribute attr = pa.DecimalConstant;
- if (attr.Constructor == null &&
- !attr.ResolveConstructor (c.Location, TypeManager.byte_type, TypeManager.byte_type,
- TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type))
- return null;
-
- Decimal d = (Decimal) c.GetValue ();
- int [] bits = Decimal.GetBits (d);
- object [] args = new object [] {
- (byte) (bits [3] >> 16),
- (byte) (bits [3] >> 31),
- (uint) bits [2], (uint) bits [1], (uint) bits [0]
- };
-
- return new CustomAttributeBuilder (attr.Constructor, args);
- }
-
public static void Error_InvalidConstantType (TypeSpec t, Location loc, Report Report)
{
if (t.IsGenericParameter) {
readonly Report report;
readonly ReflectionMetaImporter meta_importer;
readonly PredefinedAttributes attributes;
- readonly GlobalRootNamespace root;
public CompilerContext (ReflectionMetaImporter metaImporter, Report report)
{
this.report = report;
this.attributes = new PredefinedAttributes ();
- this.root = new GlobalRootNamespace ();
}
#region Properties
- public GlobalRootNamespace GlobalRootNamespace {
- get {
- return root;
- }
- }
+ // TODO: Obsolete, it has to go
+ public RootNamespace GlobalRootNamespace { get; set; }
public bool IsRuntimeBinder { get; set; }
Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes");
}
- current_namespace = new NamespaceEntry (compiler,
+ current_namespace = new NamespaceEntry (module,
current_namespace, file, name.GetName ());
current_class = current_namespace.SlaveDeclSpace;
current_container = current_class.PartialContainer;
this.file = file;
this.module = module;
this.compiler = module.Compiler;
- current_namespace = new NamespaceEntry (compiler, null, file, null);
+ current_namespace = new NamespaceEntry (module, null, file, null);
current_class = current_namespace.SlaveDeclSpace;
current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes
oob_stack.Clear ();
var nsName = identifier.Substring (0, index);
var typeName = identifier.Substring (index + 1);
Namespace ns = ds.NamespaceEntry.NS.GetNamespace (nsName, false);
- ns = ns ?? mc.Compiler.GlobalRootNamespace.GetNamespace(nsName, false);
+ ns = ns ?? mc.Module.GlobalRootNamespace.GetNamespace(nsName, false);
if (ns != null) {
var te = ns.LookupType(mc.Compiler, typeName, 0, true, mc.Location);
if(te != null)
xref.SetAttribute ("cref", "N:" + ns.GetSignatureForError ());
return; // a namespace
}
- if (mc.Compiler.GlobalRootNamespace.IsNamespace (name)) {
+ if (mc.Module.GlobalRootNamespace.IsNamespace (name)) {
xref.SetAttribute ("cref", "N:" + name);
return; // a namespace
}
return 1;
}
- public void LoadAssembly (string assembly, bool soft)
- {
- LoadAssembly (assembly, null, soft);
- }
-
void Error6 (string name, string log)
{
if (log != null && log.Length > 0)
void BadAssembly (string filename, string log)
{
- MethodInfo adder_method = AssemblyDefinition.AddModule_Method;
+ MethodInfo adder_method = null; // AssemblyDefinition.AddModule_Method;
if (adder_method != null) {
AssemblyName an = new AssemblyName ();
Error9 ("assembly", filename, log);
}
- public void LoadAssembly (string assembly, string alias, bool soft)
+ public Assembly LoadAssemblyFile (string assembly, bool soft)
{
Assembly a = null;
string total_log = "";
break;
} catch (FileNotFoundException ff) {
if (soft)
- return;
+ return a;
total_log += ff.FusionLog;
}
}
if (err) {
Error6 (assembly, total_log);
- return;
+ return a;
}
}
-
- // Extern aliased refs require special handling
- if (alias == null)
- ctx.GlobalRootNamespace.AddAssemblyReference (a);
- else
- ctx.GlobalRootNamespace.DefineRootNamespace (alias, a, ctx);
-
} catch (BadImageFormatException f) {
// .NET 2.0 throws this if we try to load a module without an assembly manifest ...
BadAssembly (f.FileName, f.FusionLog);
// ... while .NET 1.1 throws this
BadAssembly (f.FileName, f.FusionLog);
}
+
+ return a;
}
- public void LoadModule (AssemblyDefinition assembly, string module)
+ void LoadModule (AssemblyDefinition assembly, string module)
{
- Module m = null;
string total_log = "";
try {
try {
- m = assembly.AddModule (module);
+ assembly.AddModule (module);
} catch (FileNotFoundException) {
bool err = true;
foreach (string dir in link_paths) {
full_path += ".netmodule";
try {
- m = assembly.AddModule (full_path);
+ assembly.AddModule (full_path);
err = false;
break;
} catch (FileNotFoundException ff) {
return;
}
}
-
- ctx.GlobalRootNamespace.AddModuleReference (m);
-
} catch (BadImageFormatException f) {
Error9 ("module", f.FileName, f.FusionLog);
} catch (FileLoadException f) {
/// <summary>
/// Loads all assemblies referenced on the command line
/// </summary>
- public void LoadReferences ()
+ public void LoadReferences (ModuleContainer module)
{
link_paths.Add (GetSystemDir ());
link_paths.Add (Directory.GetCurrentDirectory ());
+ Assembly a;
+ var loaded = new List<Tuple<RootNamespace, Assembly>> ();
//
// Load Core Library for default compilation
//
- if (RootContext.StdLib)
- LoadAssembly ("mscorlib", false);
+ if (RootContext.StdLib) {
+ a = LoadAssemblyFile ("mscorlib", false);
+ if (a != null)
+ loaded.Add (Tuple.Create (module.GlobalRootNamespace, a));
+ }
- foreach (string r in soft_references)
- LoadAssembly (r, true);
+ foreach (string r in soft_references) {
+ a = LoadAssemblyFile (r, true);
+ if (a != null)
+ loaded.Add (Tuple.Create (module.GlobalRootNamespace, a));
+ }
- foreach (string r in references)
- LoadAssembly (r, false);
+ foreach (string r in references) {
+ a = LoadAssemblyFile (r, false);
+ if (a == null)
+ continue;
- foreach (var entry in external_aliases)
- LoadAssembly (entry.Value, entry.Key, false);
+ var key = Tuple.Create (module.GlobalRootNamespace, a);
+ if (loaded.Contains (key))
+ continue;
- if (modules.Count > 0) {
- foreach (string module in modules)
- LoadModule (null, module);
+ loaded.Add (key);
+ }
+
+ foreach (var entry in external_aliases) {
+ a = LoadAssemblyFile (entry.Value, false);
+ if (a == null)
+ continue;
+
+ var key = Tuple.Create (module.CreateRootNamespace (entry.Key), a);
+ if (loaded.Contains (key))
+ continue;
+
+ loaded.Add (key);
+ }
+
+ foreach (var entry in loaded) {
+ ctx.MetaImporter.ImportAssembly (entry.Item2, entry.Item1);
+ }
+ }
+
+ void LoadModules (AssemblyDefinition assembly)
+ {
+ if (modules.Count == 0)
+ return;
+
+ foreach (var module in modules) {
+ LoadModule (assembly, module);
}
-
- ctx.GlobalRootNamespace.ComputeNamespaces (ctx);
}
static string [] LoadArgs (string file)
output_file = first_source + RootContext.TargetExt;
}
- ctx.GlobalRootNamespace.AddModuleReference (RootContext.ToplevelTypes.Builder);
-
//
// Load assemblies required
//
var assembly = module.MakeExecutable (output_file, output_file);
- LoadReferences ();
+ LoadReferences (module);
ShowTime ("Imporing referenced assemblies");
- if (!TypeManager.InitCoreTypes (ctx, ctypes))
+ if (!TypeManager.InitCoreTypes (module, ctypes))
return false;
TypeManager.InitOptionalCoreTypes (ctx);
if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Save))
return false;
- if (RootContext.Target == Target.Module) {
- PropertyInfo module_only = typeof (AssemblyBuilder).GetProperty ("IsModuleOnly", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- if (module_only == null) {
- Report.RuntimeMissingSupport (Location.Null, "/target:module");
- Environment.Exit (1);
- }
-
- MethodInfo set_method = module_only.GetSetMethod (true);
- set_method.Invoke (assembly.Builder, BindingFlags.Default, null, new object[] { true }, null);
- }
+ LoadModules (assembly);
module.Define ();
assembly.Resolve ();
- if (RootContext.VerifyClsCompliance) {
- if (assembly.IsCLSCompliant) {
- AttributeTester.VerifyModulesClsCompliance (ctx);
- }
- }
if (Report.Errors > 0)
return false;
ctx.MetaImporter.Initialize ();
RootContext.ToplevelTypes.MakeExecutable ("temp");
- driver.LoadReferences ();
- TypeManager.InitCoreTypes (ctx, ctypes);
+ driver.LoadReferences (RootContext.ToplevelTypes);
+ TypeManager.InitCoreTypes (RootContext.ToplevelTypes, ctypes);
TypeManager.InitOptionalCoreTypes (ctx);
RootContext.EvalMode = true;
static void Reset ()
{
CompilerCallableEntryPoint.PartialReset ();
- RootContext.PartialReset ();
Location.AddFile (null, "{interactive}");
Location.Initialize ();
if (!inited)
Init ();
- RootContext.ToplevelTypes = new ModuleContainer (ctx);
+ // RootContext.ToplevelTypes = new ModuleContainer (ctx);
bool partial_input;
CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input);
}
seekable.Position = 0;
- CSharpParser parser = new CSharpParser (seekable, (CompilationUnit) Location.SourceFiles [0], RootContext.ToplevelTypes);
+ CSharpParser parser = new CSharpParser (seekable, Location.SourceFiles [0], RootContext.ToplevelTypes);
if (kind == InputKind.StatementOrExpression){
parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter;
static public void LoadAssembly (string file)
{
lock (evaluator_lock){
- driver.LoadAssembly (file, false);
- ctx.GlobalRootNamespace.ComputeNamespaces (ctx);
+ var a = driver.LoadAssemblyFile (file, false);
+ if (a != null)
+ ctx.MetaImporter.ImportAssembly (a, RootContext.ToplevelTypes.GlobalRootNamespace);
}
}
static public void ReferenceAssembly (Assembly a)
{
lock (evaluator_lock){
-// GlobalRootNamespace.Instance.AddAssemblyReference (a);
-// GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
- ctx.MetaImporter.ImportAssembly (new ImportedAssemblyDefinition (a), ctx.GlobalRootNamespace);
+ ctx.MetaImporter.ImportAssembly (a, RootContext.ToplevelTypes.GlobalRootNamespace);
}
}
public override FullNamedExpression ResolveAsTypeStep (IMemberContext ec, bool silent)
{
if (alias == GlobalAlias) {
- expr = ec.Compiler.GlobalRootNamespace;
+ expr = ec.CurrentMemberDefinition.Module.GlobalRootNamespace;
return base.ResolveAsTypeStep (ec, silent);
}
FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
}
+ public void SetCustomAttribute (MethodSpec ctor, byte[] data)
+ {
+ FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), data);
+ }
+
protected override bool CheckBase ()
{
if (!base.CheckBase ())
{
public const string FixedElementName = "FixedElementField";
static int GlobalCounter = 0;
- static object[] ctor_args = new object[] { (short)LayoutKind.Sequential };
- static FieldInfo[] fi;
TypeBuilder fixed_buffer_type;
void EmitFieldSize (int buffer_size)
{
- CustomAttributeBuilder cab;
PredefinedAttribute pa;
+ AttributeEncoder encoder;
pa = Compiler.PredefinedAttributes.StructLayout;
- if (pa.Constructor == null &&
- !pa.ResolveConstructor (Location, TypeManager.short_type))
- return;
+ if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.short_type))
+ return;
+
+ var field = pa.GetField ("Size", TypeManager.int32_type, Location);
+ if (field != null) {
+ encoder = new AttributeEncoder (false);
+ encoder.Encode ((short)LayoutKind.Sequential);
+ encoder.EncodeNamedFieldArgument (field, new IntConstant (buffer_size, Location));
- // TODO: It's not cleared
- if (fi == null) {
- var field = (FieldSpec) MemberCache.FindMember (pa.Type, MemberFilter.Field ("Size", null), BindingRestriction.DeclaredOnly);
- fi = new FieldInfo[] { field.GetMetaInfo () };
+ pa.EmitAttribute (fixed_buffer_type, encoder);
}
- object[] fi_val = new object[] { buffer_size };
- cab = new CustomAttributeBuilder (pa.Constructor,
- ctor_args, fi, fi_val);
- fixed_buffer_type.SetCustomAttribute (cab);
-
//
// Don't emit FixedBufferAttribute attribute for private types
//
return;
pa = Compiler.PredefinedAttributes.FixedBuffer;
- if (pa.Constructor == null &&
- !pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type))
+ if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type))
return;
- cab = new CustomAttributeBuilder (pa.Constructor, new object[] { MemberType.GetMetaInfo (), buffer_size });
- FieldBuilder.SetCustomAttribute (cab);
+ encoder = new AttributeEncoder (false);
+ encoder.EncodeTypeName (MemberType);
+ encoder.Encode (buffer_size);
+ encoder.EncodeEmptyNamedArguments ();
+
+ pa.EmitAttribute (FieldBuilder, encoder);
}
public void SetCharSet (TypeAttributes ta)
#region Properties
+ public ICollection<ImportedAssemblyDefinition> Assemblies {
+ get {
+ return assembly_2_definition.Values;
+ }
+ }
+
public bool IgnorePrivateMembers { get; set; }
#endregion
return null;
}
- public void ImportAssembly (ImportedAssemblyDefinition assembly, Namespace targetNamespace)
+ public void ImportAssembly (Assembly assembly, RootNamespace targetNamespace)
{
// It can be used more than once when importing same assembly
// into 2 or more global aliases
- if (!assembly_2_definition.ContainsKey (assembly.Assembly)) {
- assembly_2_definition.Add (assembly.Assembly, assembly);
- assembly.ReadAttributes ();
+ ImportedAssemblyDefinition definition;
+ if (!assembly_2_definition.TryGetValue (assembly, out definition)) {
+ definition = new ImportedAssemblyDefinition (assembly);
+ assembly_2_definition.Add (assembly, definition);
+
+ definition.ReadAttributes ();
}
- Type extension_type = assembly.HasExtensionMethod ? HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (assembly.Assembly)) : null;
+ Type extension_type = definition.HasExtensionMethod ? HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (assembly)) : null;
//
// This part tries to simulate loading of top-level
//
Type[] all_types;
try {
- all_types = assembly.Assembly.GetTypes ();
+ all_types = assembly.GetTypes ();
} catch (ReflectionTypeLoadException e) {
all_types = e.Types;
}
ImportTypes (all_types, targetNamespace, extension_type);
}
- public void ImportModule (Module module, Namespace targetNamespace)
+ public ImportedModuleDefinition ImportModule (Module module, RootNamespace targetNamespace)
{
+ var module_definition = new ImportedModuleDefinition (module, this);
+ module_definition.ReadAttributes ();
+
Type extension_type = HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (module));
Type[] all_types;
all_types = module.GetTypes ();
} catch (ReflectionTypeLoadException e) {
all_types = e.Types;
- throw;
}
ImportTypes (all_types, targetNamespace, extension_type);
+
+ return module_definition;
}
void ImportTypes (Type[] types, Namespace targetNamespace, Type extension_type)
}
}
+ public class ImportedModuleDefinition
+ {
+ readonly Module module;
+ bool cls_compliant;
+ //ReflectionMetaImporter metaImporter;
+
+ public ImportedModuleDefinition (Module module, ReflectionMetaImporter metaImporter)
+ {
+ this.module = module;
+ //this.metaImporter = metaImporter;
+ }
+
+ #region Properties
+
+ public bool IsCLSCompliant {
+ get {
+ return cls_compliant;
+ }
+ }
+
+ public string Name {
+ get {
+ return module.Name;
+ }
+ }
+
+ #endregion
+
+ public void ReadAttributes ()
+ {
+ IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes (module);
+ foreach (var a in attrs) {
+ var type = a.Constructor.DeclaringType;
+ if (type == typeof (CLSCompliantAttribute)) {
+ cls_compliant = (bool) a.ConstructorArguments[0].Value;
+ continue;
+ }
+ }
+ }
+
+ //
+ // Reads assembly attributes which where attached to a special type because
+ // module does have assembly manifest
+ //
+ public List<Attribute> ReadAssemblyAttributes ()
+ {
+ var t = module.GetType (AssemblyAttributesPlaceholder.TypeName);
+ if (t == null)
+ return null;
+
+ var field = t.GetField (AssemblyAttributesPlaceholder.AssemblyFieldName, BindingFlags.NonPublic | BindingFlags.Static);
+ if (field == null)
+ return null;
+
+ // TODO: implement, the idea is to fabricate specil Attribute class and
+ // add it to OptAttributes before resolving the source code attributes
+ // Need to build module location as well for correct error reporting
+
+ //var assembly_attributes = CustomAttributeData.GetCustomAttributes (field);
+ //var attrs = new List<Attribute> (assembly_attributes.Count);
+ //foreach (var a in assembly_attributes)
+ //{
+ // var type = metaImporter.ImportType (a.Constructor.DeclaringType);
+ // var ctor = metaImporter.CreateMethod (a.Constructor, type);
+
+ // foreach (var carg in a.ConstructorArguments) {
+ // carg.Value
+ // }
+
+ // attrs.Add (new Attribute ("assembly", ctor, null, Location.Null, true));
+ //}
+
+ return null;
+ }
+ }
+
public class ImportedAssemblyDefinition : IAssemblyDefinition
{
readonly Assembly assembly;
public class RootNamespace : Namespace {
- protected readonly string alias_name;
- protected List<ImportedAssemblyDefinition> referenced_assemblies;
-
- Dictionary<string, Namespace> all_namespaces;
+ readonly string alias_name;
+ readonly Dictionary<string, Namespace> all_namespaces;
public RootNamespace (string alias_name)
: base (null, String.Empty)
{
this.alias_name = alias_name;
- referenced_assemblies = new List<ImportedAssemblyDefinition> ();
all_namespaces = new Dictionary<string, Namespace> ();
all_namespaces.Add ("", this);
}
- public void AddAssemblyReference (ImportedAssemblyDefinition assembly)
- {
- referenced_assemblies.Add (assembly);
- }
-
- public virtual void ImportTypes (CompilerContext ctx)
- {
- foreach (var a in referenced_assemblies) {
- try {
- ctx.MetaImporter.ImportAssembly (a, this);
- } catch (TypeLoadException e) {
- ctx.Report.Error (11, Location.Null, e.Message);
- } catch (System.IO.FileNotFoundException) {
- ctx.Report.Error (12, Location.Null, "An assembly `{0}' is used without being referenced",
- a.FullName);
- }
+ public string Alias {
+ get {
+ return alias_name;
}
}
}
}
- // TODO: It should go to AssemblyClass or AssemblySpec
- public class GlobalRootNamespace : RootNamespace {
- Module [] modules;
- Dictionary<string, RootNamespace> root_namespaces;
- Dictionary<Assembly, ImportedAssemblyDefinition> all_assemblies;
-
+ public class GlobalRootNamespace : RootNamespace
+ {
public GlobalRootNamespace ()
: base ("global")
{
- root_namespaces = new Dictionary<string, RootNamespace> ();
- root_namespaces.Add (alias_name, this);
- all_assemblies = new Dictionary<Assembly, ImportedAssemblyDefinition> ();
- }
-
- public List<ImportedAssemblyDefinition> Assemblies {
- get { return referenced_assemblies; }
- }
-
- public Module [] Modules {
- get { return modules; }
- }
-
- public void AddAssemblyReference (Assembly assembly)
- {
- if (!all_assemblies.ContainsKey (assembly))
- AddAssemblyReference (CreateAssemblyDefinition (assembly));
- }
-
- public void AddModuleReference (Module m)
- {
- int top = modules != null ? modules.Length : 0;
- Module [] n = new Module [top + 1];
- if (modules != null)
- modules.CopyTo (n, 0);
- n [top] = m;
- modules = n;
-
- if (m == RootContext.ToplevelTypes.Builder)
- return;
-
- foreach (var t in m.GetTypes ())
- RegisterNamespace (t.Namespace);
- }
-
- public ImportedAssemblyDefinition CreateAssemblyDefinition (Assembly assembly)
- {
- ImportedAssemblyDefinition a;
- if (!all_assemblies.TryGetValue (assembly, out a)) {
- a = new ImportedAssemblyDefinition (assembly);
- all_assemblies.Add (assembly, a);
- }
-
- return a;
- }
-
- public void ComputeNamespaces (CompilerContext ctx)
- {
- foreach (RootNamespace rn in root_namespaces.Values) {
- rn.ImportTypes (ctx);
- }
- }
-
- public void DefineRootNamespace (string alias, Assembly assembly, CompilerContext ctx)
- {
- if (alias == alias_name) {
- NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null, ctx.Report);
- return;
- }
-
- RootNamespace retval = GetRootNamespace (alias);
- if (retval == null) {
- retval = new RootNamespace (alias);
- root_namespaces.Add (alias, retval);
- }
-
- retval.AddAssemblyReference (CreateAssemblyDefinition (assembly));
}
public override void Error_NamespaceDoesNotExist (Location loc, string name, int arity, IMemberContext ctx)
"The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)",
name);
}
-
- public RootNamespace GetRootNamespace (string name)
- {
- RootNamespace rn;
- if (!root_namespaces.TryGetValue (name, out rn))
- return null;
-
- return rn;
- }
-
- public override void ImportTypes (CompilerContext ctx)
- {
- base.ImportTypes (ctx);
-
- if (modules != null) {
- // 0 is this module
- for (int i = 1; i < modules.Length; ++i) {
- ctx.MetaImporter.ImportModule (modules[i], this);
- }
- }
- }
}
/// <summary>
public virtual FullNamedExpression Resolve (IMemberContext rc, bool local)
{
- FullNamedExpression fne = rc.Compiler.GlobalRootNamespace.GetRootNamespace (Alias);
+ FullNamedExpression fne = rc.CurrentMemberDefinition.Module.GetRootNamespace (Alias);
if (fne == null) {
rc.Compiler.Report.Error (430, Location,
"The extern alias `{0}' was not specified in -reference option",
public readonly DeclSpace SlaveDeclSpace;
static readonly Namespace [] empty_namespaces = new Namespace [0];
Namespace [] namespace_using_table;
- CompilerContext ctx;
+ ModuleContainer ctx;
static List<NamespaceEntry> entries = new List<NamespaceEntry> ();
entries = new List<NamespaceEntry> ();
}
- // TODO: ctx should be a module
- public NamespaceEntry (CompilerContext ctx, NamespaceEntry parent, CompilationUnit file, string name)
+ public NamespaceEntry (ModuleContainer ctx, NamespaceEntry parent, CompilationUnit file, string name)
{
this.ctx = ctx;
this.parent = parent;
if (parent != null)
ns = parent.NS.GetNamespace (name, true);
else if (name != null)
- ns = Compiler.GlobalRootNamespace.GetNamespace (name, true);
+ ns = ctx.GlobalRootNamespace.GetNamespace (name, true);
else
- ns = Compiler.GlobalRootNamespace;
+ ns = ctx.GlobalRootNamespace;
+
SlaveDeclSpace = new RootDeclSpace (this);
}
- private NamespaceEntry (CompilerContext ctx, NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
+ private NamespaceEntry (ModuleContainer ctx, NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
{
this.ctx = ctx;
this.parent = parent;
public static void Error_GlobalNamespaceRedefined (Location loc, Report Report)
{
- Report.Error (1681, loc, "You cannot redefine the global extern alias");
+ Report.Error (1681, loc, "The global extern alias cannot be redefined");
}
public static void Error_NamespaceNotFound (Location loc, string name, Report Report)
#region IMemberContext Members
public CompilerContext Compiler {
- get { return ctx; }
+ get { return ctx.Compiler; }
}
public TypeSpec CurrentType {
Constant c = default_expr as Constant;
if (c != null) {
if (default_expr.Type == TypeManager.decimal_type) {
- builder.SetCustomAttribute (Const.CreateDecimalConstantAttribute (c, pa));
+ pa.DecimalConstant.EmitAttribute (builder, (decimal) c.GetValue (), c.Location);
} else {
builder.SetConstant (c.GetTypedValue ());
}
AssemblyDefinition assembly;
readonly CompilerContext context;
+ readonly RootNamespace global_ns;
+ Dictionary<string, RootNamespace> alias_ns;
ModuleBuilder builder;
int static_data_counter;
types = new List<TypeContainer> ();
anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
+ global_ns = new GlobalRootNamespace ();
+ alias_ns = new Dictionary<string, RootNamespace> ();
+
+ // TODO: REMOVE
+ context.GlobalRootNamespace = global_ns;
}
#region Properties
}
}
+ //
+ // Returns module global:: namespace
+ //
+ public RootNamespace GlobalRootNamespace {
+ get {
+ return global_ns;
+ }
+ }
+
public override ModuleContainer Module {
get {
return this;
return builder.DefineType (name, attr, null, typeSize);
}
+ //
+ // Creates alias global namespace
+ //
+ public RootNamespace CreateRootNamespace (string alias)
+ {
+ if (alias == global_ns.Alias) {
+ NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null, Report);
+ return global_ns;
+ }
+
+ RootNamespace rn;
+ if (!alias_ns.TryGetValue (alias, out rn)) {
+ rn = new RootNamespace (alias);
+ alias_ns.Add (alias, rn);
+ }
+
+ return rn;
+ }
+
public new void Define ()
{
builder = assembly.CreateModuleBuilder ();
+ // FIXME: Temporary hack for repl to reset
+ TypeBuilder = null;
+
ResolveGlobalAttributes ();
foreach (TypeContainer tc in types)
OptAttributes.Emit ();
if (RootContext.Unsafe) {
- TypeSpec t = TypeManager.CoreLookupType (context, "System.Security", "UnverifiableCodeAttribute", MemberKind.Class, true);
- if (t != null) {
- var unverifiable_code_ctor = TypeManager.GetPredefinedConstructor (t, Location.Null, TypeSpec.EmptyTypes);
- if (unverifiable_code_ctor != null)
- builder.SetCustomAttribute (new CustomAttributeBuilder ((ConstructorInfo) unverifiable_code_ctor.GetMetaInfo (), new object[0]));
- }
+ var pa = Compiler.PredefinedAttributes.UnverifiableCode;
+ if (pa.IsDefined)
+ pa.EmitAttribute (builder);
}
foreach (var tc in types)
return null;
}
+ public RootNamespace GetRootNamespace (string name)
+ {
+ RootNamespace rn;
+ alias_ns.TryGetValue (name, out rn);
+ return rn;
+ }
+
public override string GetSignatureForError ()
{
return "<module>";
/// <summary>
/// It is called very early therefore can resolve only predefined attributes
/// </summary>
- public void ResolveGlobalAttributes ()
+ void ResolveGlobalAttributes ()
{
if (OptAttributes == null)
return;
/// population of the type has happened (for example, to
/// bootstrap the corlib.dll
/// </remarks>
- public static bool InitCoreTypes (CompilerContext ctx, IList<PredefinedTypeSpec> predefined)
+ public static bool InitCoreTypes (ModuleContainer module, IList<PredefinedTypeSpec> predefined)
{
+ var ctx = module.Compiler;
foreach (var p in predefined) {
var found = CoreLookupType (ctx, p.Namespace, p.Name, p.Kind, true);
if (found == null || found == p)
continue;
if (!RootContext.StdLib) {
- var ns = ctx.GlobalRootNamespace.GetNamespace (p.Namespace, false);
+ var ns = module.GlobalRootNamespace.GetNamespace (p.Namespace, false);
ns.ReplaceTypeWithPredefined (found, p);
var tc = found.MemberDefinition as TypeContainer;
gtest-437.cs
test-106.cs bug #628662
-test-416.cs bug #504085
test-418.cs bug #504085
test-454.cs bug #593342
test-682.cs bug #530861
-test-704.cs IGNORE #472845
-test-715.cs bug #504085
-test-759.cs IGNORE bug #604218
+test-704.cs bug #472845
test-xml-030.cs
test-xml-035.cs
gtest-437.cs
test-106.cs bug #628662
-test-416.cs bug #504085
test-418.cs bug #504085
test-454.cs bug #593342
test-682.cs bug #530861
-test-704.cs IGNORE #472845
-test-715.cs bug #504085
-test-759.cs IGNORE bug #604218
+test-704.cs bug #472845
test-xml-030.cs
test-xml-035.cs
</method>
</type>
</test>
+ <test name="dtest-friend-01.cs">
+ <type name="C">
+ <method name="Void Main()">
+ <size>90</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="dtest-implicitarray-01.cs">
<type name="C">
<method name="Void Method()">
</method>
</type>
</test>
+ <test name="gtest-549.cs">
+ <type name="C`1[T]">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D+Impl">
+ <method name="Void MA(Int32)">
+ <size>1</size>
+ </method>
+ <method name="Void MB(Int32)">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test">
+ <method name="Void Main()">
+ <size>21</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-1.cs">
<type name="X">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-anon-20.cs">
+ <type name="C`1[T]">
+ <method name="Void Foo[U](U)">
+ <size>20</size>
+ </method>
+ <method name="Void Run()">
+ <size>1</size>
+ </method>
+ <method name="Void <Foo`1>m__0[U]()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A">
+ <method name="Void Main()">
+ <size>8</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-21.cs">
<type name="BaseObject">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-anon-64.cs">
+ <type name="C`1[T]">
+ <method name="Void Foo[U](U)">
+ <size>81</size>
+ </method>
+ <method name="Void Run(T)">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="E">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A">
+ <method name="Int32 Main()">
+ <size>12</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C`1+<Foo>c__AnonStorey0`1[T,U]">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C`1+<Foo>c__AnonStorey1`1[T,U]">
+ <method name="U <>m__0()">
+ <size>12</size>
+ </method>
+ <method name="Void <>m__1()">
+ <size>12</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-7.cs">
<type name="MyDisposable">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-iter-17.cs">
+ <type name="Test">
+ <method name="IEnumerable`1 TestMethod()">
+ <size>16</size>
+ </method>
+ <method name="Void Main()">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test+<TestMethod>c__Iterator0">
+ <method name="Int32 System.Collections.Generic.IEnumerator<int>.get_Current()">
+ <size>7</size>
+ </method>
+ <method name="System.Object System.Collections.IEnumerator.get_Current()">
+ <size>12</size>
+ </method>
+ <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+ <size>7</size>
+ </method>
+ <method name="IEnumerator`1 System.Collections.Generic.IEnumerable<int>.GetEnumerator()">
+ <size>26</size>
+ </method>
+ <method name="Boolean MoveNext()">
+ <size>45</size>
+ </method>
+ <method name="Void Dispose()">
+ <size>8</size>
+ </method>
+ <method name="Void Reset()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
+ <test name="gtest-iter-18.cs">
+ <type name="c">
+ <method name="IEnumerable`1 func()">
+ <size>16</size>
+ </method>
+ <method name="Void Main()">
+ <size>53</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="c+<func>c__Iterator0">
+ <method name="Char System.Collections.Generic.IEnumerator<char>.get_Current()">
+ <size>7</size>
+ </method>
+ <method name="System.Object System.Collections.IEnumerator.get_Current()">
+ <size>12</size>
+ </method>
+ <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+ <size>7</size>
+ </method>
+ <method name="IEnumerator`1 System.Collections.Generic.IEnumerable<char>.GetEnumerator()">
+ <size>26</size>
+ </method>
+ <method name="Boolean MoveNext()">
+ <size>69</size>
+ </method>
+ <method name="Void Dispose()">
+ <size>8</size>
+ </method>
+ <method name="Void Reset()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-lambda-01.cs">
<type name="X">
<method name="Int32 Main()">
</method>
</type>
</test>
+ <test name="test-416.cs">
+ <type name="ModTest">
+ <method name="Void Main(System.String[])">
+ <size>20</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="n1.Adder">
+ <method name="Int32 Add(Int32, Int32)">
+ <size>4</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-417.cs">
<type name="blah2.MyClass">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="test-715.cs">
+ <type name="C">
+ <method name="Int32 Main()">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-716.cs">
<type name="SS">
<method name="Void .cctor()">
</method>
</type>
</test>
+ <test name="gtest-549.cs">
+ <type name="C`1[T]">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D+Impl">
+ <method name="Void MA(Int32)">
+ <size>1</size>
+ </method>
+ <method name="Void MB(Int32)">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test">
+ <method name="Void Main()">
+ <size>21</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-1.cs">
<type name="X">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-anon-20.cs">
+ <type name="C`1[T]">
+ <method name="Void Foo[U](U)">
+ <size>20</size>
+ </method>
+ <method name="Void Run()">
+ <size>1</size>
+ </method>
+ <method name="Void <Foo`1>m__0[U]()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A">
+ <method name="Void Main()">
+ <size>8</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-21.cs">
<type name="BaseObject">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-anon-64.cs">
+ <type name="C`1[T]">
+ <method name="Void Foo[U](U)">
+ <size>81</size>
+ </method>
+ <method name="Void Run(T)">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="D">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="E">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A">
+ <method name="Int32 Main()">
+ <size>12</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C`1+<Foo>c__AnonStorey0`1[T,U]">
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C`1+<Foo>c__AnonStorey1`1[T,U]">
+ <method name="U <>m__0()">
+ <size>12</size>
+ </method>
+ <method name="Void <>m__1()">
+ <size>12</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anon-7.cs">
<type name="MyDisposable">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="gtest-iter-17.cs">
+ <type name="Test">
+ <method name="IEnumerable`1 TestMethod()">
+ <size>16</size>
+ </method>
+ <method name="Void Main()">
+ <size>1</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test+<TestMethod>c__Iterator0">
+ <method name="Int32 System.Collections.Generic.IEnumerator<int>.get_Current()">
+ <size>7</size>
+ </method>
+ <method name="System.Object System.Collections.IEnumerator.get_Current()">
+ <size>12</size>
+ </method>
+ <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+ <size>7</size>
+ </method>
+ <method name="IEnumerator`1 System.Collections.Generic.IEnumerable<int>.GetEnumerator()">
+ <size>26</size>
+ </method>
+ <method name="Boolean MoveNext()">
+ <size>45</size>
+ </method>
+ <method name="Void Dispose()">
+ <size>8</size>
+ </method>
+ <method name="Void Reset()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
+ <test name="gtest-iter-18.cs">
+ <type name="c">
+ <method name="IEnumerable`1 func()">
+ <size>16</size>
+ </method>
+ <method name="Void Main()">
+ <size>53</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="c+<func>c__Iterator0">
+ <method name="Char System.Collections.Generic.IEnumerator<char>.get_Current()">
+ <size>7</size>
+ </method>
+ <method name="System.Object System.Collections.IEnumerator.get_Current()">
+ <size>12</size>
+ </method>
+ <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+ <size>7</size>
+ </method>
+ <method name="IEnumerator`1 System.Collections.Generic.IEnumerable<char>.GetEnumerator()">
+ <size>26</size>
+ </method>
+ <method name="Boolean MoveNext()">
+ <size>69</size>
+ </method>
+ <method name="Void Dispose()">
+ <size>8</size>
+ </method>
+ <method name="Void Reset()">
+ <size>6</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-lambda-01.cs">
<type name="X">
<method name="Int32 Main()">
</method>
</type>
</test>
+ <test name="test-416.cs">
+ <type name="ModTest">
+ <method name="Void Main(System.String[])">
+ <size>20</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="n1.Adder">
+ <method name="Int32 Add(Int32, Int32)">
+ <size>4</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-417.cs">
<type name="blah2.MyClass">
<method name="Void .ctor()">
</method>
</type>
</test>
+ <test name="test-715.cs">
+ <type name="C">
+ <method name="Int32 Main()">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-716.cs">
<type name="SS">
<method name="Void .cctor()">
</method>
</type>
</test>
+ <test name="test-759.cs">
+ <type name="B">
+ <method name="Void Main()">
+ <size>12</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-76.cs">
<type name="foo">
<method name="Void .ctor()">