2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / bmcs / 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.CSharp ;
17
18 namespace Mono.CSharp
19 {
20         public class Utils
21         {
22                 public static void AddSpecializedAttribute(ref Attributes attrs, string attributeName, ArrayList args, Location loc)
23                 {
24                         Mono.CSharp.Attribute specialAttr = new Mono.CSharp.Attribute(null, attributeName, args, loc); // Sudha :  passed null for target
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
35         public class VBModule : Class
36         {
37                 public new const int AllowedModifiers = Modifiers.PUBLIC |Modifiers.INTERNAL;
38
39                 public VBModule (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
40                               Attributes attrs, Location l)
41                         : base (ns, parent, name, 0, attrs, l)
42
43                 {
44                         if (parent.Parent != null)
45                                 Report.Error (30617, l,
46                                         "'Module' statements can occur only at file or namespace level");
47
48                         // overwrite ModFlags
49                         this.ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.INTERNAL, l);
50
51                         // add specialized attribute
52                         Utils.AddSpecializedAttribute(ref attributes, "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute", null, l);
53                 }
54
55
56                 public override TypeAttributes TypeAttr 
57                 {
58                         get {
59                                 return base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class | TypeAttributes.Sealed;
60                         }
61                 }
62         }
63 }