/// <summary> /// Finds the decl with the given name and type; returning a default version if requested. /// </summary> /// <param name="type"></param> /// <param name="name"></param> /// <param name="makeDefault"> If true, a default decl of appropriate type will be created.</param> /// <returns>Decl with the given name or a default decl of the requested type if not found or null if makeDefault is false.</returns> public T FindType <T>(DeclType type, string name, bool makeDefault) where T : idDecl { if ((name == null) || (name == string.Empty)) { name = "_emptyName"; } idDecl decl = FindTypeWithoutParsing(type, name, makeDefault); if (decl == null) { return(null); } // if it hasn't been parsed yet, parse it now if (decl.State == DeclState.Unparsed) { decl.ParseLocal(); } // mark it as referenced decl.ReferencedThisLevel = true; decl.EverReferenced = true; if (_insideLevelLoad == true) { decl.ParsedOutsideLevelLoad = false; } return(decl as T); }
public idDecl DeclByIndex(DeclType type, int index, bool forceParse) { if (_declTypes.ContainsKey(type) == false) { idConsole.FatalError("idDeclManager.DeclByIndex: bad type: {0}", type.ToString().ToLower()); } if ((index < 0) || (index >= _declsByType[type].Count)) { idConsole.Error("idDeclManager.DeclByIndex: out of range [{0}: {1} < {2}]", type, index, _declsByType[type].Count); } idDecl decl = _declsByType[type][index]; if ((forceParse == true) && (decl.State == DeclState.Unparsed)) { decl.ParseLocal(); } return(decl); }