private void BuildDUC( ) { foreach (var v in GVarsDecl) { v.DucAssignments.Data.Clear( ); v.DucReferences.Data.Clear( ); } foreach (var block in Blocks) { GVarsUsed.UnionWith(block.Vars); foreach (var stmt in block.GStatements) { if (stmt is GAssignStmt || stmt is GPhiStmt || stmt is GOptimizedStmt) { UsedToDeclMap[stmt.Vars[0]].DucAssignments.Add(block.Number, stmt.Linenum); for (int i = 1; i < stmt.Vars.Count; ++i) { UsedToDeclMap[stmt.Vars[i]].DucReferences.Add(block.Number, stmt.Linenum); } } else { foreach (var v in stmt.Vars) { UsedToDeclMap[v].DucReferences.Add(block.Number, stmt.Linenum); } } } } }
private void GetVarsUsed( ) { GVarsUsed.Clear( ); foreach (var block in Blocks) { GVarsUsed.UnionWith(block.Vars); } }
public void Rename(string oldName, string newName) { Blocks.ForEach(b => b.Rename(oldName, newName)); if (GVarsDecl.Count(v => v.Name == oldName) != 0) { GVarsDecl.Where(v => v.Name == oldName).FirstOrDefault( ).Name = UsedToDeclMap.ContainsKey(newName) ? UsedToDeclMap[newName].Name : newName; } GVarsDecl = new HashSet <GVar> (GVarsDecl); if (GVarsUsed.Remove(oldName)) { GVarsUsed.Add(newName); if (UsedToDeclMap.ContainsKey(oldName)) { UsedToDeclMap[newName] = UsedToDeclMap[oldName]; UsedToDeclMap.Remove(oldName); } } }