internal void UpdateModifiedNodes() { IEnumerable iter = nodesToModify; List <uint> nodesRemoved = new List <uint>(); List <SnapshotNode> hasUndefinedVariableNodes = new List <SnapshotNode>(); //Tron's #if TESTING_COMPARE List <List <string> > oldNodeContent = new List <List <string> >(); foreach (SnapshotNode modifiedNode in nodesToModify) { List <string> checkEmptyContent = new List <string>(); if (gc.codeBlockUIDMap.ContainsKey(modifiedNode.Id)) { foreach (KeyValuePair <int, uint> kvp in gc.codeBlockUIDMap[modifiedNode.Id]) { if (gc.Graph.GetNode(kvp.Value) is Statement) { checkEmptyContent.Add(gc.Graph.GetNode(kvp.Value).Name); } } } else { if (gc.Graph.GetNode(modifiedNode.Id) is Statement) { checkEmptyContent.Add(gc.Graph.GetNode(modifiedNode.Id).Name); } } oldNodeContent.Add(checkEmptyContent); } #endif foreach (SnapshotNode node in iter) { if (node.Type == SnapshotNodeType.CodeBlock) { // Get all guids associated with the main codeblocks' guid Dictionary <int, uint> slotUIDMap = new Dictionary <int, uint>(); if (gc.codeBlockUIDMap.TryGetValue(node.Id, out slotUIDMap)) { foreach (KeyValuePair <int, uint> slotUID in slotUIDMap) { nodesRemoved.Add(slotUID.Value); } gc.codeBlockUIDMap.Remove(node.Id); } else { nodesRemoved.Add(node.Id); } } else { nodesRemoved.Add(node.Id); } if (node.UndefinedVariables != null) { hasUndefinedVariableNodes.Add(node); } } bool removeFromRemovedNodes = false; RemoveNodes(nodesRemoved, removeFromRemovedNodes); AddNodesToAST(nodesToModify); #if TESTING_COMPARE List <List <KeyValuePair <uint, string> > > newNodeContents = new List <List <KeyValuePair <uint, string> > >(); foreach (SnapshotNode ssn in nodesToModify) { List <KeyValuePair <uint, string> > temp = new List <KeyValuePair <uint, string> >(); if (gc.codeBlockUIDMap.ContainsKey(ssn.Id)) { foreach (KeyValuePair <int, uint> kvp in gc.codeBlockUIDMap[ssn.Id]) { if (gc.Graph.GetNode(kvp.Value) is Statement) { temp.Add(new KeyValuePair <uint, string>(kvp.Value, gc.Graph.GetNode(kvp.Value).Name)); } } } else { if (gc.Graph.GetNode(ssn.Id) is Statement) { temp.Add(new KeyValuePair <uint, string>(ssn.Id, gc.Graph.GetNode(ssn.Id).Name)); } } newNodeContents.Add(temp); } bool proceed = true; for (int i = 0; i < newNodeContents.Count; i++) { if (newNodeContents[i].Count != oldNodeContent[i].Count) { proceed = false; } } if (proceed) { for (int i = 0; i < newNodeContents.Count; i++) { if (oldNodeContent[i].Count == 0) { continue; } for (int j = 0; j < newNodeContents[i].Count; j++) { if (!GraphUtilities.CompareCode(oldNodeContent[i][j], newNodeContents[i][j].Value)) { Node modified = gc.Graph.GetNode(newNodeContents[i][j].Key); if (modified is Statement) { (modified as Statement).wasModified = true; } } } } } #endif MakeConnectionsForAddedNodes(nodesToModify); gc.ResetUndefinedVariables(); foreach (var node in hasUndefinedVariableNodes) { // @keyu: undefined variables are those variables that were // defined in last run but were undefined in this run, so we // need to nullify these varaibles. Add them to graph // compiler's UndefinedNameList and later on graph compiler // will generate null assignment statements for them. gc.UndefineVariablesForNodes(node.UndefinedVariables, node.Id); } }