2 // interface.cs: Interface handler
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
11 using System.Collections;
14 using System.Reflection;
15 using System.Reflection.Emit;
17 namespace Mono.CSharp {
22 public class Interface : DeclSpace, IMemberContainer {
23 const MethodAttributes interface_method_attributes =
24 MethodAttributes.Public |
25 MethodAttributes.Abstract |
26 MethodAttributes.HideBySig |
27 MethodAttributes.NewSlot |
28 MethodAttributes.Virtual;
30 const MethodAttributes property_attributes =
31 MethodAttributes.Public |
32 MethodAttributes.Abstract |
33 MethodAttributes.HideBySig |
34 MethodAttributes.NewSlot |
35 MethodAttributes.SpecialName |
36 MethodAttributes.Virtual;
41 ArrayList defined_method;
42 ArrayList defined_indexer;
43 ArrayList defined_events;
44 ArrayList defined_properties;
46 ArrayList method_builders;
47 ArrayList property_builders;
48 ArrayList event_builders;
51 public string IndexerName;
53 IMemberContainer parent_container;
54 MemberCache member_cache;
61 // These will happen after the semantic analysis
63 // Hashtable defined_indexers;
64 // Hashtable defined_methods;
67 /// Modifiers allowed in a class declaration
69 public const int AllowedModifiers =
77 public Interface (NamespaceEntry ns, TypeContainer parent, string name, int mod,
78 Attributes attrs, Location l)
79 : base (ns, parent, name, attrs, l)
81 ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE, l);
83 method_builders = new ArrayList ();
84 property_builders = new ArrayList ();
85 event_builders = new ArrayList ();
88 public AdditionResult AddMethod (InterfaceMethod imethod)
90 string name = imethod.Name;
91 Object value = defined_names [name];
94 if (!(value is InterfaceMethod))
95 return AdditionResult.NameExists;
98 if (defined_method == null)
99 defined_method = new ArrayList ();
101 defined_method.Add (imethod);
103 DefineName (name, imethod);
105 return AdditionResult.Success;
108 public AdditionResult AddProperty (InterfaceProperty iprop)
111 string name = iprop.Name;
113 if ((res = IsValid (name, name)) != AdditionResult.Success)
116 DefineName (name, iprop);
118 if (defined_properties == null)
119 defined_properties = new ArrayList ();
121 defined_properties.Add (iprop);
122 return AdditionResult.Success;
125 public AdditionResult AddEvent (InterfaceEvent ievent)
127 string name = ievent.Name;
130 if ((res = IsValid (name, name)) != AdditionResult.Success)
133 DefineName (name, ievent);
135 if (defined_events == null)
136 defined_events = new ArrayList ();
138 defined_events.Add (ievent);
139 return AdditionResult.Success;
142 public bool AddIndexer (InterfaceIndexer iindexer)
144 if (defined_indexer == null)
145 defined_indexer = new ArrayList ();
147 defined_indexer.Add (iindexer);
151 public ArrayList InterfaceMethods {
153 return defined_method;
157 public ArrayList InterfaceProperties {
159 return defined_properties;
163 public ArrayList InterfaceEvents {
165 return defined_events;
169 public ArrayList InterfaceIndexers {
171 return defined_indexer;
175 public ArrayList Bases {
185 public virtual TypeAttributes InterfaceAttr {
187 TypeAttributes x = TypeAttributes.Interface | TypeAttributes.Abstract;
189 if (IsTopLevel == false) {
191 if ((ModFlags & Modifiers.PROTECTED) != 0
192 && (ModFlags & Modifiers.INTERNAL) != 0)
193 x |= TypeAttributes.NestedFamORAssem;
194 else if ((ModFlags & Modifiers.PROTECTED) != 0)
195 x |= TypeAttributes.NestedFamily;
196 else if ((ModFlags & Modifiers.INTERNAL) != 0)
197 x |= TypeAttributes.NestedAssembly;
198 else if ((ModFlags & Modifiers.PUBLIC) != 0)
199 x |= TypeAttributes.NestedPublic;
201 x |= TypeAttributes.NestedPrivate;
203 if ((ModFlags & Modifiers.PUBLIC) != 0)
204 x |= TypeAttributes.Public;
205 else if ((ModFlags & Modifiers.PRIVATE) != 0)
206 x |= TypeAttributes.NotPublic;
209 if ((ModFlags & Modifiers.ABSTRACT) != 0)
210 x |= TypeAttributes.Abstract;
212 if ((ModFlags & Modifiers.SEALED) != 0)
213 x |= TypeAttributes.Sealed;
219 void Error111 (InterfaceMemberBase ib)
223 "Interface `" + Name + "' already contains a definition with the " +
224 "same return value and parameter types for member `" + ib.Name + "'");
227 bool RegisterMethod (MethodBase mb, InternalParameters ip, Type [] types)
229 if (!TypeManager.RegisterMethod (mb, ip, types))
232 method_builders.Add (mb);
237 // This might trigger a definition of the methods. This happens only
238 // with Attributes, as Attribute classes are processed before interfaces.
239 // Ideally, we should make everything just define recursively in terms
240 // of its dependencies.
242 public MethodInfo [] GetMethods (TypeContainer container)
246 if (!members_defined){
247 if (DefineMembers (container))
248 n = method_builders.Count;
250 n = method_builders.Count;
252 MethodInfo [] mi = new MethodInfo [n];
254 method_builders.CopyTo (mi, 0);
259 // Hack around System.Reflection as found everywhere else
260 public override MemberList FindMembers (MemberTypes mt, BindingFlags bf,
261 MemberFilter filter, object criteria)
263 ArrayList members = new ArrayList ();
265 if ((mt & MemberTypes.Method) != 0) {
266 foreach (MethodBuilder mb in method_builders)
267 if (filter (mb, criteria))
271 if ((mt & MemberTypes.Property) != 0) {
272 foreach (PropertyBuilder pb in property_builders)
273 if (filter (pb, criteria))
277 if ((mt & MemberTypes.Event) != 0) {
278 foreach (MyEventBuilder eb in event_builders)
279 if (filter (eb, criteria))
283 if (((bf & BindingFlags.DeclaredOnly) == 0) && (baseTypes != null)) {
284 foreach (Type baseType in baseTypes) {
285 members.AddRange (TypeContainer.FindMembers (baseType, mt, bf, filter, criteria));
289 return new MemberList (members);
292 public override MemberCache MemberCache {
299 // Populates the methods in the interface
301 void PopulateMethod (TypeContainer parent, DeclSpace decl_space, InterfaceMethod im)
303 if (im.ReturnType == null)
306 Type return_type = im.ReturnType.Type;
307 if (return_type == null)
308 return_type = this.ResolveType (im.ReturnType, false, im.Location);
310 Type [] arg_types = im.ParameterTypes (this);
313 if (return_type == null)
316 if (return_type.IsPointer && !UnsafeOK (this))
319 if (arg_types == null)
322 foreach (Type t in arg_types){
327 if (t.IsPointer && !UnsafeOK (this))
334 mb = TypeBuilder.DefineMethod (
335 im.Name, interface_method_attributes,
336 return_type, arg_types);
338 InternalParameters ip = new InternalParameters (arg_types, im.Parameters);
340 if (!RegisterMethod (mb, ip, arg_types)) {
346 // Labelling of parameters is taken care of
347 // during the Emit phase via
348 // MethodCore.LabelParameters method so I am
349 // removing the old code here.
357 // Populates the properties in the interface
359 void PopulateProperty (TypeContainer parent, DeclSpace decl_space, InterfaceProperty ip)
363 ip.ReturnType = this.ResolveTypeExpr (ip.ReturnType, false, ip.Location);
364 if (ip.ReturnType == null)
367 Type prop_type = ip.ReturnType.Type;
368 Type [] setter_args = new Type [1];
370 if (prop_type == null)
373 if (prop_type.IsPointer && !UnsafeOK (this))
376 setter_args [0] = prop_type;
379 // FIXME: properties are missing the following
380 // flags: hidebysig newslot specialname
382 pb = TypeBuilder.DefineProperty (
383 ip.Name, PropertyAttributes.None,
386 MethodBuilder get = null, set = null;
389 get = TypeBuilder.DefineMethod (
390 "get_" + ip.Name, property_attributes ,
394 // HACK because System.Reflection.Emit is lame
396 Type [] null_types = null;
397 InternalParameters inp = new InternalParameters
398 (null_types, Parameters.EmptyReadOnlyParameters);
400 if (!RegisterMethod (get, inp, null)) {
405 pb.SetGetMethod (get);
409 setter_args [0] = prop_type;
411 set = TypeBuilder.DefineMethod (
412 "set_" + ip.Name, property_attributes,
413 TypeManager.void_type, setter_args);
415 set.DefineParameter (1, ParameterAttributes.None, "value");
416 pb.SetSetMethod (set);
419 // HACK because System.Reflection.Emit is lame
421 Parameter [] parms = new Parameter [1];
422 parms [0] = new Parameter (ip.ReturnType, "value", Parameter.Modifier.NONE, null);
423 InternalParameters ipp = new InternalParameters (
424 this, new Parameters (parms, null, Location.Null));
426 if (!RegisterMethod (set, ipp, setter_args)) {
432 TypeManager.RegisterProperty (pb, get, set);
433 property_builders.Add (pb);
434 ip.SetBuilders (pb, get, set);
438 // Populates the events in the interface
440 void PopulateEvent (TypeContainer parent, DeclSpace decl_space, InterfaceEvent ie)
443 // FIXME: We need to do this after delegates have been
444 // declared or we declare them recursively.
447 MethodBuilder add = null, remove = null;
448 ie.ReturnType = this.ResolveTypeExpr (ie.ReturnType, false, ie.Location);
449 if (ie.ReturnType == null)
452 Type event_type = ie.ReturnType.Type;
454 if (event_type == null)
457 if (event_type.IsPointer && !UnsafeOK (this))
460 Type [] parameters = new Type [1];
461 parameters [0] = event_type;
463 eb = new MyEventBuilder (null, TypeBuilder, ie.Name,
464 EventAttributes.None, event_type);
467 // Now define the accessors
469 string add_name = "add_" + ie.Name;
471 add = TypeBuilder.DefineMethod (
472 add_name, property_attributes, null, parameters);
473 add.DefineParameter (1, ParameterAttributes.None, "value");
474 eb.SetAddOnMethod (add);
476 string remove_name = "remove_" + ie.Name;
477 remove = TypeBuilder.DefineMethod (
478 remove_name, property_attributes, null, parameters);
479 remove.DefineParameter (1, ParameterAttributes.None, "value");
480 eb.SetRemoveOnMethod (remove);
482 Parameter [] parms = new Parameter [1];
483 parms [0] = new Parameter (ie.ReturnType, "value", Parameter.Modifier.NONE, null);
484 InternalParameters ip = new InternalParameters (
485 this, new Parameters (parms, null, Location.Null));
487 if (!RegisterMethod (add, ip, parameters)) {
492 if (!RegisterMethod (remove, ip, parameters)) {
497 TypeManager.RegisterEvent (eb, add, remove);
498 event_builders.Add (eb);
504 // Populates the indexers in the interface
506 void PopulateIndexer (TypeContainer parent, DeclSpace decl_space, InterfaceIndexer ii)
509 ii.ReturnType = this.ResolveTypeExpr (ii.ReturnType, false, ii.Location);
510 if (ii ==null || ii.ReturnType == null)
513 Type prop_type = ii.ReturnType.Type;
514 Type [] arg_types = ii.ParameterTypes (this);
515 Type [] value_arg_types;
517 if (prop_type == null)
520 if (prop_type.IsPointer && !UnsafeOK (this))
524 // Sets up the extra invisible `value' argument for setters.
526 if (arg_types != null){
527 int count = arg_types.Length;
528 value_arg_types = new Type [count + 1];
530 arg_types.CopyTo (value_arg_types, 0);
531 value_arg_types [count] = prop_type;
533 foreach (Type t in arg_types){
534 if (t.IsPointer && !UnsafeOK (this))
538 value_arg_types = new Type [1];
540 value_arg_types [1] = prop_type;
543 EmitContext ec = new EmitContext (parent, decl_space, Location, null,
544 null, ModFlags, false);
546 IndexerName = Attribute.ScanForIndexerName (ec, ii.OptAttributes);
547 if (IndexerName == null)
548 IndexerName = "Item";
550 pb = TypeBuilder.DefineProperty (
551 IndexerName, PropertyAttributes.None,
552 prop_type, arg_types);
554 MethodBuilder set_item = null, get_item = null;
556 Parameter [] p = ii.Parameters.FixedParameters;
558 get_item = TypeBuilder.DefineMethod (
559 "get_" + IndexerName, property_attributes,
560 prop_type, arg_types);
561 pb.SetGetMethod (get_item);
563 // HACK because System.Reflection.Emit is lame
565 InternalParameters ip = new InternalParameters (
566 arg_types, ii.Parameters);
568 if (!RegisterMethod (get_item, ip, arg_types)) {
574 for (int i = 0; i < p.Length; i++)
575 get_item.DefineParameter (
577 p [i].Attributes, p [i].Name);
582 Parameter [] p = ii.Parameters.FixedParameters;
586 pv = new Parameter [p.Length + 1];
588 pv [p.Length] = new Parameter (ii.ReturnType, "value", Parameter.Modifier.NONE, null);
589 Parameters value_params = new Parameters (pv, null, Location.Null);
590 value_params.GetParameterInfo (decl_space);
592 set_item = TypeBuilder.DefineMethod (
593 "set_" + IndexerName, property_attributes,
594 TypeManager.void_type, value_arg_types);
595 pb.SetSetMethod (set_item);
597 // HACK because System.Reflection.Emit is lame
599 InternalParameters ip = new InternalParameters (
600 value_arg_types, value_params);
601 if (!RegisterMethod (set_item, ip, value_arg_types)) {
607 for (; i < p.Length; i++)
608 set_item.DefineParameter (
610 p [i].Attributes, p [i].Name);
613 set_item.DefineParameter (i + 1, ParameterAttributes.None, "value");
616 property_builders.Add (pb);
618 ii.SetBuilders (pb, get_item, set_item);
622 /// Performs the semantic analysis for all the interface members
623 /// that were declared
625 bool SemanticAnalysis ()
627 Hashtable methods = new Hashtable ();
630 if (defined_method != null){
631 foreach (InterfaceMethod im in defined_method){
632 string sig = im.GetSignature (this);
635 // If there was an undefined Type on the signatures
640 if (methods [sig] != null){
648 // FIXME: Here I should check i
653 TypeExpr GetInterfaceTypeByName (Expression name)
655 TypeExpr resolved = ResolveTypeExpr (name, false, Location);
656 if (resolved == null)
659 if (resolved.IsInterface)
664 if (resolved.IsValueType)
665 cause = "is a struct";
666 else if (resolved.IsClass)
667 cause = "is a class";
669 cause = "Should not happen.";
671 Report.Error (527, Location, "`"+resolved.Name+"' " + cause +
672 ", need an interface instead");
678 // Returns the list of interfaces that this interface implements
679 // Or null if it does not implement any interface.
681 // Sets the error boolean accoringly.
683 TypeExpr [] GetInterfaceBases (out bool error)
692 tbases = new TypeExpr [Bases.Count];
695 foreach (Expression name in Bases){
698 t = GetInterfaceTypeByName (name);
704 if (!t.AsAccessible (Parent, ModFlags))
705 Report.Error (61, Location,
706 "Inconsistent accessibility: base interface `" +
707 t.Name + "' is less accessible than interface `" +
713 return TypeManager.ExpandInterfaces (tbases);
718 // Defines the Interface in the appropriate ModuleBuilder or TypeBuilder
722 // Rework the way we recurse, because for recursive
723 // definitions of interfaces (A:B and B:A) we report the
724 // error twice, rather than once.
726 public override TypeBuilder DefineType ()
731 if (TypeBuilder != null)
739 ec = new EmitContext (this, this, Location, null, null,
742 ifaces = GetInterfaceBases (out error);
748 foreach (TypeParameter type_param in TypeParameters)
749 if (!type_param.Resolve (this)) {
756 if (TypeManager.NamespaceClash (Name, Location))
759 ModuleBuilder builder = CodeGen.Module.Builder;
761 TypeBuilder = builder.DefineType (
764 (Type)null, // Parent Type
766 RootContext.RegisterOrder (this);
768 TypeBuilder builder = Parent.TypeBuilder;
770 TypeBuilder = builder.DefineNestedType (
773 (Type) null, //parent type
776 TypeContainer tc = TypeManager.LookupTypeContainer (builder);
777 tc.RegisterOrder (this);
781 CurrentType = new ConstructedType (
782 Name, TypeParameters, Location);
784 foreach (TypeParameter type_param in TypeParameters)
785 type_param.Define (TypeBuilder);
787 foreach (TypeParameter type_param in TypeParameters)
788 type_param.DefineType (ec, TypeBuilder);
791 if (ifaces != null) {
792 baseTypes = new Type[ifaces.Length];
793 for (int i = 0; i < ifaces.Length; ++i) {
794 Type itype = ifaces [i].ResolveType (ec);
795 TypeBuilder.AddInterfaceImplementation (itype);
796 baseTypes [i] = itype;
800 TypeManager.AddUserInterface (Name, TypeBuilder, this, ifaces);
807 // Defines the indexers, and also verifies that the IndexerNameAttribute in the
808 // interface is consistent. Either it is `Item' or it is the name defined by all the
809 // indexers with the `IndexerName' attribute.
811 // Turns out that the IndexerNameAttribute is applied to each indexer,
812 // but it is never emitted, instead a DefaultName attribute is attached
815 void DefineIndexers (TypeContainer parent)
817 string interface_indexer_name = null;
819 foreach (InterfaceIndexer ii in defined_indexer){
821 PopulateIndexer (parent, this, ii);
823 if (interface_indexer_name == null){
824 interface_indexer_name = IndexerName;
828 if (IndexerName == interface_indexer_name)
832 668, "Two indexers have different names, " +
833 " you should use the same name for all your indexers");
835 if (interface_indexer_name == null)
836 interface_indexer_name = "Item";
837 IndexerName = interface_indexer_name;
841 /// Performs semantic analysis, and then generates the IL interfaces
843 public override bool DefineMembers (TypeContainer parent)
848 if (!SemanticAnalysis ())
852 if (defined_method != null){
853 foreach (InterfaceMethod im in defined_method)
854 PopulateMethod (parent, this, im);
857 if (defined_properties != null){
858 foreach (InterfaceProperty ip in defined_properties)
859 PopulateProperty (parent, this, ip);
862 if (defined_events != null)
863 foreach (InterfaceEvent ie in defined_events)
864 PopulateEvent (parent, this, ie);
866 if (defined_indexer != null) {
867 DefineIndexers (parent);
869 CustomAttributeBuilder cb = EmitDefaultMemberAttr (
870 parent, IndexerName, ModFlags, Location);
872 TypeBuilder.SetCustomAttribute (cb);
875 if (CurrentType != null) {
876 GenericType = CurrentType.ResolveType (ec);
878 ec.ContainerType = GenericType;
882 if (TypeBuilder.BaseType != null)
883 parent_container = TypeManager.LookupMemberContainer (TypeBuilder.BaseType);
885 member_cache = new MemberCache (this);
887 members_defined = true;
893 // In the case of Interfaces, there is nothing to do here
895 public override bool Define (TypeContainer parent)
901 /// Applies all the attributes.
903 public void Emit (TypeContainer tc) {
904 if (OptAttributes != null) {
905 EmitContext ec = new EmitContext (tc, this, Location, null, null, ModFlags, false);
906 Attribute.ApplyAttributes (ec, TypeBuilder, this, OptAttributes);
909 EmitSubType (tc, defined_method);
910 EmitSubType (tc, defined_properties);
911 EmitSubType (tc, defined_indexer);
912 EmitSubType (tc, defined_events);
915 void EmitSubType (TypeContainer tc, ArrayList subType) {
919 foreach (InterfaceMemberBase imb in subType) {
920 //TODO: set it somewhere earlier
921 imb.ModFlags = ModFlags;
926 public static CustomAttributeBuilder EmitDefaultMemberAttr (TypeContainer parent,
931 EmitContext ec = new EmitContext (parent, loc, null, null, flags);
933 Expression ml = Expression.MemberLookup (ec, TypeManager.default_member_type,
934 ".ctor", MemberTypes.Constructor,
935 BindingFlags.Public | BindingFlags.Instance,
938 MethodGroupExpr mg = (MethodGroupExpr) ml;
940 MethodBase constructor = mg.Methods [0];
942 string [] vals = { name };
944 CustomAttributeBuilder cb = null;
946 cb = new CustomAttributeBuilder ((ConstructorInfo) constructor, vals);
948 Report.Warning (-100, "Can not set the indexer default member attribute");
958 string IMemberContainer.Name {
964 Type IMemberContainer.Type {
970 IMemberContainer IMemberContainer.Parent {
972 return parent_container;
976 MemberCache IMemberContainer.MemberCache {
982 bool IMemberContainer.IsInterface {
988 MemberList IMemberContainer.GetMembers (MemberTypes mt, BindingFlags bf)
990 // Interfaces only contain instance members.
991 if ((bf & BindingFlags.Instance) == 0)
992 return MemberList.Empty;
993 if ((bf & BindingFlags.Public) == 0)
994 return MemberList.Empty;
996 BindingFlags new_bf = bf | BindingFlags.DeclaredOnly;
998 if (GenericType != null)
999 return TypeManager.FindMembers (GenericType, mt, new_bf,
1002 ArrayList members = new ArrayList ();
1004 if ((mt & MemberTypes.Method) != 0)
1005 members.AddRange (method_builders);
1007 if ((mt & MemberTypes.Property) != 0)
1008 members.AddRange (property_builders);
1010 if ((mt & MemberTypes.Event) != 0)
1011 members.AddRange (event_builders);
1013 return new MemberList (members);
1017 public abstract class InterfaceMemberBase: MemberCore, IAttributeSupport {
1018 public readonly bool IsNew;
1019 // Why is not readonly
1020 public Expression ReturnType;
1022 public InterfaceMemberBase (Expression type, string name, bool is_new, Attributes attrs, Location loc):
1023 base (name, attrs, loc)
1029 public virtual EmitContext Emit (TypeContainer tc, DeclSpace ds) {
1030 EmitContext ec = null;
1031 if (OptAttributes != null) {
1032 ec = new EmitContext (tc, ds, Location, null, null, ModFlags, false);
1034 Attribute.ApplyAttributes (ec, null, this, OptAttributes);
1040 #region IAttributeSupport Members
1041 public abstract void SetCustomAttribute (CustomAttributeBuilder customBuilder);
1044 public override bool Define (TypeContainer parent) {
1045 throw new NotImplementedException ();
1049 abstract public class InterfaceSetGetBase: InterfaceMemberBase
1051 internal sealed class PropertyAccessor: IAttributeSupport
1054 MethodBuilder m_builder;
1056 public PropertyAccessor (Attributes attrs) {
1060 public MethodBuilder Builder {
1066 public void Emit (EmitContext ec) {
1067 if (m_attrs != null) {
1068 Attribute.ApplyAttributes (ec, this, this, m_attrs);
1072 public void SetCustomAttribute (CustomAttributeBuilder customAttribute) {
1073 m_builder.SetCustomAttribute (customAttribute);
1078 PropertyAccessor m_get;
1079 PropertyAccessor m_set;
1080 protected PropertyBuilder Builder;
1082 public readonly bool HasSet;
1083 public readonly bool HasGet;
1085 public InterfaceSetGetBase (Expression type, string name, bool is_new,
1086 bool has_get, bool has_set, Attributes prop_attrs, Attributes get_attrs,
1087 Attributes set_attrs, Location loc)
1088 :base (type, name, is_new, prop_attrs, loc)
1092 m_get = new PropertyAccessor (get_attrs);
1093 m_set = new PropertyAccessor (set_attrs);
1097 public override EmitContext Emit (TypeContainer tc, DeclSpace ds) {
1098 EmitContext ec = base.Emit (tc, ds);
1100 ec = new EmitContext (tc, ds, Location, null, null, ModFlags, false);
1107 // TODO: It would be nice to have this method private
1108 public void SetBuilders (PropertyBuilder pb, MethodBuilder gb, MethodBuilder sb) {
1114 public override void SetCustomAttribute (CustomAttributeBuilder customBuilder) {
1115 Builder.SetCustomAttribute (customBuilder);
1120 public class InterfaceEvent : InterfaceMemberBase {
1121 MyEventBuilder Builder;
1123 public InterfaceEvent (Expression type, string name, bool is_new, Attributes attrs,
1125 : base (type, name, is_new, attrs, loc)
1129 public override string GetSignatureForError () {
1130 return TypeManager.GetFullNameSignature (Builder);
1133 public void SetBuilder (MyEventBuilder eb) {
1137 public override void SetCustomAttribute (CustomAttributeBuilder customBuilder) {
1138 Builder.SetCustomAttribute (customBuilder);
1142 public class InterfaceMethod : InterfaceMemberBase {
1143 public readonly Parameters Parameters;
1144 MethodBuilder Builder;
1146 public InterfaceMethod (Expression return_type, string name, bool is_new, Parameters args,
1147 Attributes attrs, Location l)
1148 : base (return_type, name, is_new, attrs, l)
1150 this.Parameters = args;
1153 public override EmitContext Emit(TypeContainer tc, DeclSpace ds) {
1154 EmitContext ec = base.Emit(tc, ds);
1156 ec = new EmitContext (tc, ds, Location, null, null, ModFlags, false);
1158 MethodCore.LabelParameters (ec, Builder, Parameters, OptAttributes, Location);
1163 /// Returns the signature for this interface method
1165 public string GetSignature (DeclSpace ds)
1167 ReturnType = ds.ResolveTypeExpr (ReturnType, false, Location);
1168 if (ReturnType == null)
1171 Type ret = ReturnType.Type;
1172 string args = Parameters.GetSignature (ds);
1174 if ((ret == null) || (args == null))
1177 return (IsNew ? "new-" : "") + ret.FullName + "(" + args + ")";
1180 public override string GetSignatureForError () {
1181 return TypeManager.CSharpSignature (Builder);
1184 public Type [] ParameterTypes (DeclSpace ds)
1186 return Parameters.GetParameterInfo (ds);
1189 public void SetBuilder (MethodBuilder mb) {
1193 public override void SetCustomAttribute(CustomAttributeBuilder customBuilder) {
1194 Builder.SetCustomAttribute (customBuilder);
1198 public class InterfaceProperty : InterfaceSetGetBase
1200 public InterfaceProperty (Expression type, string name,
1201 bool is_new, bool has_get, bool has_set,
1202 Attributes prop_attrs, Attributes get_attrs,
1203 Attributes set_attrs, Location loc)
1204 : base (type, name, is_new, has_get, has_set, prop_attrs, get_attrs, set_attrs, loc)
1208 public override string GetSignatureForError () {
1209 return TypeManager.CSharpSignature (Builder, false);
1213 public class InterfaceIndexer : InterfaceSetGetBase {
1214 public readonly Parameters Parameters;
1216 public InterfaceIndexer (Expression type, Parameters args, bool do_get, bool do_set,
1217 bool is_new, Attributes attrs, Attributes get_attrs, Attributes set_attrs,
1219 : base (type, "Item", is_new, do_get, do_set, attrs, get_attrs, set_attrs, loc)
1224 public override string GetSignatureForError() {
1225 return TypeManager.CSharpSignature (Builder, true);
1228 public Type [] ParameterTypes (DeclSpace ds) {
1229 return Parameters.GetParameterInfo (ds);