-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTypes.cs
More file actions
82 lines (64 loc) · 1.97 KB
/
Copy pathTypes.cs
File metadata and controls
82 lines (64 loc) · 1.97 KB
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
// Types.cs
// (C) Sergey Chaban (serge@wildwestsoftware.com)
using System;
using System.Collections;
using System.Reflection;
namespace Mono.ILASM {
public class Types {
// maps default types to their library equivalents
private static Hashtable defaultTypes;
private static readonly object dummy;
private Hashtable userTypes;
static Types ()
{
dummy = new Object ();
defaultTypes = new Hashtable ();
Hashtable t = defaultTypes;
t ["object"] = Type.GetType ("System.Object");
t ["string"] = Type.GetType ("System.String");
t ["char"] = Type.GetType ("System.Char");
t ["void"] = Type.GetType ("System.Void");
t ["bool"] = Type.GetType ("System.Boolean");
t ["int8"] = Type.GetType ("System.Byte");
t ["int16"] = Type.GetType ("System.Int16");
t ["int32"] = Type.GetType ("System.Int32");
t ["int64"] = Type.GetType ("System.Int64");
t ["float32"] = Type.GetType ("System.Single");
t ["float64"] = Type.GetType ("System.Double");
t ["uint8"] = Type.GetType ("System.SByte");
t ["uint16"] = Type.GetType ("System.UInt16");
t ["uint32"] = Type.GetType ("System.UInt32");
t ["uint64"] = Type.GetType ("System.UInt64");
}
/// <summary>
/// </summary>
public Types ()
{
}
/// <summary>
/// </summary>
/// <param name="typeName"></param>
/// <returns></returns>
public Type Lookup (string typeName)
{
Type res = defaultTypes [typeName] as Type;
return res;
}
/// <summary>
/// </summary>
/// <param name="name"></param>
/// <param name="type"></param>
public void Add (string name, Type type)
{
if (defaultTypes.Contains (name)) return;
if (userTypes == null) userTypes = new Hashtable ();
userTypes [name] = (type != null) ? type : dummy;
}
/// <summary>
/// </summary>
/// <param name="name"></param>
public void Add (string name){
Add (name, null);
}
}
}