+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ * typemanager.cs (TypeManager.CheckStructCycles): Fixed.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ Applying a patch from Benjamin Jemlich <pcgod@gmx.net>.
+
+ * ecore.cs (FieldExpr.AddressOf): Make this work for valuetypes.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ * class.cs (ConstructorInitializer.Resolve): Check whether the
+ parent .ctor is accessible. Fixes #52146.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ Applying a patch from Benjamin Jemlich <pcgod@gmx.net>.
+
+ * statement.cs (Using.EmitLocalVariableDecls): Use
+ TypeManager.idisposable_type, not typeof (IDisposable).
+ (Foreach.EmitCollectionForeach): Added support for valuetypes.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ * class.cs (Event.Define): Don't emit the field and don't set
+ RTSpecialName and SpecialName for events on interfaces. Fixes
+ #57703.
+
+2004-04-29 Raja R Harinath <rharinath@novell.com>
+
+ Refactor Attribute.ApplyAttributes.
+ * attribute.cs (Attributable): New base class for objects that can
+ have Attributes applied on them.
+ (Attribute): Make AttributeUsage fields public.
+ (Attribute.GetFieldValue, Attribute.GetMarshal): Make non-static.
+ (Attribute.IsInternalCall): New property.
+ (Attribute.UsageAttr): Convert to a public read-only property.
+ (Attribute.CheckAttributeType): Use a DeclSpace, not an EmitContext.
+ (Attribute.ResolveType, Attribute.Resolve)
+ (Attribute.ScanForIndexerName): Update to reflect changes.
+ (Attribute.CheckAttributeTarget): Re-format.
+ (Attribute.ApplyAttributes): Refactor, to various
+ Attributable.ApplyAttributeBuilder methods.
+ * decl.cs (MemberCore): Make Attributable.
+ * class.cs (Accessor): Make Attributable.
+ (MethodData.ApplyAttributes): Use proper attribute types, not
+ attribute names.
+ (TypeContainer.LabelParameters): Pass Parameter to ApplyAttributes.
+ (TypeContainer.ApplyAttributeBuilder)
+ (Method.ApplyAttributeBuilder, Constructor.ApplyAttributeBuilder)
+ (Field.ApplyAttributeBuilder, Accessor.ApplyAttributeBuilder)
+ (PropertyBase.ApplyAttributeBuilder, Event.ApplyAttributeBuilder)
+ (Operator.ApplyAttributeBuilder): New factored-out methods.
+ * const.cs (Const.ApplyAttributeBuilder): Likewise.
+ * delegate.cs (Delegate.ApplyAttributeBuilder): Likewise.
+ * enum.cs (Enum.ApplyAttributeBuilder): Likewise.
+ * parameter.cs (ParameterBase): New Attributable base class
+ that can also represent Return types.
+ (Parameter): Update to the changes.
+
+2004-04-29 Jackson Harper <jackson@ximian.com>
+
+ * driver.cs: Prefer the corlib system version when looking for
+ assemblies in the GAC. This is still a hack, but its a better hack
+ now.
+
+2004-04-29 Marek Safar <marek.safar@seznam.cz>
+
+ * decl.cs, enum.cs: Improved error 3005 reporting.
+
+ * report.cs (SymbolRelatedToPreviousError): New method for error reporting.
+ (related_symbols): New private member for list of symbols
+ related to reported error/warning.
+
+ * tree.cs: Do not use now obsolete Report.LocationOfPreviousError.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ * ecore.cs (Expression.Constantify): If we're an enum and
+ TypeManager.TypeToCoreType() doesn't give us another type, use
+ t.UnderlyingSystemType. Fixes #56178.
+
+2004-04-29 Martin Baulig <martin@ximian.com>
+
+ * decl.cs (MemberCache.SetupCacheForInterface): Look over all our
+ interfaces and for each interface, only add members directly
+ declared in that interface. Fixes #53255.
+
+2004-04-28 Martin Baulig <martin@ximian.com>
+
+ * expression.cs (ConditionalLogicalOperator): Use a temporary
+ variable for `left' to avoid that we evaluate it more than once;
+ bug #52588.
+
+2004-04-28 Martin Baulig <martin@ximian.com>
+
+ * expression.cs (ComposedCast.DoResolveAsTypeStep): Don't allow
+ `void[]' (CS1547).
+
+2004-04-28 Martin Baulig <martin@ximian.com>
+
+ * statement.cs (LocalInfo.Resolve): Check whether the type is not
+ void (CS1547).
+
+ * class.cs (MemberBase.CheckParameters, FieldBase.DoDefine): Check
+ whether the type is not void (CS1547).
+
+2004-04-28 Martin Baulig <martin@ximian.com>
+
+ * expression.cs (Unary.DoResolveLValue): Override this and report
+ CS0131 for anything but Operator.Indirection.
+
+2004-04-28 Martin Baulig <martin@ximian.com>
+
+ Committing a patch from Ben Maurer; see bug #50820.
+
+ * typemanager.cs (TypeManager.FilterWithClosure): Added CS1540
+ check for classes.
+
+ * ecore.cs (Expression.MemberLookupFailed): Added CS1540 check for
+ classes.
+
2004-04-28 Martin Baulig <martin@ximian.com>
* statement.cs (Block.LookupLabel): Also lookup in implicit child blocks.
for a named field or property, implicity convert it to the correct
type.
->>>>>>> 1.1450
2004-04-27 Raja R Harinath <rharinath@novell.com>
* statement.cs (Block.Block): Implicit blocks share
using System.Text;\r
\r
namespace Mono.CSharp {\r
+ /// <summary>\r
+ /// Base class for objects that can have Attributes applied to them.\r
+ /// </summary>\r
+ public abstract class Attributable {\r
+ /// <summary>\r
+ /// Attributes for this type\r
+ /// </summary>\r
+ Attributes attributes;\r
+\r
+ public Attributable(Attributes attrs)\r
+ {\r
+ attributes = attrs;\r
+ }\r
+\r
+ public Attributes OptAttributes \r
+ {\r
+ get {\r
+ return attributes;\r
+ }\r
+ set {\r
+ attributes = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Use member-specific procedure to apply attribute @a in @cb to the entity being built in @builder\r
+ /// </summary>\r
+ public abstract void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb);\r
+ };\r
+\r
\r
public class Attribute {\r
public readonly string Name;\r
// The following are only meaningful when the attribute\r
// being emitted is an AttributeUsage attribute\r
//\r
- AttributeTargets Targets;\r
- bool AllowMultiple;\r
- bool Inherited;\r
+ public AttributeTargets Targets;\r
+ public bool AllowMultiple;\r
+ public bool Inherited;\r
\r
- bool UsageAttr = false;\r
+ bool usage_attr = false;\r
\r
+ public bool UsageAttr {\r
+ get { return usage_attr; }\r
+ }\r
+\r
MethodImplOptions ImplOptions;\r
UnmanagedType UnmanagedType;\r
CustomAttributeBuilder cb;\r
\r
public Type ResolveType (EmitContext ec)\r
{\r
- Type = CheckAttributeType (ec);\r
+ if (Type == null)\r
+ Type = CheckAttributeType (ec);\r
return Type;\r
}\r
\r
\r
public CustomAttributeBuilder Resolve (EmitContext ec)\r
{\r
- if (Type == null)\r
- Type = CheckAttributeType (ec);\r
+ ResolveType (ec);\r
if (Type == null)\r
return null;\r
\r
bool MethodImplAttr = false;\r
bool MarshalAsAttr = false;\r
bool GuidAttr = false;\r
- UsageAttr = false;\r
+ usage_attr = false;\r
\r
bool DoCompares = true;\r
\r
//\r
\r
if (Type == TypeManager.attribute_usage_type)\r
- UsageAttr = true;\r
+ usage_attr = true;\r
else if (Type == TypeManager.methodimpl_attr_type)\r
MethodImplAttr = true;\r
else if (Type == TypeManager.marshal_as_attr_type)\r
} else\r
targets = attr.Targets;\r
\r
-\r
- if (element is Class) {\r
- if ((targets & AttributeTargets.Class) != 0)\r
- return true;\r
- else\r
- return false;\r
- \r
- } else if (element is Struct) {\r
- if ((targets & AttributeTargets.Struct) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Constructor) {\r
- if ((targets & AttributeTargets.Constructor) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Delegate) {\r
- if ((targets & AttributeTargets.Delegate) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Enum) {\r
- if ((targets & AttributeTargets.Enum) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Event) {\r
- if ((targets & AttributeTargets.Event) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Field || element is FieldBuilder) {\r
- if ((targets & AttributeTargets.Field) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Interface) {\r
- if ((targets & AttributeTargets.Interface) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Method || element is Operator ||\r
- element is Accessor) {\r
- if ((targets & AttributeTargets.Method) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is ParameterBuilder) {\r
- if ((targets & AttributeTargets.Parameter) != 0 ||\r
- (targets & AttributeTargets.ReturnValue) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is Property || element is Indexer ||\r
- element is Accessor) {\r
- if ((targets & AttributeTargets.Property) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is AssemblyClass){\r
- if ((targets & AttributeTargets.Assembly) != 0)\r
- return true;\r
- else\r
- return false;\r
- } else if (element is ModuleClass){\r
- if ((targets & AttributeTargets.Module) != 0)\r
- return true;\r
- else\r
- return false;\r
- }\r
+ if (element is Class) return ((targets & AttributeTargets.Class) != 0);\r
+ if (element is Struct) return ((targets & AttributeTargets.Struct) != 0);\r
+ if (element is Constructor) return ((targets & AttributeTargets.Constructor) != 0);\r
+ if (element is Delegate) return ((targets & AttributeTargets.Delegate) != 0);\r
+ if (element is Enum) return ((targets & AttributeTargets.Enum) != 0);\r
+ if (element is Event) return ((targets & AttributeTargets.Event) != 0);\r
+ if (element is Field \r
+ || element is FieldBuilder) return ((targets & AttributeTargets.Field) != 0);\r
+ if (element is Interface) return ((targets & AttributeTargets.Interface) != 0);\r
+ if (element is Method\r
+ || element is Operator\r
+ || element is Accessor) return ((targets & AttributeTargets.Method) != 0);\r
+ if (element is ParameterBase) return ((targets & (AttributeTargets.Parameter \r
+ | AttributeTargets.ReturnValue)) != 0);\r
+ if (element is Property\r
+ || element is Indexer\r
+ || element is Accessor) return ((targets & AttributeTargets.Property) != 0);\r
+ if (element is AssemblyClass) return ((targets & AttributeTargets.Assembly) != 0);\r
+ if (element is ModuleClass) return ((targets & AttributeTargets.Module) != 0);\r
\r
return false;\r
}\r
return (bool)pos_values [0];\r
}\r
\r
- static object GetFieldValue (Attribute a, string name)\r
+ object GetFieldValue (string name)\r
{\r
int i;\r
- if (a.field_info_arr == null)\r
+ if (field_info_arr == null)\r
return null;\r
i = 0;\r
- foreach (FieldInfo fi in a.field_info_arr) {\r
+ foreach (FieldInfo fi in field_info_arr) {\r
if (fi.Name == name)\r
- return a.field_values_arr [i];\r
+ return field_values_arr [i];\r
i++;\r
}\r
return null;\r
}\r
\r
- static UnmanagedMarshal GetMarshal (Attribute a)\r
+ public UnmanagedMarshal GetMarshal ()\r
{\r
- object o = GetFieldValue (a, "ArraySubType");\r
+ object o = GetFieldValue ("ArraySubType");\r
UnmanagedType array_sub_type = o == null ? UnmanagedType.I4 : (UnmanagedType) o;\r
- switch (a.UnmanagedType) {\r
+ switch (UnmanagedType) {\r
case UnmanagedType.CustomMarshaler:\r
MethodInfo define_custom = typeof (UnmanagedMarshal).GetMethod ("DefineCustom",\r
BindingFlags.Static | BindingFlags.Public);\r
return null;\r
\r
object [] args = new object [4];\r
- args [0] = GetFieldValue (a, "MarshalTypeRef");\r
- args [1] = GetFieldValue (a, "MarshalCookie");\r
- args [2] = GetFieldValue (a, "MarshalType");\r
+ args [0] = GetFieldValue ("MarshalTypeRef");\r
+ args [1] = GetFieldValue ("MarshalCookie");\r
+ args [2] = GetFieldValue ("MarshalType");\r
args [3] = Guid.Empty;\r
return (UnmanagedMarshal) define_custom.Invoke (null, args);\r
\r
return UnmanagedMarshal.DefineSafeArray (array_sub_type);\r
\r
case UnmanagedType.ByValArray:\r
- return UnmanagedMarshal.DefineByValArray ((int) GetFieldValue (a, "SizeConst"));\r
+ return UnmanagedMarshal.DefineByValArray ((int) GetFieldValue ("SizeConst"));\r
\r
case UnmanagedType.ByValTStr:\r
- return UnmanagedMarshal.DefineByValTStr ((int) GetFieldValue (a, "SizeConst"));\r
+ return UnmanagedMarshal.DefineByValTStr ((int) GetFieldValue ("SizeConst"));\r
\r
default:\r
- return UnmanagedMarshal.DefineUnmanagedMarshal (a.UnmanagedType);\r
+ return UnmanagedMarshal.DefineUnmanagedMarshal (UnmanagedType);\r
}\r
}\r
\r
+ public bool IsInternalCall\r
+ {\r
+ get { return ImplOptions == MethodImplOptions.InternalCall; }\r
+ }\r
+\r
/// <summary>\r
/// Applies the attributes specified on target 'kind' to the `builder'.\r
/// </summary>\r
if (cb == null) \r
continue;\r
\r
- if (!(kind is TypeContainer))\r
- if (!CheckAttributeTarget (a, kind)) {\r
- Error_AttributeNotValidForElement (a, loc);\r
- return;\r
- }\r
-\r
//\r
// Perform the check for duplicate attributes\r
//\r
return;\r
}\r
\r
- if (kind is IAttributeSupport) {\r
- if (attr_type == TypeManager.methodimpl_attr_type && a.ImplOptions == MethodImplOptions.InternalCall) {\r
- ((MethodBuilder) builder).SetImplementationFlags (MethodImplAttributes.InternalCall | MethodImplAttributes.Runtime);\r
- } \r
- else {\r
- IAttributeSupport attributeSupport = kind as IAttributeSupport;\r
- attributeSupport.SetCustomAttribute (cb);\r
- }\r
+ if (!CheckAttributeTarget (a, kind)) {\r
+ Error_AttributeNotValidForElement (a, loc);\r
+ return;\r
}\r
- else if (kind is Method || kind is Operator || kind is Accessor) {\r
- if (attr_type == TypeManager.methodimpl_attr_type) {\r
- if (a.ImplOptions == MethodImplOptions.InternalCall)\r
- ((MethodBuilder) builder).\r
- SetImplementationFlags (\r
- MethodImplAttributes.InternalCall |\r
- MethodImplAttributes.Runtime);\r
- else\r
- ((MethodBuilder) builder).SetCustomAttribute (cb);\r
- } else if (attr_type != TypeManager.dllimport_type){\r
- ((MethodBuilder) builder).SetCustomAttribute (cb);\r
- }\r
- } else if (kind is Constructor) {\r
- ((ConstructorBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is Field) {\r
- if (attr_type == TypeManager.marshal_as_attr_type) {\r
- UnmanagedMarshal marshal = GetMarshal (a);\r
- if (marshal == null) {\r
- Report.Warning (-24, loc,\r
- "The Microsoft Runtime cannot set this marshal info. " +\r
- "Please use the Mono runtime instead.");\r
- } else {\r
- ((FieldBuilder) builder).SetMarshal (marshal);\r
- }\r
- } else { \r
- ((FieldBuilder) builder).SetCustomAttribute (cb);\r
- }\r
- } else if (kind is Property || kind is Indexer) {\r
-\r
- if (builder is PropertyBuilder) \r
- ((PropertyBuilder) builder).SetCustomAttribute (cb);\r
- //\r
- // This is for the case we are setting attributes on\r
- // the get and set accessors\r
- //\r
- else if (builder is MethodBuilder)\r
- ((MethodBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is Event) {\r
- ((MyEventBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is ParameterBuilder) {\r
-\r
- if (attr_type == TypeManager.marshal_as_attr_type) {\r
- UnmanagedMarshal marshal = GetMarshal (a);\r
- if (marshal == null) {\r
- Report.Warning (-24, loc,\r
- "The Microsoft Runtime cannot set this marshal info. " +\r
- "Please use the Mono runtime instead.");\r
- } else {\r
- ((ParameterBuilder) builder).SetMarshal (marshal);\r
- }\r
- } else { \r
-\r
- try {\r
- ((ParameterBuilder) builder).SetCustomAttribute (cb);\r
- } catch (System.ArgumentException) {\r
- Report.Warning (-24, loc,\r
- "The Microsoft Runtime cannot set attributes \n" +\r
- "on the return type of a method. Please use the \n" +\r
- "Mono runtime instead.");\r
- }\r
-\r
- }\r
- } else if (kind is Enum) {\r
- ((TypeBuilder) builder).SetCustomAttribute (cb); \r
-\r
- } else if (kind is TypeContainer) {\r
- TypeContainer tc = (TypeContainer) kind;\r
- \r
- if (a.UsageAttr) {\r
- tc.Targets = a.Targets;\r
- tc.AllowMultiple = a.AllowMultiple;\r
- tc.Inherited = a.Inherited;\r
-\r
- TypeManager.RegisterAttributeAllowMultiple (tc.TypeBuilder,\r
- tc.AllowMultiple);\r
- \r
- } else if (attr_type == TypeManager.default_member_type) {\r
- if (tc.Indexers != null) {\r
- Report.Error (646, loc,\r
- "Cannot specify the DefaultMember attribute on" +\r
- " a type containing an indexer");\r
- return;\r
- }\r
-\r
- } else {\r
- if (!CheckAttributeTarget (a, kind)) {\r
- Error_AttributeNotValidForElement (a, loc);\r
- return;\r
- }\r
- }\r
-\r
- try {\r
- ((TypeBuilder) builder).SetCustomAttribute (cb);\r
- } catch (System.ArgumentException) {\r
- Report.Warning (\r
- -21, loc,\r
- "The CharSet named property on StructLayout\n"+\r
- "\tdoes not work correctly on Microsoft.NET\n"+\r
- "\tYou might want to remove the CharSet declaration\n"+\r
- "\tor compile using the Mono runtime instead of the\n"+\r
- "\tMicrosoft .NET runtime");\r
- }\r
- } else if (kind is Delegate){\r
- if (!CheckAttributeTarget (a, kind)) {\r
- Error_AttributeNotValidForElement (a, loc);\r
- return;\r
- }\r
- try {\r
- ((TypeBuilder) builder).SetCustomAttribute (cb);\r
- } catch (System.ArgumentException) {\r
- Report.Warning (\r
- -21, loc,\r
- "The CharSet named property on StructLayout\n"+\r
- "\tdoes not work correctly on Microsoft.NET\n"+\r
- "\tYou might want to remove the CharSet declaration\n"+\r
- "\tor compile using the Mono runtime instead of the\n"+\r
- "\tMicrosoft .NET runtime");\r
- }\r
- } else if (kind is Interface) {\r
- Interface iface = (Interface) kind;\r
-\r
- if ((attr_type == TypeManager.default_member_type) &&\r
- (iface.Indexers != null)) {\r
- Report.Error (\r
- 646, loc,\r
- "Cannot specify the DefaultMember attribute on" +\r
- " a type containing an indexer");\r
- return;\r
- }\r
\r
- if (!CheckAttributeTarget (a, kind)) {\r
- Error_AttributeNotValidForElement (a, loc);\r
- return;\r
- }\r
-\r
- ((TypeBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is AssemblyBuilder){\r
- ((AssemblyBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is ModuleBuilder) {\r
- ((ModuleBuilder) builder).SetCustomAttribute (cb);\r
- } else if (kind is FieldBuilder) {\r
- if (attr_type == TypeManager.marshal_as_attr_type) {\r
- UnmanagedMarshal marshal = GetMarshal (a);\r
+ if (kind is Attributable) {\r
+ Attributable able = kind as Attributable;\r
+ able.ApplyAttributeBuilder (builder, a, cb);\r
+ }\r
+ else if (kind is IAttributeSupport) {\r
+ IAttributeSupport attributeSupport = kind as IAttributeSupport;\r
+ attributeSupport.SetCustomAttribute (cb);\r
+ } \r
+ else if (kind is FieldBuilder) {\r
+ // This is used only for enumerated constants\r
+ if (attr_type == TypeManager.marshal_as_attr_type) {\r
+ UnmanagedMarshal marshal = a.GetMarshal ();\r
if (marshal == null) {\r
Report.Warning (-24, loc,\r
- "The Microsoft Runtime cannot set this marshal info. " +\r
- "Please use the Mono runtime instead.");\r
+ "The Microsoft Runtime cannot set this marshal info. " +\r
+ "Please use the Mono runtime instead.");\r
} else {\r
- ((ParameterBuilder) builder).SetMarshal (marshal);\r
+ ((FieldBuilder) builder).SetMarshal (marshal);\r
}\r
} else { \r
((FieldBuilder) builder).SetCustomAttribute (cb);\r
}\r
- } else\r
- throw new Exception ("Unknown kind: " + kind);\r
+ } \r
+ else {\r
+ throw new Exception ("" + loc + ": Error applying Attribute " + a.Type \r
+ + " to unknown kind " + kind);\r
+ }\r
\r
- //\r
// Once an attribute type has been emitted once we\r
// keep track of the info to prevent multiple occurences\r
// for attributes which do not explicitly allow it\r
return null;\r
}\r
\r
- Type = CheckAttributeType (ec);\r
+ ResolveType (ec);\r
if (Type == null)\r
return null;\r
\r
return AdditionResult.Success;
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ TypeBuilder tb = builder as TypeBuilder;
+
+ if (a.UsageAttr) {
+ Targets = a.Targets;
+ AllowMultiple = a.AllowMultiple;
+ Inherited = a.Inherited;
+
+ TypeManager.RegisterAttributeAllowMultiple (tb, AllowMultiple);
+ }
+
+ if (a.Type == TypeManager.default_member_type) {
+ if (Indexers != null) {
+ Report.Error (646, a.Location,
+ "Cannot specify the DefaultMember attribute on" +
+ " a type containing an indexer");
+ return;
+ }
+ }
+
+ try {
+ tb.SetCustomAttribute (cb);
+ }
+ catch (System.ArgumentException e) {
+ Report.Warning (-21, a.Location,
+ "The CharSet named property on StructLayout\n"+
+ "\tdoes not work correctly on Microsoft.NET\n"+
+ "\tYou might want to remove the CharSet declaration\n"+
+ "\tor compile using the Mono runtime instead of the\n"+
+ "\tMicrosoft .NET runtime.\n"+
+ "\tThe runtime reported the error: " + e);
+ }
+ }
+
public void RegisterOrder (Interface iface)
{
if (interface_order == null)
Attributes attr = p [i].OptAttributes;
if (attr != null){
- Attribute.ApplyAttributes (ec, pb, pb, attr);
+ Attribute.ApplyAttributes (ec, pb, p[i], attr);
if (par_attr == ParameterAttributes.Out){
if (attr.Contains (TypeManager.in_attribute_type))
}
if (ret_attrs != null) {
+ ParameterBase ret = new ParameterBase (ret_attrs);
+
try {
- ret_pb = mb.DefineParameter (0, ParameterAttributes.None, "");
- Attribute.ApplyAttributes (ec, ret_pb, ret_pb, ret_attrs);
+ ret_pb = mb.DefineParameter (0, ParameterAttributes.None, "");
+ Attribute.ApplyAttributes (ec, ret_pb, ret, ret_attrs);
} catch (ArgumentOutOfRangeException) {
Report.Warning (
return false;
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ MethodBuilder mb = builder as MethodBuilder;
+
+ if (a.Type == TypeManager.methodimpl_attr_type && a.IsInternalCall)
+ mb.SetImplementationFlags (MethodImplAttributes.InternalCall | MethodImplAttributes.Runtime);
+ else if (a.Type != TypeManager.dllimport_type)
+ mb.SetCustomAttribute (cb);
+ }
+
//
// Checks our base implementation if any
//
t = ec.ContainerType;
parent_constructor_group = Expression.MemberLookup (
- ec, t, null, t, ".ctor",
- MemberTypes.Constructor,
+ ec, t, ".ctor", MemberTypes.Constructor,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
loc);
if (parent_constructor_group == null){
- Report.Error (1501, loc,
- "Can not find a constructor for this argument list");
+ parent_constructor_group = Expression.MemberLookup (
+ ec, t, ".ctor", MemberTypes.Constructor,
+ BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ loc);
+
+ if (parent_constructor_group != null)
+ Report.Error (
+ 112, loc, "`{0}.{1}' is inaccessible due to " +
+ "its protection level", t.FullName, t.Name);
+ else
+ Report.Error (
+ 1501, loc, "Can not find a constructor for " +
+ "this argument list");
return false;
}
(Initializer.Arguments == null);
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ ((ConstructorBuilder) builder).SetCustomAttribute (cb);
+ }
+
protected override bool CheckBase (TypeContainer container)
{
base.CheckBase (container);
string obsolete = null;
bool obsolete_error = false;
- public virtual bool ApplyAttributes (Attributes opt_attrs, bool is_method)
+ public virtual bool ApplyAttributes (Attributes opt_attrs, bool is_method, DeclSpace ds)
{
if ((opt_attrs == null) || (opt_attrs.AttributeSections == null))
return true;
continue;
foreach (Attribute a in asec.Attributes) {
- if (a.Name == "Conditional") {
+ Type attr_type = a.ResolveType (ec);
+ if (attr_type == TypeManager.conditional_attribute_type) {
if (!ApplyConditionalAttribute (a))
return false;
- } else if (a.Name == "Obsolete") {
+ } else if (attr_type == TypeManager.obsolete_attribute_type) {
if (!ApplyObsoleteAttribute (a))
return false;
- } else if (a.Name.IndexOf ("DllImport") != -1) {
+ } else if (attr_type == TypeManager.dllimport_type) {
if (!is_method) {
- a.Type = TypeManager.dllimport_type;
Attribute.Error_AttributeNotValidForElement (a, method.Location);
return false;
}
string prefix;
if (method.OptAttributes != null)
- if (!ApplyAttributes (method.OptAttributes, is_method))
+ if (!ApplyAttributes (method.OptAttributes, is_method, container))
return false;
if (member.IsExplicitImpl)
bool error = false;
foreach (Type partype in parameters){
+ if (partype == TypeManager.void_type) {
+ Report.Error (
+ 1547, Location, "Keyword 'void' cannot " +
+ "be used in this context");
+ return false;
+ }
+
if (partype.IsPointer){
if (!UnsafeOK (ds))
error = true;
return init_expr;
}
+ protected override bool DoDefine (DeclSpace ds, TypeContainer container)
+ {
+ if (!base.DoDefine (ds, container))
+ return false;
+
+ if (MemberType == TypeManager.void_type) {
+ Report.Error (1547, Location,
+ "Keyword 'void' cannot be used in this context");
+ return false;
+ }
+
+ return true;
+ }
+
public override string GetSignatureForError ()
{
return TypeManager.GetFullNameSignature (FieldBuilder);
{
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ FieldBuilder fb = builder as FieldBuilder;
+
+ if (a.Type == TypeManager.marshal_as_attr_type) {
+ UnmanagedMarshal marshal = a.GetMarshal ();
+ if (marshal == null)
+ Report.Warning (-24, a.Location,
+ "The Microsoft Runtime cannot set this marshal info. " +
+ "Please use the Mono runtime instead.");
+ else
+ fb.SetMarshal (marshal);
+ }
+ else
+ fb.SetCustomAttribute (cb);
+ }
+
public override bool Define (TypeContainer container)
{
Type t = container.ResolveType (Type, false, Location);
//
// `set' and `get' accessors are represented with an Accessor.
//
- public class Accessor {
+ public class Accessor : Attributable {
//
// Null if the accessor is empty, or a Block if not
//
public Block Block;
- public Attributes OptAttributes;
public Accessor (Block b, Attributes attrs)
+ : base (attrs)
{
Block = b;
- OptAttributes = attrs;
+ }
+
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ MethodBuilder mb = builder as MethodBuilder;
+
+ if (a.Type == TypeManager.methodimpl_attr_type && a.IsInternalCall)
+ mb.SetImplementationFlags (MethodImplAttributes.InternalCall | MethodImplAttributes.Runtime);
+ else if (a.Type != TypeManager.dllimport_type)
+ mb.SetCustomAttribute (cb);
}
}
{
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ if (builder is PropertyBuilder)
+ ((PropertyBuilder) builder).SetCustomAttribute (cb);
+ //
+ // This is for the case we are setting attributes on
+ // the get and set accessors
+ //
+ else if (builder is MethodBuilder)
+ ((MethodBuilder) builder).SetCustomAttribute (cb);
+ }
+
protected override bool DoDefine (DeclSpace decl, TypeContainer container)
{
if (!base.DoDefine (decl, container))
is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
name, init, attrs, loc)
{
+ IsInterface = is_iface;
Add = new AddDelegateMethod (this, add);
Remove = new RemoveDelegateMethod (this, remove);
- IsInterface = is_iface;
this.ds = ds;
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ ((MyEventBuilder) builder).SetCustomAttribute (cb);
+ }
+
public override bool Define (TypeContainer container)
{
- EventAttributes e_attr = EventAttributes.RTSpecialName | EventAttributes.SpecialName;
+ EventAttributes e_attr;
+ if (IsInterface)
+ e_attr = EventAttributes.None;
+ else
+ e_attr = EventAttributes.RTSpecialName |
+ EventAttributes.SpecialName;
;
if (!DoDefine (container, container))
return false;
EventBuilder = new MyEventBuilder (this,
container.TypeBuilder, Name, e_attr, MemberType);
- if (Add.Accessor == null && Remove.Accessor == null) {
+ if (Add.Accessor == null && Remove.Accessor == null &&
+ !IsInterface) {
FieldBuilder = container.TypeBuilder.DefineField (
Name, MemberType,
FieldAttributes.Private | ((ModFlags & Modifiers.STATIC) != 0 ? FieldAttributes.Static : 0));
Attribute.ApplyAttributes (ec, EventBuilder, this, OptAttributes);
}
- Add.Emit (tc);
- Remove.Emit (tc);
+ if (!IsInterface) {
+ Add.Emit (tc);
+ Remove.Emit (tc);
+ }
base.Emit (tc);
}
return container.Name + ".operator " + OperatorType + " (" + FirstArgType + "," +
SecondArgType + ")";
}
+
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ OperatorMethod.ApplyAttributeBuilder (builder, a, cb);
+ }
protected override bool CheckGenericOverride (MethodInfo method, string name)
{
}
#endif
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ throw new NotImplementedException ("Can't apply attributes to constants ???");
+ }
+
/// <summary>
/// Defines the constant in the @parent
/// </summary>
}
/// <summary>
- /// Base representation for members. This is only used to keep track
- /// of Name, Location and Modifier flags.
+ /// Base representation for members. This is used to keep track
+ /// of Name, Location and Modifier flags, and handling Attributes.
/// </summary>
- public abstract class MemberCore {
+ public abstract class MemberCore : Attributable {
/// <summary>
/// Public name
/// </summary>
/// </summary>
public readonly Location Location;
- /// <summary>
- /// Attributes for this type
- /// </summary>
- Attributes attributes;
-
[Flags]
public enum Flags {
Obsolete_Undetected = 1, // Obsolete attribute has not beed detected yet
protected Flags caching_flags;
public MemberCore (MemberName name, Attributes attrs, Location loc)
+ : base (attrs)
{
Name = name.GetName (!(this is GenericMethod) && !(this is Method));
MemberName = name;
Location = loc;
- attributes = attrs;
caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected;
}
return Name;
}
- public Attributes OptAttributes
- {
- get {
- return attributes;
- }
- set {
- attributes = value;
- }
- }
-
/// <summary>
/// Base Emit method. This is also entry point for CLS-Compliant verification.
/// </summary>
return true;
bool error3006 = false;
- foreach (MemberInfo mi in ml) {
+ for (int i = 0; i < ml.Count; ++i) {
+ MemberInfo mi = ml [i];
if (name == mi.Name) {
MethodBase method = mi as MethodBase;
if (method == null || method == methodBuilder || paramTypes == null || paramTypes.Length == 0)
continue;
}
+ for (int ii = 0; ii < ml.Count; ++ii) {
+ mi = ml [ii];
+ if (name == mi.Name)
+ continue;
+ Report.SymbolRelatedToPreviousError (mi);
+ }
+
if (error3006)
Report.Error_T (3006, Location, GetSignatureForError ());
continue;
if (String.Compare (Name, type_name, true) == 0 &&
- AttributeTester.IsClsCompliant (TypeManager.all_imported_types [type_name] as Type))
+ AttributeTester.IsClsCompliant (TypeManager.all_imported_types [type_name] as Type)) {
+ Report.SymbolRelatedToPreviousError ((Type)TypeManager.all_imported_types [type_name]);
return false;
}
}
+ }
// Seek through generated types
foreach (string name in RootContext.Tree.Decls.Keys) {
continue;
DeclSpace found_ds = RootContext.Tree.Decls[name] as DeclSpace;
- if (found_ds.IsClsCompliaceRequired (found_ds.Parent))
+ if (found_ds.IsClsCompliaceRequired (found_ds.Parent)) {
+ Report.SymbolRelatedToPreviousError (found_ds.Location, found_ds.GetSignatureForError ());
return false;
}
}
+ }
return true;
}
protected Hashtable member_hash;
protected Hashtable method_hash;
- Hashtable interface_hash;
-
/// <summary>
/// Create a new MemberCache for the given IMemberContainer `container'.
/// </summary>
// TypeManager.object_type), we deep-copy its MemberCache here.
if (Container.IsInterface) {
MemberCache parent;
- interface_hash = new Hashtable ();
if (Container.Parent != null)
parent = Container.Parent.MemberCache;
/// <summary>
/// Add the contents of `new_hash' to `hash'.
/// </summary>
- void AddHashtable (Hashtable hash, Hashtable new_hash)
+ void AddHashtable (Hashtable hash, MemberCache cache)
{
+ Hashtable new_hash = cache.member_hash;
IDictionaryEnumerator it = new_hash.GetEnumerator ();
while (it.MoveNext ()) {
ArrayList list = (ArrayList) hash [it.Key];
- if (list != null)
- list.AddRange ((ArrayList) it.Value);
- else
- hash [it.Key] = ((ArrayList) it.Value).Clone ();
+ if (list == null)
+ hash [it.Key] = list = new ArrayList ();
+
+ foreach (CacheEntry entry in (ArrayList) it.Value) {
+ if (entry.Container != cache.Container)
+ break;
+ list.Add (entry);
+ }
}
}
foreach (TypeExpr iface in ifaces) {
Type itype = iface.Type;
- if (interface_hash.Contains (itype))
- continue;
-
- interface_hash [itype] = null;
-
IMemberContainer iface_container =
TypeManager.LookupMemberContainer (itype);
MemberCache iface_cache = iface_container.MemberCache;
- AddHashtable (hash, iface_cache.member_hash);
-
- if (iface_cache.interface_hash == null)
- continue;
-
- foreach (Type parent_contains in iface_cache.interface_hash.Keys)
- interface_hash [parent_contains] = null;
+ AddHashtable (hash, iface_cache);
}
return hash;
applicable = (ArrayList) method_hash [name];
else
applicable = (ArrayList) member_hash [name];
-
+
if (applicable == null)
return emptyMemberInfo;
IMemberContainer current = Container;
+
// `applicable' is a list of all members with the given member name `name'
// in the current class and all its parent classes. The list is sorted in
// reverse order due to the way how the cache is initialy created (to speed
Parameters = param_list;\r
}\r
\r
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)\r
+ {\r
+ try {\r
+ ((TypeBuilder) builder).SetCustomAttribute (cb);\r
+ } catch (System.ArgumentException e) {\r
+ Report.Warning (-21, a.Location,\r
+ "The CharSet named property on StructLayout\n"+\r
+ "\tdoes not work correctly on Microsoft.NET\n"+\r
+ "\tYou might want to remove the CharSet declaration\n"+\r
+ "\tor compile using the Mono runtime instead of the\n"+\r
+ "\tMicrosoft .NET runtime\n"+\r
+ "\tThe runtime gave the error: " + e);\r
+ }\r
+ }\r
+ \r
public override TypeBuilder DefineType ()\r
{\r
if (TypeBuilder != null)\r
pb = InvokeBuilder.DefineParameter (i+1, p.Attributes, p.Name);\r
cattr = p.OptAttributes;\r
if (cattr != null)\r
- Attribute.ApplyAttributes (ec, pb, pb, cattr);\r
+ Attribute.ApplyAttributes (ec, pb, p, cattr);\r
\r
if ((p.ModFlags & Parameter.Modifier.ISBYREF) != 0)\r
out_params++;\r
i+1, p.Attributes, p.Name);\r
cattr = p.OptAttributes;\r
if (cattr != null)\r
- Attribute.ApplyAttributes (ec, pb, pb, cattr);\r
+ Attribute.ApplyAttributes (ec, pb, p, cattr);\r
}\r
\r
InvokeBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);\r
pb = BeginInvokeBuilder.DefineParameter (i+1, p.Attributes, p.Name);\r
cattr = p.OptAttributes;\r
if (cattr != null)\r
- Attribute.ApplyAttributes (ec, pb, pb, cattr);\r
+ Attribute.ApplyAttributes (ec, pb, p, cattr);\r
}\r
}\r
if (Parameters.ArrayParameter != null){\r
pb = BeginInvokeBuilder.DefineParameter (i+1, p.Attributes, p.Name);\r
cattr = p.OptAttributes;\r
if (cattr != null)\r
- Attribute.ApplyAttributes (ec, pb, pb, cattr);\r
+ Attribute.ApplyAttributes (ec, pb, p, cattr);\r
i++;\r
}\r
\r
else if (t == TypeManager.bool_type)
return new BoolConstant ((bool) v);
else if (TypeManager.IsEnumType (t)){
- Constant e = Constantify (v, TypeManager.TypeToCoreType (v.GetType ()));
+ Type real_type = TypeManager.TypeToCoreType (v.GetType ());
+ if (real_type == t)
+ real_type = real_type.UnderlyingSystemType;
+
+ Constant e = Constantify (v, real_type);
return new EnumConstant (e, t);
} else
}
if ((qualifier_type != null) && (qualifier_type != ec.ContainerType) &&
- ec.ContainerType.IsSubclassOf (qualifier_type)) {
+ !qualifier_type.IsSubclassOf (ec.ContainerType)) {
// Although a derived class can access protected members of
// its base class it cannot do so through an instance of the
// base class (CS1540). If the qualifier_type is a parent of the
IMemoryLocation ml = (IMemoryLocation) instance_expr;
ml.AddressOf (ec, AddressOp.LoadStore);
- } else
+ } else {
instance_expr.Emit (ec);
+
+ if (instance_expr.Type.IsValueType) {
+ LocalBuilder local = ig.DeclareLocal (instance_expr.Type);
+ ig.Emit(OpCodes.Stloc, local);
+ ig.Emit(OpCodes.Ldloca, local);
+ ig.Emit(OpCodes.Ldfld, FieldInfo);
+ LocalBuilder local2 = ig.DeclareLocal(type);
+ ig.Emit(OpCodes.Stloc, local2);
+ ig.Emit(OpCodes.Ldloca, local2);
+ return;
+ }
+ }
ig.Emit (OpCodes.Ldflda, FieldInfo);
}
}
return AdditionResult.Success;
}
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ ((TypeBuilder) builder).SetCustomAttribute (cb);
+ }
+
//
// This is used by corlib compilation: we map from our
// type to a type that is consumable by the DefineField
string enumerator_name = ordered_enums [ii] as string;
if (String.Compare (checked_name, enumerator_name, true) == 0) {
+ Report.SymbolRelatedToPreviousError ((Location)member_to_location [enumerator_name], enumerator_name);
Report.Error_T (3005, (Location)member_to_location [checked_name], GetEnumeratorName (checked_name));
- Report.LocationOfPreviousError ((Location)member_to_location [enumerator_name]);
break;
}
}
return ResolveOperator (ec);
}
+ public override Expression DoResolveLValue (EmitContext ec, Expression right)
+ {
+ if (Oper == Operator.Indirection)
+ return base.DoResolveLValue (ec, right);
+
+ Error (131, "The left-hand side of an assignment must be a " +
+ "variable, property or indexer");
+ return null;
+ }
+
public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
ig.MarkLabel (end);
return;
}
-
+
left.Emit (ec);
right.Emit (ec);
}
Expression op_true, op_false, op;
+ LocalTemporary left_temp;
public override Expression DoResolve (EmitContext ec)
{
return null;
}
+ left_temp = new LocalTemporary (ec, type);
+
ArrayList arguments = new ArrayList ();
- arguments.Add (new Argument (left, Argument.AType.Expression));
+ arguments.Add (new Argument (left_temp, Argument.AType.Expression));
arguments.Add (new Argument (right, Argument.AType.Expression));
method = Invocation.OverloadResolve (
ec, (MethodGroupExpr) operator_group, arguments, false, loc)
op = new StaticCallExpr (method, arguments, loc);
- op_true = GetOperatorTrue (ec, left, loc);
- op_false = GetOperatorFalse (ec, left, loc);
+ op_true = GetOperatorTrue (ec, left_temp, loc);
+ op_false = GetOperatorFalse (ec, left_temp, loc);
if ((op_true == null) || (op_false == null)) {
Error218 ();
return null;
ig.Emit (OpCodes.Nop);
- (is_and ? op_false : op_true).EmitBranchable (ec, false_target, false);
left.Emit (ec);
+ left_temp.Store (ec);
+
+ (is_and ? op_false : op_true).EmitBranchable (ec, false_target, false);
+ left_temp.Emit (ec);
ig.Emit (OpCodes.Br, end_target);
ig.MarkLabel (false_target);
op.Emit (ec);
if (ltype == null)
return null;
+ if ((ltype == TypeManager.void_type) && (dim != "*")) {
+ Report.Error (1547, Location,
+ "Keyword 'void' cannot be used in this context");
+ return null;
+ }
+
int pos = 0;
while ((pos < dim.Length) && (dim [pos] == '[')) {
pos++;
throw new Exception ();
}
}
+
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ // FIXME
+ }
}
public class DefaultValueExpression : Expression
namespace Mono.CSharp {
+ /// <summary>
+ /// Base class for parameters of a method. Can also be
+ /// used to directly represent the return type of a method
+ /// </summary>
+ public class ParameterBase : Attributable {
+ public ParameterBase (Attributes attrs)
+ : base (attrs)
+ {
+ }
+
+ public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+ {
+ ParameterBuilder pb = builder as ParameterBuilder;
+
+ if (a.Type == TypeManager.marshal_as_attr_type) {
+ UnmanagedMarshal marshal = a.GetMarshal ();
+ if (marshal == null)
+ Report.Warning (-24, a.Location,
+ "The Microsoft Runtime cannot set this marshal info. " +
+ "Please use the Mono runtime instead.");
+ else
+ pb.SetMarshal (marshal);
+ }
+ else {
+ try {
+ pb.SetCustomAttribute (cb);
+ } catch (System.ArgumentException) {
+ Report.Warning (-24, a.Location,
+ "The Microsoft Runtime cannot set attributes \n" +
+ "on the return type of a method. Please use the \n" +
+ "Mono runtime instead.");
+ }
+ }
+ }
+ }
/// <summary>
/// Represents a single method parameter
/// </summary>
- public class Parameter {
+ public class Parameter : ParameterBase {
[Flags]
public enum Modifier : byte {
NONE = 0,
public readonly Expression TypeName;
public readonly Modifier ModFlags;
- public Attributes OptAttributes;
public readonly string Name;
GenericConstraints constraints;
Type parameter_type;
public Parameter (Expression type, string name, Modifier mod, Attributes attrs)
+ : base (attrs)
{
Name = name;
ModFlags = mod;
TypeName = type;
- OptAttributes = attrs;
}
// <summary>
using System;
using System.Text;
using System.Collections;
+using System.Collections.Specialized;
using System.Diagnostics;
using System.Reflection;
// Keeps track of the warnings that we are ignoring
//
static Hashtable warning_ignore_table;
+
+ /// <summary>
+ /// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
+ /// </summary>
+ static StringCollection related_symbols = new StringCollection ();
struct WarningData {
public WarningData (int level, string text) {
return sb.ToString ();
}
- static public void LocationOfPreviousError (Location loc) {
+ [Obsolete ("Use SymbolRelatedToPreviousError for better error description")]
+ static public void LocationOfPreviousError (Location loc)
+ {
Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
+ }
+
+ /// <summary>
+ /// In most error cases is very useful to have information about symbol that caused the error.
+ /// Call this method before you call Report.Error when it makes sense.
+ /// </summary>
+ static public void SymbolRelatedToPreviousError (Location loc, string symbol)
+ {
+ SymbolRelatedToPreviousError (String.Format ("{0}({1})", loc.Name, loc.Row), symbol);
+ }
+
+ static public void SymbolRelatedToPreviousError (MemberInfo mi)
+ {
+ DeclSpace temp_ds = TypeManager.LookupDeclSpace (mi.DeclaringType);
+ if (temp_ds == null) {
+ SymbolRelatedToPreviousError (mi.DeclaringType.Assembly.Location, TypeManager.GetFullNameSignature (mi));
+ } else {
+ string name = String.Concat (temp_ds.Name, ".", mi.Name);
+ MemberCore mc = temp_ds.GetDefinition (name) as MemberCore;
+ SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
+ }
+ }
+
+ static public void SymbolRelatedToPreviousError (Type type)
+ {
+ SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
+ }
+
+ static void SymbolRelatedToPreviousError (string loc, string symbol)
+ {
+ related_symbols.Add (String.Format ("{0}: ('{1}' name of symbol related to previous error)", loc, symbol));
}
static public void RealError (string msg)
Errors++;
Console.WriteLine (msg);
+ foreach (string s in related_symbols)
+ Console.WriteLine (s);
+ related_symbols.Clear ();
+
if (Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
static public void Warning (int code, Location loc, params object[] args)
{
WarningData warning = GetWarningMsg (code);
- if (!warning.IsEnabled ())
- return;
+ if (warning.IsEnabled ())
+ Warning (code, loc, warning.Format (args));
- Warning (code, loc, warning.Format (args));
+ related_symbols.Clear ();
}
/// <summary>
code = 8000-code;
if (warning_ignore_table != null){
- if (warning_ignore_table.Contains (code))
+ if (warning_ignore_table.Contains (code)) {
+ related_symbols.Clear ();
return;
+ }
}
if (WarningsAreErrors)
// "{0}({1}) warning CS{2}: {3}",
l.Name, row, code, text));
Warnings++;
+
+ foreach (string s in related_symbols)
+ Console.WriteLine (s);
+ related_symbols.Clear ();
+
Check (code);
if (Stacktrace)
if (VariableType == null)
VariableType = decl.ResolveType (Type, false, Location);
+ if (VariableType == TypeManager.void_type) {
+ Report.Error (1547, Location,
+ "Keyword 'void' cannot be used in this context");
+ return false;
+ }
+
if (VariableType == null)
return false;
converted_vars [i].Emit (ec);
ig.Emit (OpCodes.Callvirt, TypeManager.void_dispose_void);
} else {
- Expression ml = Expression.MemberLookup(ec, typeof(IDisposable), var.Type, "Dispose", Mono.CSharp.Location.Null);
+ Expression ml = Expression.MemberLookup(ec, TypeManager.idisposable_type, var.Type, "Dispose", Mono.CSharp.Location.Null);
if (!(ml is MethodGroupExpr)) {
var.Emit (ec);
if (expr is IMemoryLocation){
IMemoryLocation ml = (IMemoryLocation) expr;
- ml.AddressOf (ec, AddressOp.Load);
+ Expression ml1 = Expression.MemberLookup(ec, TypeManager.ienumerator_type, expr.Type, "GetEnumerator", Mono.CSharp.Location.Null);
+
+ if (!(ml1 is MethodGroupExpr)) {
+ expr.Emit(ec);
+ ec.ig.Emit(OpCodes.Box, expr.Type);
+ } else {
+ ml.AddressOf (ec, AddressOp.Load);
+ }
} else
throw new Exception ("Expr " + expr + " of type " + expr.Type +
" does not implement IMemoryLocation");
- ig.Emit (OpCodes.Call, hm.get_enumerator);
+ ig.Emit (OpCodes.Callvirt, hm.get_enumerator);
} else {
expr.Emit (ec);
ig.Emit (OpCodes.Callvirt, hm.get_enumerator);
public void RecordDecl (string name, DeclSpace ds)
{
if (decls.Contains (name)){
+ DeclSpace other = (DeclSpace) decls [name];
+ Report.SymbolRelatedToPreviousError (other.Location, other.GetSignatureForError ());
+
Report.Error (
101, ds.Location,
"There is already a definition for `" + name + "'");
- DeclSpace other = (DeclSpace) decls [name];
- Report.LocationOfPreviousError (other.Location);
return;
}
return true;
seen.Add (tc, null);
- //
- // `hash' contains all types in the current path.
- //
- hash.Add (tc, null);
-
if (tc.Fields == null)
return true;
return false;
}
- if (!CheckStructCycles (ftc, seen, hash))
+ //
+ // `hash' contains all types in the current path.
+ //
+ hash.Add (tc, null);
+
+ bool ok = CheckStructCycles (ftc, seen, hash);
+
+ hash.Remove (tc);
+
+ if (!ok)
return false;
}
// it cannot do so through an instance of the base class (CS1540).
if (!mb.IsStatic && (closure_invocation_type != closure_qualifier_type) &&
(closure_qualifier_type != null) &&
- closure_invocation_type.IsSubclassOf (closure_qualifier_type) &&
+ ! closure_qualifier_type.IsSubclassOf (closure_invocation_type) &&
!TypeManager.IsNestedChildOf (closure_invocation_type, closure_qualifier_type))
return false;