// 查找元素 public void FindClassAttrList(int access_level, ALittleScriptUtility.ClassAttrType attr_type, string name, List <ABnfElement> result) { if (access_level >= ALittleScriptUtility.sAccessOnlyPublic) { var map = GetElementMap(attr_type, ALittleScriptUtility.ClassAccessType.PUBLIC); if (map != null) { if (name.Length == 0) { result.AddRange(map.Values); } else { if (map.TryGetValue(name, out ABnfElement dec)) { result.Add(dec); } } } } if (access_level >= ALittleScriptUtility.sAccessProtectedAndPublic) { var map = GetElementMap(attr_type, ALittleScriptUtility.ClassAccessType.PROTECTED); if (map != null) { if (name.Length == 0) { result.AddRange(map.Values); } else { if (map.TryGetValue(name, out ABnfElement dec)) { result.Add(dec); } } } } if (access_level >= ALittleScriptUtility.sAccessPrivateAndProtectedAndPublic) { var map = GetElementMap(attr_type, ALittleScriptUtility.ClassAccessType.PRIVATE); if (map != null) { if (name.Length == 0) { result.AddRange(map.Values); } else { if (map.TryGetValue(name, out ABnfElement dec)) { result.Add(dec); } } } } }
public ABnfElement FindClassAttr(ALittleScriptClassDecElement dec , int access_level, ALittleScriptUtility.ClassAttrType attr_type, string name) { var result = new List <ABnfElement>(); FindClassAttrList(dec, access_level, attr_type, name, result); if (result.Count == 0) { return(null); } return(result[0]); }
// 获取元素集合 private Dictionary <string, ABnfElement> GetElementMap(ALittleScriptUtility.ClassAttrType attr_type, ALittleScriptUtility.ClassAccessType access_type) { if (!m_element_map.TryGetValue(access_type, out Dictionary <ALittleScriptUtility.ClassAttrType, Dictionary <string, ABnfElement> > map)) { return(null); } if (!map.TryGetValue(attr_type, out Dictionary <string, ABnfElement> sub_map)) { return(null); } return(sub_map); }
public void FindClassAttrList(ALittleScriptClassDecElement dec , int access_level, ALittleScriptUtility.ClassAttrType attr_type, string name, List <ABnfElement> result) { var name_dec = dec.GetClassNameDec(); if (name_dec == null) { return; } if (!m_class_data_map.TryGetValue(dec.GetFile(), out Dictionary <string, ALittleScriptClassData> map)) { return; } if (!map.TryGetValue(name_dec.GetElementText(), out ALittleScriptClassData data)) { return; } data.FindClassAttrList(access_level, attr_type, name, result); }