internal override IList <Executable> Resolve(Parser parser) { bool removeBreaks = parser.RemoveBreaksFromSwitch; int[] keys = codeByCondition.Keys.ToArray(); // iterate over a copy of keys so you don't modify the enumerable while iterating. foreach (int key in keys) { codeByCondition[key] = Executable.RemoveBreaksForElifedSwitch(removeBreaks, codeByCondition[key]); } return(Listify(this)); }
internal override IList <Executable> Resolve(Parser parser) { bool removeBreaks = parser.RemoveBreaksFromSwitch; if (removeBreaks) { foreach (int key in this.codeMapping.Keys.ToArray()) // ToArray is used otherwise C# considers this modifying the enumerable collection { this.codeMapping[key] = Executable.RemoveBreaksForElifedSwitch(removeBreaks, this.codeMapping[key]); } if (parser.NullablePlatform != null) { int num = parser.NullablePlatform.Translator.GetNextInt(); this.LookupTableName = "switch_lookup_" + num; this.SwitchKeyName = "switch_key_" + num; } if (this.UsesStrings) { Dictionary <string, int> lookup = new Dictionary <string, int>(); foreach (string key in this.StringUnsafeToSafeMapping.Keys) { lookup.Add(key, this.StringUnsafeToSafeMapping[key]); } parser.RegisterSwitchStringDictLookup(this.LookupTableName, lookup); } else { Dictionary <int, int> lookup = new Dictionary <int, int>(); foreach (int key in this.IntegerUnsafeToSafeMapping.Keys) { lookup.Add(key, this.IntegerUnsafeToSafeMapping[key]); } parser.RegisterSwitchIntegerListLookup(this.LookupTableName, lookup, this.UseExplicitMax ? this.ExplicitMax : 0, this.DefaultCaseId); } } return(Listify(this)); }