/// <summary> /// This finds or creates the decl, but does not cause a parse. This is only used internally. /// </summary> /// <param name="type"></param> /// <param name="name"></param> /// <param name="makeDefault"></param> /// <returns></returns> internal idDecl FindTypeWithoutParsing(DeclType type, string name, bool makeDefault) { if (_declTypes.ContainsKey(type) == false) { idConsole.FatalError("find type without parsing: bad type {0}", type.ToString().ToLower()); } else { string canonicalName = name; foreach (idDecl decl in _declsByType[type]) { if (decl.Name.Equals(canonicalName, StringComparison.OrdinalIgnoreCase) == true) { // only print these when decl_show is set to 2, because it can be a lot of clutter if (idE.CvarSystem.GetInteger("decl_show") > 1) { MediaPrint("referencing {0} {1}", type.ToString().ToLower(), name); } return(decl); } } if (makeDefault == true) { idDecl newDecl = _declTypes[type].Allocator.Create(); newDecl.Name = canonicalName; newDecl.Type = type; newDecl.State = DeclState.Unparsed; newDecl.SourceFile = _implicitDecls; newDecl.ParsedOutsideLevelLoad = !_insideLevelLoad; newDecl.Index = _declsByType[type].Count; _declsByType[type].Add(newDecl); return(newDecl); } } return(null); }
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); }