2001-10-12 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 {\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                 Location loc;\r
29 \r
30                 const int AllowedModifiers =\r
31                         Modifiers.NEW |\r
32                         Modifiers.PUBLIC |\r
33                         Modifiers.PROTECTED |\r
34                         Modifiers.INTERNAL |\r
35                         Modifiers.PRIVATE;\r
36 \r
37                 public Delegate (string type, int mod_flags, string name, Parameters param_list,\r
38                                  Attributes attrs, Location loc)\r
39                 {\r
40                         this.Name       = name;\r
41                         this.type       = type;\r
42                         this.mod_flags  = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PUBLIC);\r
43                         Parameters      = param_list;\r
44                         OptAttributes   = attrs;\r
45                         this.loc        = loc;\r
46                 }\r
47 \r
48                 public void Define (TypeContainer parent)\r
49                 {\r
50                         TypeAttributes attr;\r
51                         \r
52                         if (parent.IsTopLevel)\r
53                                 attr = TypeAttributes.NestedPublic | TypeAttributes.Class;\r
54                         else\r
55                                 attr = TypeAttributes.Public | TypeAttributes.Class;\r
56                         \r
57                         Type t = parent.LookupType (type, false);\r
58                         Type [] param_types = Parameters.GetParameterInfo (parent);\r
59                         Type base_type = System.Type.GetType ("System.MulticastDelegate");\r
60 \r
61                         DelegateBuilder = parent.TypeBuilder.DefineNestedType (Name, attr, base_type);\r
62 \r
63                         //DelegateBuilder.CreateType ();\r
64 \r
65                 }\r
66                 \r
67                 \r
68                 public string Type {\r
69                         get {\r
70                                 return type;\r
71                         }\r
72                 }\r
73 \r
74                 public int ModFlags {\r
75                         get {\r
76                                 return mod_flags;\r
77                         }\r
78                 }\r
79                 \r
80 \r
81         }\r
82         \r
83 }\r