// ############################################################################################# // public interface // ############################################################################################# /** **************************************************************************************** * Constructs a scope info. * @param name The name of the Lox we belong to * @param threadDictionary A dictionary to map thread IDs to user friendly names which is * managed outside of this class. ******************************************************************************************/ public ScopeInfo(String name, Dictionary <int, String> threadDictionary) { loxName = name.ToUpper(); ALIB.ASSERT_ERROR(!loxName.Equals("GLOBAL"), "Name \"GLOBAL\" not allowed for Lox instances"); this.threadDictionary = threadDictionary; cache = new SourceFile[cacheSize = DefaultCacheSize]; for (int i = 0; i < cacheSize; i++) { cache[i] = new SourceFile(); } actual = cache[0]; // read trim rules from config // do 2 times, 0== local list, 1== global list List <SourcePathTrimRule> trimInfoList; AString rules = new AString(); AString variableName = new AString(); for (int trimInfoNo = 0; trimInfoNo < 2; trimInfoNo++) { // check if done... or set list variableName._(); if (trimInfoNo == 0) { trimInfoList = LocalSPTRs; variableName._(loxName); } else { if (GlobalSPTRsReadFromConfig) { continue; } GlobalSPTRsReadFromConfig = true; trimInfoList = GlobalSPTRs; variableName._("GLOBAL"); } variableName._("_SOURCE_PATH_TRIM_RULES"); // get auto sizes from last session rules._(); if (ALIB.Config.Get(ALox.ConfigCategoryName, variableName, rules) != 0) { Tokenizer rulesTok = new Tokenizer(); Tokenizer ruleTok = new Tokenizer(); rulesTok.Set(rules, ';'); Substring ruleStr; while ((ruleStr = rulesTok.Next()).IsNotEmpty()) { try { ruleTok.Set(ruleStr, ','); SourcePathTrimRule rule = new SourcePathTrimRule(); rule.Path = new AString(); ruleTok.Next(); if (!(rule.IsPrefix = !ruleTok.Actual.StartsWith("*"))) { ruleTok.Actual.Consume(1); } rule.Path._(ruleTok.Actual); if (rule.Path.CharAtEnd() == '*') { rule.Path.DeleteEnd(1); } if (rule.Path.IsEmpty()) { continue; } if (Path.DirectorySeparatorChar == '/') { rule.Path.SearchAndReplaceAll("\\", "/"); } else { rule.Path.SearchAndReplaceAll("/", "\\"); } rule.IncludeString = ALIB.ReadInclusion(ruleTok.Next()); if (ruleTok.HasNext()) { ruleTok.Next().ConsumeInteger(out rule.TrimOffset); } rule.Sensitivity = ALIB.ReadCase(ruleTok.Next()); trimInfoList.Add(rule); } catch (Exception) { ALIB.ERROR("Error reading source path trim rule from configuration. Invalid String: " + ruleStr.ToString()); } } } } }