/// <summary> /// Reset this context to the first line of code, clearing out any /// temporary variables, and optionally clearing out all variables. /// </summary> /// <param name="clearVariables">if true, clear our local variables</param> public void Reset(bool clearVariables = true) { lineNum = 0; // #0 is the return variable, which we don't want to unref // unless this is the root context, in which case we unref it all int start = root == this ? 0 : 1; for (int i = start; i < temps.Count; i++) { TempEntry entry = temps[i]; if (!entry.Unref) { continue; } entry.value?.Unref(); } temps.Clear(); if (clearVariables) { if (variables != null) { variables.Unref(); } variables = null; } }
public void SetTemp(int tempNum, Value value, bool unrefWhenDone) { if (temps.Count <= tempNum) { while (temps.Count <= tempNum) { temps.Add(default(TempEntry)); } } else { TempEntry existing = temps[tempNum]; if (existing.Unref && existing.value != null) { existing.value.Unref(); } } temps[tempNum] = new TempEntry { value = value, Unref = unrefWhenDone }; }
public FStats(List <QSO> lQSO, string type) { InitializeComponent(); bsStats = new BindingSource(blStats, null); dgvStats.AutoGenerateColumns = false; dgvStats.DataSource = bsStats; dgvStats.Columns[0].HeaderText = type; if (type == "RDA") { Dictionary <string, TempEntry> data = new Dictionary <string, TempEntry>(); lQSO .Where(qso => qso.rda != null).ToList() .ForEach(qso => { string[] rdas = qso.rda.Split(new string[] { ", " }, StringSplitOptions.None); foreach (string rda in rdas) { if (rda.IndexOf(',') != -1) { System.Diagnostics.Trace.TraceInformation(qso.rda); } if (!data.ContainsKey(rda)) { data[rda] = new TempEntry(); } data[rda].qsoCount += 1; data[rda].csList.Add(qso.cs); } }); data.Keys.ToList().OrderBy(k => k).ToList().ForEach(k => { blStats.Add(new Entry { _value = k, _csCount = data[k].csList.Count, _qsoCount = data[k].qsoCount }); }); } if (type == "RAFA") { Dictionary <string, TempEntry> data = new Dictionary <string, TempEntry>(); lQSO .Where(qso => qso.rafa != null).ToList() .ForEach(qso => { string[] rafas = qso.rafa.Split(new string[] { ", " }, StringSplitOptions.None); foreach (string rafa in rafas) { if (!data.ContainsKey(rafa)) { data[rafa] = new TempEntry(); } data[rafa].qsoCount += 1; data[rafa].csList.Add(qso.cs); } }); data.Keys.ToList().OrderBy(k => k).ToList().ForEach(k => { blStats.Add(new Entry { _value = k, _csCount = data[k].csList.Count, _qsoCount = data[k].qsoCount }); }); } dgvStats.Refresh(); }