bb284b5d516e6f4486c90d6e73ad12e5fe122367
[mono.git] / mcs / mbas / module.cs
1 //
2 // module.cs: Module handler
3 //
4 // Author: Rafael Teixeira (rafaelteixeirabr@hotmail.com)
5 //
6 // Licensed under the terms of the GNU GPL
7 //
8 // (C) 2002 Rafael Teixeira
9 //
10 using System;
11 using System.Collections;
12 using System.Diagnostics.SymbolStore;
13 using System.Reflection;
14 using System.Reflection.Emit;
15 using System.Runtime.CompilerServices;
16 using Mono.MonoBASIC ;
17
18 namespace Mono.MonoBASIC
19 {
20         public class Utils
21         {
22                 public static void AddSpecializedAttribute(ref Attributes attrs, string attributeName, ArrayList args, Location loc)
23                 {
24                         Mono.MonoBASIC.Attribute specialAttr = new Mono.MonoBASIC.Attribute(attributeName, args, loc);
25                         ArrayList al = new ArrayList();
26                         al.Add(specialAttr);
27                         if (attrs == null)
28                                 attrs = new Attributes(al);
29                         else
30                                 attrs.AddAttributes(al);
31                 }
32         }
33         
34         /// <summary>
35         /// Summary description for module.
36         /// </summary>
37         public class Module : Mono.MonoBASIC.Class 
38         {
39                 // <summary>
40                 //   Modifiers allowed in a class declaration
41                 // </summary>
42                 public new const int AllowedModifiers =
43                         Modifiers.PUBLIC |
44                         Modifiers.INTERNAL
45                         ;
46
47                 public Module(TypeContainer parent, string name, int mod, Attributes attrs, Location l)
48                         : base (parent, name, 0, null, l)
49                 {
50                         if (parent.Parent != null)
51                                 Report.Error (30617, l,
52                                         "'Module' statements can occur only at file or namespace level");
53
54                         // overwrite ModFlags
55                         this.ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.INTERNAL, l);
56
57                         // add specialized attribute
58                         Utils.AddSpecializedAttribute(ref attrs, "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute", null, l);
59                         this.attributes = attrs;
60                 }
61
62                 //
63                 // FIXME: How do we deal with the user specifying a different
64                 // layout?
65                 //
66                 public override TypeAttributes TypeAttr 
67                 {
68                         get 
69                         {
70                                 return base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class | TypeAttributes.Sealed;
71                         }
72                 }
73         }
74 }