File: NativeEnumType.cs

package info (click to toggle)
mono-debugger 0.60%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,556 kB
  • ctags: 22,787
  • sloc: ansic: 99,407; cs: 42,429; sh: 9,192; makefile: 376
file content (114 lines) | stat: -rw-r--r-- 2,170 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;

namespace Mono.Debugger.Languages.Native
{
	internal class NativeEnumType : TargetEnumType
	{
		string name;
		int size;

		string[] element_names;
		int[] element_values;

		NativeEnumInfo[] members;
		NativeEnumInfo value;

		public NativeEnumType (Language language, string name, int size,
				       string[] element_names, int[] element_values)
			: base (language)
		{
			this.name = name;
			this.size = size;
			this.element_names = element_names;
			this.element_values = element_values;

			members = new NativeEnumInfo [element_names.Length];
			for (int i = 0; i < element_names.Length; i++)
				members [i] = new NativeEnumInfo (
					this, element_names [i], i, element_values [i]);

			value = new NativeEnumInfo (language.IntegerType, "__value", 0, 0);
		}

		public override bool HasClassType {
			get { return false; }
		}

		public override TargetClassType ClassType {
			get { throw new InvalidOperationException (); }
		}

		public override string Name {
			get { return name; }
		}

		public override int Size {
			get { return size; }
		}

		public override bool HasFixedSize {
			get { return true; }
		}

		public string[] ElementNames {
			get {
				return element_names;
			}
		}

		public int[] ElementValues {
			get {
				return element_values;
			}
		}

		public override bool IsFlagsEnum {
			get {
				return false;
			}
		}

		public override TargetEnumInfo Value {
			get {
				return value;
			}
		}

		public override TargetEnumInfo[] Members {
			get {
				return members;
			}
		}

		public override bool IsByRef {
			get {
				return false;
			}
		}
	}

	[Serializable]
	internal class NativeEnumInfo : TargetEnumInfo
	{
		int const_value;

		public NativeEnumInfo (TargetType field_type, string name, int index, int value)
			: base (field_type, name, index, false, 0, 0, true)
		{
			this.const_value = value;
		}

		public NativeEnumInfo (TargetType field_type, string name, int index)
			: base (field_type, name, index, false, 0, 0, false)
		{ }

		public override object ConstValue {
			get {
				if (HasConstValue)
					return const_value;
				else
					throw new InvalidOperationException ();
			}
		}
	}
}