public static Type FindType(string name, PascalABCCompiler.TreeRealization.using_namespace_list _unar) { FoundInfo fi = null; if (type_search_cache.TryGetValue(name, out fi)) { if (!fi.exists) return null; TypeInfo ti = fi.GetTypeByNamespaceList(_unar); if (ti != null) return ti.type; } object o = types[name]; if (o == null) { type_search_cache[name] = new FoundInfo(false); return null; } if (o is TypeInfo) { TypeInfo t = o as TypeInfo; for (int i = 0; i < _unar.Count; i++) { if (string.Compare(_unar[i].namespace_name + "." + name, t.FullName, true) == 0) { if (!type_search_cache.TryGetValue(name, out fi)) { fi = new FoundInfo(true, t, _unar[i]); type_search_cache[name] = fi; } else { fi.type_infos.Add(new TypeNamespaceInfo(t, _unar[i])); } return t.type; } } return null; } else if (o is List<TypeInfo>) { foreach (TypeInfo t in o as List<TypeInfo>) { for (int i = 0; i < _unar.Count; i++) { if (string.Compare(_unar[i].namespace_name + "." + name, t.FullName, true) == 0) { if (!type_search_cache.TryGetValue(name, out fi)) { fi = new FoundInfo(true, t, _unar[i]); type_search_cache[name] = fi; } else { fi.type_infos.Add(new TypeNamespaceInfo(t, _unar[i])); } return t.type; } } } return null; } for (int i = 0; i < _unar.Count; i++) { o = types[_unar[i].namespace_name + "." + name]; if (o == null) continue; if (o is TypeInfo) return (o as TypeInfo).type; List<TypeInfo> typs = o as List<TypeInfo>; List<TypeInfo> founded_types = new List<TypeInfo>(); foreach (TypeInfo t in typs) { if (cur_used_assemblies.ContainsKey(t.type.Assembly)) founded_types.Add(t); } if (founded_types.Count == 1) return founded_types[0].type; else return null; } return null; }
public static Type FindType(string name) { FoundInfo fi = null; if (type_search_cache.TryGetValue(name, out fi)) { if (!fi.exists) return null; TypeInfo ti = fi.type_infos[0].type_info; if (ti != null) return ti.type; } TypeInfo t = (TypeInfo)types[name]; if (t != null) { fi = new FoundInfo(true, t); type_search_cache[name] = fi; return t.type; } else { fi = new FoundInfo(false); type_search_cache[name] = fi; } return null; }