//\r
\r
using System;\r
+using System.Diagnostics;\r
using System.Collections;\r
using System.Reflection;\r
using System.Reflection.Emit;\r
return null;\r
\r
e = a.Expr;\r
+\r
if (e is Constant) {\r
pos_values [i] = ((Constant) e).GetValue ();\r
} else if (e is TypeOf) {\r
this.Inherited = (bool) o;\r
}\r
\r
- } else { \r
+ } else if (e is TypeOf) {\r
+ prop_values.Add (((TypeOf) e).TypeArg);\r
+ } else {\r
Error_AttributeArgumentNotValid ();\r
return null;\r
}\r
object value = ((Constant) e).GetValue ();\r
\r
field_values.Add (value);\r
- } else { \r
+ } else if (e is TypeOf) {\r
+ field_values.Add (((TypeOf) e).TypeArg);\r
+ } else {\r
Error_AttributeArgumentNotValid ();\r
return null;\r
}\r
Error_AttributeConstructorMismatch (Location);\r
return null;\r
}\r
+\r
+ //\r
+ // Now we perform some checks on the positional args as they\r
+ // cannot be null for a constructor which expects a parameter\r
+ // of type object\r
+ //\r
+\r
+ ParameterData pd = Invocation.GetParameterData (constructor);\r
+\r
+ for (int j = 0; j < pos_arg_count; ++j) {\r
+ Argument a = (Argument) pos_args [j];\r
+ \r
+ if (a.Expr is NullLiteral && pd.ParameterType (j) == TypeManager.object_type) {\r
+ Error_AttributeArgumentNotValid ();\r
+ return null;\r
+ }\r
+ }\r
\r
PropertyInfo [] prop_info_arr = new PropertyInfo [prop_infos.Count];\r
FieldInfo [] field_info_arr = new FieldInfo [field_infos.Count];\r
(ConstructorInfo) constructor, pos_values,\r
prop_info_arr, prop_values_arr,\r
field_info_arr, field_values_arr); \r
+\r
+ } catch (NullReferenceException) {\r
+ // \r
+ // Don't know what to do here\r
+ //\r
+ Report.Warning (\r
+ -100, Location, "NullReferenceException while trying to create attribute. Something's wrong!");\r
} catch {\r
//\r
// Sample:\r
}\r
\r
foreach (System.Attribute tmp in attrs)\r
- if (tmp is AttributeUsageAttribute) \r
+ if (tmp is AttributeUsageAttribute) {\r
targets = ((AttributeUsageAttribute) tmp).ValidOn;\r
+ break;\r
+ }\r
} else\r
targets = a.Targets;\r
\r
}\r
return null;\r
}\r
- \r
+\r
+ //\r
+ // This pulls the condition name out of a Conditional attribute\r
+ //\r
+ public string Conditional_GetConditionName ()\r
+ {\r
+ //\r
+ // So we have a Conditional, pull the data out.\r
+ //\r
+ if (Arguments == null || Arguments [0] == null){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+\r
+ ArrayList pos_args = (ArrayList) Arguments [0];\r
+ if (pos_args.Count != 1){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+\r
+ Argument arg = (Argument) pos_args [0]; \r
+ if (!(arg.Expr is StringConstant)){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+\r
+ return ((StringConstant) arg.Expr).Value;\r
+ }\r
+\r
+ //\r
+ // This pulls the obsolete message and error flag out of an Obsolete attribute\r
+ //\r
+ public string Obsolete_GetObsoleteMessage (out bool is_error)\r
+ {\r
+ is_error = false;\r
+ //\r
+ // So we have an Obsolete, pull the data out.\r
+ //\r
+ if (Arguments == null || Arguments [0] == null)\r
+ return "";\r
+\r
+ ArrayList pos_args = (ArrayList) Arguments [0];\r
+ if (pos_args.Count == 0)\r
+ return "";\r
+ else if (pos_args.Count > 2){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+\r
+ Argument arg = (Argument) pos_args [0]; \r
+ if (!(arg.Expr is StringConstant)){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+\r
+ if (pos_args.Count == 2){\r
+ Argument arg2 = (Argument) pos_args [1];\r
+ if (!(arg2.Expr is BoolConstant)){\r
+ Error_AttributeConstructorMismatch (Location);\r
+ return null;\r
+ }\r
+ is_error = ((BoolConstant) arg2.Expr).Value;\r
+ }\r
+\r
+ return ((StringConstant) arg.Expr).Value;\r
+ }\r
+\r
//\r
// Applies the attributes to the `builder'.\r
//\r
"\tMicrosoft .NET runtime");\r
}\r
\r
+ } else if (kind is Interface) {\r
+ Interface iface = (Interface) kind;\r
+\r
+ if ((a.Type == TypeManager.default_member_type) &&\r
+ (iface.InterfaceIndexers != 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 (!CheckAttribute (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
}\r
}\r
\r
+ if (entry_point == null)\r
+ entry_point = name;\r
+ \r
MethodBuilder mb = builder.DefinePInvokeMethod (\r
- name, dll_name, flags | MethodAttributes.HideBySig,\r
+ name, dll_name, entry_point, flags | MethodAttributes.HideBySig,\r
CallingConventions.Standard,\r
ret_type,\r
param_types,\r