2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / mbas / interface.cs
1 //
2 // interface.cs: Interface handler
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //                 Anirban Bhattacharjee (banirban@novell.com)
6 //
7 // Licensed under the terms of the GNU GPL
8 //
9 // (C) 2001 Ximian, Inc (http://www.ximian.com)
10 //
11
12 #define CACHE
13
14 /*This file will go off shortly
15  * after copying the interface class 
16  * in class.cs file
17  */
18
19 using System.Collections;
20 using System;
21 using System.IO;
22 using System.Reflection;
23 using System.Reflection.Emit;
24
25 namespace Mono.MonoBASIC {
26
27         /// <summary>
28         ///   Interfaces
29         /// </summary>
30
31
32         /// <summary>
33         ///   Interfaces
34         /// </summary>
35         public class Interface : Mono.MonoBASIC.Class /*TypeContainer , IMemberContainer */
36         {
37                 /// <summary>
38                 ///   Modifiers allowed in a class declaration
39                 /// </summary>
40                 public new const int AllowedModifiers =
41                         Modifiers.NEW       |
42                         Modifiers.PUBLIC    |
43                         Modifiers.PROTECTED |
44                         Modifiers.INTERNAL  |
45                         Modifiers.PRIVATE;
46
47                 public Interface (TypeContainer parent, string name, int mod,
48                                                         Attributes attrs, Location l)
49                         : base (parent, name, 0, attrs, l)
50                 {
51                         int accmods;
52
53                         if (parent.Parent == null)
54                                 accmods = Modifiers.INTERNAL;
55                         else
56                                 accmods = Modifiers.PUBLIC;
57
58                         this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
59                         this.ModFlags |= Modifiers.ABSTRACT;
60                 }
61
62                 public override AttributeTargets AttributeTargets {
63                         get {
64                                 return AttributeTargets.Interface;
65                         }
66                 }
67
68                 public override TypeAttributes TypeAttr 
69                 {
70                         get 
71                         {
72                                 return base.TypeAttr |
73                                         TypeAttributes.AutoLayout |
74                                         TypeAttributes.Abstract |
75                                         TypeAttributes.Interface;
76                         }
77                 }
78         }
79
80 /*
81         public class InterfaceMemberBase {
82                 public readonly string Name;
83                 public readonly bool IsNew;
84                 public Attributes OptAttributes;
85                 
86                 public InterfaceMemberBase (string name, bool is_new, Attributes attrs)
87                 {
88                         Name = name;
89                         IsNew = is_new;
90                         OptAttributes = attrs;
91                 }
92         }
93         
94         public class InterfaceProperty : InterfaceMemberBase {
95                 public readonly bool HasSet;
96                 public readonly bool HasGet;
97                 public readonly Location Location;
98                 public Expression Type;
99                 
100                 public InterfaceProperty (Expression type, string name,
101                                           bool is_new, bool has_get, bool has_set,
102                                           Attributes attrs, Location loc)
103                         : base (name, is_new, attrs)
104                 {
105                         Type = type;
106                         HasGet = has_get;
107                         HasSet = has_set;
108                         Location = loc;
109                 }
110         }
111 */
112 /*      public class InterfaceEvent : InterfaceMemberBase {
113                 public readonly Location Location;
114                 public Expression Type;
115                 
116                 public InterfaceEvent (Expression type, string name, bool is_new, Attributes attrs,
117                                        Location loc)
118                         : base (name, is_new, attrs)
119                 {
120                         Type = type;
121                         Location = loc;
122                 }
123         }
124 /*      
125         public class InterfaceMethod : InterfaceMemberBase {
126                 public readonly Expression ReturnType;
127                 public readonly Parameters Parameters;
128                 public readonly Location Location;
129                 
130                 public InterfaceMethod (Expression return_type, string name, bool is_new, Parameters args,
131                                         Attributes attrs, Location l)
132                         : base (name, is_new, attrs)
133                 {
134                         this.ReturnType = return_type;
135                         this.Parameters = args;
136                         Location = l;
137                 }
138
139                 /// <summary>
140                 ///   Returns the signature for this interface method
141                 /// </summary>
142                 public string GetSignature (DeclSpace ds)
143                 {
144                         Type ret = ds.ResolveType (ReturnType, false, Location);
145                         string args = Parameters.GetSignature (ds);
146
147                         if ((ret == null) || (args == null))
148                                 return null;
149                         
150                         return (IsNew ? "new-" : "") + ret.FullName + "(" + args + ")";
151                 }
152
153                 public Type [] ParameterTypes (DeclSpace ds)
154                 {
155                         return Parameters.GetParameterInfo (ds);
156                 }
157         }
158
159         public class InterfaceIndexer : InterfaceMemberBase {
160                 public readonly bool HasGet, HasSet;
161                 public readonly Parameters Parameters;
162                 public readonly Location Location;
163                 public Expression Type;
164                 
165                 public InterfaceIndexer (Expression type, Parameters args, bool do_get, bool do_set,
166                                          bool is_new, Attributes attrs, Location loc)
167                         : base ("", is_new, attrs)
168                 {
169                         Type = type;
170                         Parameters = args;
171                         HasGet = do_get;
172                         HasSet = do_set;
173                         Location = loc;
174                 }
175
176                 public Type [] ParameterTypes (DeclSpace ds)
177                 {
178                         return Parameters.GetParameterInfo (ds);
179                 }
180         }*/
181 }