Welcome to mirror list, hosted at ThFree Co, Russian Federation.

module.cs « mbas « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec9982d7e025ec1ead43d9b3f48029e045a6acd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// module.cs: Module handler
//
// Author: Rafael Teixeira (rafaelteixeirabr@hotmail.com)
//
// Licensed under the terms of the GNU GPL
//
// (C) 2002 Rafael Teixeira
//
using System;
using System.Collections;
using System.Diagnostics.SymbolStore;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using Mono.CSharp ;

namespace Mono.MonoBASIC
{
	public class Utils
	{
		public static void AddSpecializedAttribute(ref Attributes attrs, string attributeName, ArrayList args, Location loc)
		{
			Mono.CSharp.Attribute specialAttr = new Mono.CSharp.Attribute(attributeName, args, loc);
			ArrayList al = new ArrayList();
			al.Add(specialAttr);
			AttributeSection asec = new AttributeSection(null, al);
			if (attrs == null)
				attrs = new Attributes(asec, loc);
			else
				attrs.AddAttribute(asec);
		}
	}
	
	/// <summary>
	/// Summary description for module.
	/// </summary>
	public class Module : Mono.CSharp.Class 
	{
		// <summary>
		//   Modifiers allowed in a class declaration
		// </summary>
		public new const int AllowedModifiers =
			Modifiers.PUBLIC |
			Modifiers.INTERNAL;

		public Module(TypeContainer parent, string name, int mod, Attributes attrs, Location l)
			: base (parent, name, 0, null, l)
		{
			if (parent.Parent != null)
				Report.Error (30617, l,
					"'Module' statements can occur only at file or namespace level");

			// overwrite ModFlags
			this.ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.INTERNAL, l);

			// add specialized attribute
			Utils.AddSpecializedAttribute(ref attrs, "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute", null, l);
			this.attributes = attrs;
		}

		//
		// FIXME: How do we deal with the user specifying a different
		// layout?
		//
		public override TypeAttributes TypeAttr 
		{
			get 
			{
				return base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class | TypeAttributes.Sealed;
			}
		}
	}
}