2001-09-11 Ravi Pratap <ravi@ximian.com>
[mono.git] / mcs / mcs / delegate.cs
1 //\r
2 // delegate.cs: Delegate Handler\r
3 //\r
4 // Author: Ravi Pratap (ravi@ximian.com)\r
5 //\r
6 // Licensed under the terms of the GNU GPL\r
7 //\r
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)\r
9 //\r
10 //\r
11 \r
12 using System;\r
13 using System.Collections;\r
14 using System.Reflection;\r
15 using System.Reflection.Emit;\r
16 \r
17 namespace CIR {\r
18         \r
19         public class Delegate : DeclSpace {\r
20 \r
21                 public string name;\r
22                 public string type;\r
23                 public int    mod_flags;\r
24                 public Parameters Parameters;\r
25                 public Attributes OptAttributes;\r
26                 public TypeBuilder DelegateBuilder;\r
27 \r
28                 const int AllowedModifiers =\r
29                         Modifiers.NEW |\r
30                         Modifiers.PUBLIC |\r
31                         Modifiers.PROTECTED |\r
32                         Modifiers.INTERNAL |\r
33                         Modifiers.PRIVATE;\r
34 \r
35                 public Delegate (string type, int mod_flags, string name, Parameters param_list,\r
36                                  Attributes attrs) : base (name)\r
37                 {\r
38                         this.name       = name;\r
39                         this.type       = type;\r
40                         this.mod_flags  = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PUBLIC);\r
41                         Parameters      = param_list;\r
42                         OptAttributes   = attrs;\r
43                 }\r
44 \r
45                 public void Define (TypeContainer parent)\r
46                 {\r
47                         TypeAttributes attr = Modifiers.TypeAttr (ModFlags);\r
48 \r
49                         Type t = parent.LookupType (type, false);\r
50                         Type [] param_types = Parameters.GetParameterInfo (parent);\r
51                         Type base_type = System.Type.GetType ("System.MulticastDelegate");\r
52 \r
53                         DelegateBuilder = parent.TypeBuilder.DefineNestedType (name, attr, base_type);\r
54 \r
55                         // FIXME : Need to figure out how to proceed from here. \r
56 \r
57                 }\r
58                 \r
59                 \r
60                 public string Type {\r
61                         get {\r
62                                 return type;\r
63                         }\r
64                 }\r
65 \r
66                 public int ModFlags {\r
67                         get {\r
68                                 return mod_flags;\r
69                         }\r
70                 }\r
71                 \r
72 \r
73         }\r
74         \r
75 }\r