// -------------------------------------------------------------------------- // 1. goto 9 // 9. goto 21 // 1. goto 21 // 9. goto 21 private void TraceGotoChains() { for (int index = 1; index < m_middleCodeList.Count; ++index) { MiddleCode middleCode = m_middleCodeList[index]; if (middleCode.IsRelationCarryOrGoto()) { ISet <int> sourceSet = new HashSet <int>(); sourceSet.Add(index); int firstTarget = (int)middleCode[0]; int finalTarget = TraceGoto(firstTarget, sourceSet); if (firstTarget != finalTarget) { foreach (int source in sourceSet) { MiddleCode sourceCode = m_middleCodeList[source]; sourceCode[0] = finalTarget; } m_update = true; } } } }
// -------------------------------------------------------------------------- // 1. goto 2 // 2. ... private void ClearGotoNextStatements() { for (int index = 0; index < (m_middleCodeList.Count - 1); ++index) { MiddleCode middleCode = m_middleCodeList[index]; if (middleCode.IsRelationCarryOrGoto()) { int target = (int)middleCode[0]; if (target == (index + 1)) { middleCode.Clear(); m_update = true; } } } }