protected override IStatement ConvertWhile(IWhileStatement iws) { IStatement st = base.ConvertWhile(iws); InitializerSet initSet = context.InputAttributes.Get <InitializerSet>(iws); if (initSet != null) { // initializers occur in the loop, so all replacements should already be known. initSet.Replace(replacements); } return(st); }
protected override IStatement DoConvertStatement(IStatement ist) { if (ist is IWhileStatement) { IWhileStatement iws = (IWhileStatement)ist; if (whileCount == 0) { replacements.Clear(); } whileCount++; IStatement convertedSt = ConvertWhile(iws); whileCount--; if (replacements.Count > 0) { InitializerSet initializerSet = context.InputAttributes.Get <InitializerSet>(iws); if (initializerSet != null) { initializerSet.Replace(replacements); } } return(convertedSt); } else if (isInnerStatement) { return(ist); } else if (context.InputAttributes.Has <FirstIterationPostProcessingBlock>(ist)) { return(base.DoConvertStatement(ist)); } else if (!previousStatements.Contains(ist)) { previousStatements.Add(ist); return(ist); } else { this.ShallowCopy = true; isInnerStatement = true; IStatement convertedSt = base.DoConvertStatement(ist); isInnerStatement = false; this.ShallowCopy = false; AddClone(ist, convertedSt); loopMergingInfo.AddEquivalentStatement(convertedSt, loopMergingInfo.GetIndexOf(ist)); return(convertedSt); } }