2 // (C) Sergey Chaban (serge@wildwestsoftware.com)
\r
5 using System.Collections;
\r
6 using System.Reflection;
\r
8 namespace Mono.ILASM {
\r
10 public class Types {
\r
12 // maps default types to their library equivalents
\r
13 private static Hashtable defaultTypes;
\r
14 private static readonly object dummy;
\r
15 private Hashtable userTypes;
\r
19 dummy = new Object ();
\r
21 defaultTypes = new Hashtable ();
\r
22 Hashtable t = defaultTypes;
\r
24 t ["object"] = Type.GetType ("System.Object");
\r
25 t ["string"] = Type.GetType ("System.String");
\r
26 t ["char"] = Type.GetType ("System.Char");
\r
27 t ["void"] = Type.GetType ("System.Void");
\r
28 t ["bool"] = Type.GetType ("System.Boolean");
\r
29 t ["int8"] = Type.GetType ("System.Byte");
\r
30 t ["int16"] = Type.GetType ("System.Int16");
\r
31 t ["int32"] = Type.GetType ("System.Int32");
\r
32 t ["int64"] = Type.GetType ("System.Int64");
\r
33 t ["float32"] = Type.GetType ("System.Single");
\r
34 t ["float64"] = Type.GetType ("System.Double");
\r
35 t ["uint8"] = Type.GetType ("System.SByte");
\r
36 t ["uint16"] = Type.GetType ("System.UInt16");
\r
37 t ["uint32"] = Type.GetType ("System.UInt32");
\r
38 t ["uint64"] = Type.GetType ("System.UInt64");
\r
51 /// <param name="typeName"></param>
\r
52 /// <returns></returns>
\r
53 public Type Lookup (string typeName)
\r
55 Type res = defaultTypes [typeName] as Type;
\r
62 /// <param name="name"></param>
\r
63 /// <param name="type"></param>
\r
64 public void Add (string name, Type type)
\r
66 if (defaultTypes.Contains (name)) return;
\r
68 if (userTypes == null) userTypes = new Hashtable ();
\r
69 userTypes [name] = (type != null) ? type : dummy;
\r
75 /// <param name="name"></param>
\r
76 public void Add (string name){
\r