**** Merged from MCS ****
[mono-project.git] / mcs / mbas / interface.cs
bloba3077b865fb6a9021c031a338ade01ab1820aa5d
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)
12 /*This file will go off shortly
13 * after copying the interface class
14 * in class.cs file
17 #define CACHE
18 using System.Collections;
19 using System;
20 using System.IO;
21 using System.Reflection;
22 using System.Reflection.Emit;
24 namespace Mono.MonoBASIC {
26 /// <summary>
27 /// Interfaces
28 /// </summary>
31 /// <summary>
32 /// Interfaces
33 /// </summary>
34 public class Interface : Mono.MonoBASIC.Class /*TypeContainer , IMemberContainer */
36 /// <summary>
37 /// Modifiers allowed in a class declaration
38 /// </summary>
39 public new const int AllowedModifiers =
40 Modifiers.NEW |
41 Modifiers.PUBLIC |
42 Modifiers.PROTECTED |
43 Modifiers.INTERNAL |
44 Modifiers.PRIVATE;
46 public Interface (TypeContainer parent, string name, int mod,
47 Attributes attrs, Location l)
48 : base (parent, name, 0, attrs, l)
50 int accmods;
52 if (parent.Parent == null)
53 accmods = Modifiers.INTERNAL;
54 else
55 accmods = Modifiers.PUBLIC;
57 this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
58 this.ModFlags |= Modifiers.ABSTRACT;
61 public override AttributeTargets AttributeTargets {
62 get {
63 return AttributeTargets.Interface;
67 public override TypeAttributes TypeAttr
69 get
71 return base.TypeAttr |
72 TypeAttributes.AutoLayout |
73 TypeAttributes.Abstract |
74 TypeAttributes.Interface;
80 public class InterfaceMemberBase {
81 public readonly string Name;
82 public readonly bool IsNew;
83 public Attributes OptAttributes;
85 public InterfaceMemberBase (string name, bool is_new, Attributes attrs)
87 Name = name;
88 IsNew = is_new;
89 OptAttributes = attrs;
93 public class InterfaceProperty : InterfaceMemberBase {
94 public readonly bool HasSet;
95 public readonly bool HasGet;
96 public readonly Location Location;
97 public Expression Type;
99 public InterfaceProperty (Expression type, string name,
100 bool is_new, bool has_get, bool has_set,
101 Attributes attrs, Location loc)
102 : base (name, is_new, attrs)
104 Type = type;
105 HasGet = has_get;
106 HasSet = has_set;
107 Location = loc;
111 /* public class InterfaceEvent : InterfaceMemberBase {
112 public readonly Location Location;
113 public Expression Type;
115 public InterfaceEvent (Expression type, string name, bool is_new, Attributes attrs,
116 Location loc)
117 : base (name, is_new, attrs)
119 Type = type;
120 Location = loc;
124 public class InterfaceMethod : InterfaceMemberBase {
125 public readonly Expression ReturnType;
126 public readonly Parameters Parameters;
127 public readonly Location Location;
129 public InterfaceMethod (Expression return_type, string name, bool is_new, Parameters args,
130 Attributes attrs, Location l)
131 : base (name, is_new, attrs)
133 this.ReturnType = return_type;
134 this.Parameters = args;
135 Location = l;
138 /// <summary>
139 /// Returns the signature for this interface method
140 /// </summary>
141 public string GetSignature (DeclSpace ds)
143 Type ret = ds.ResolveType (ReturnType, false, Location);
144 string args = Parameters.GetSignature (ds);
146 if ((ret == null) || (args == null))
147 return null;
149 return (IsNew ? "new-" : "") + ret.FullName + "(" + args + ")";
152 public Type [] ParameterTypes (DeclSpace ds)
154 return Parameters.GetParameterInfo (ds);
158 public class InterfaceIndexer : InterfaceMemberBase {
159 public readonly bool HasGet, HasSet;
160 public readonly Parameters Parameters;
161 public readonly Location Location;
162 public Expression Type;
164 public InterfaceIndexer (Expression type, Parameters args, bool do_get, bool do_set,
165 bool is_new, Attributes attrs, Location loc)
166 : base ("", is_new, attrs)
168 Type = type;
169 Parameters = args;
170 HasGet = do_get;
171 HasSet = do_set;
172 Location = loc;
175 public Type [] ParameterTypes (DeclSpace ds)
177 return Parameters.GetParameterInfo (ds);