2004-08-05 Anirban Bhattacharjee <banirban@novell.com>
[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                         AttributeSection asec = new AttributeSection(null, al);
28                         if (attrs == null)
29                                 attrs = new Attributes(asec, loc);
30                         else
31                                 attrs.AddAttribute(asec);
32                 }
33         }
34         
35         /// <summary>
36         /// Summary description for module.
37         /// </summary>
38         public class Module : Mono.MonoBASIC.Class 
39         {
40                 // <summary>
41                 //   Modifiers allowed in a class declaration
42                 // </summary>
43                 public new const int AllowedModifiers =
44                         Modifiers.PUBLIC |
45                         Modifiers.INTERNAL
46                         ;
47
48                 public Module(TypeContainer parent, string name, int mod, Attributes attrs, Location l)
49                         : base (parent, name, 0, null, l)
50                 {
51                         if (parent.Parent != null)
52                                 Report.Error (30617, l,
53                                         "'Module' statements can occur only at file or namespace level");
54
55                         // overwrite ModFlags
56                         this.ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.INTERNAL, l);
57
58                         // add specialized attribute
59                         Utils.AddSpecializedAttribute(ref attrs, "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute", null, l);
60                         this.attributes = attrs;
61                 }
62
63                 //
64                 // FIXME: How do we deal with the user specifying a different
65                 // layout?
66                 //
67                 public override TypeAttributes TypeAttr 
68                 {
69                         get 
70                         {
71                                 return base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class | TypeAttributes.Sealed;
72                         }
73                 }
74         }
75 }