public void ReplaceDependant(string toReplace, DependencyGraphNode newNode) { DependencyGraphNode replacing = SearchDependant(toReplace); for (int i=0; i<CountDependants(); i++) { ((DependencyGraphNode)dependants[i]).ReplaceCalledBy(replacing, newNode); } RemoveDependant(replacing); }
public void AddCallsBy(DependencyGraphNode func) { if (func == null) return; for (int i=0; i<calledBy.Count; i++) { if (func == calledBy[i]) return; } calledBy.Add(func); }
public void ReplaceCalledBy(DependencyGraphNode toReplace, DependencyGraphNode newOne) { for (int i=0; i<calledBy.Count; i++) { if (toReplace == calledBy[i]) { calledBy.Remove(toReplace); if (newOne != null) calledBy.Add(newOne); return; } } }
public DependencyGraphNode SearchDependant(string dependantName) { DependencyGraphNode tmp; for (int i=0; i<dependants.Count; i++) { tmp = (DependencyGraphNode) dependants[i]; if (tmp.GetDependencyName().Equals(dependantName)) return tmp; } DependencyGraphNode novo = new DependencyGraphNode(dependantName); dependants.Add(novo); return novo; }
public override Node ExitFunctionOrVariableDeclaration(Production node) { DependencyGraphNode antiga = dependencyGraph.SearchDependant(((Token)GrammaticaNodeUtils.FindChildOf(node, "IDENTIFIER")).GetImage()); // se a função já existir if (antiga != null) { // trocar a nova pela n em todo o grafo. dependencyGraph.ReplaceDependant("Nova Função", antiga); } else { dependencyGraph.SearchDependant("Nova Função").SetDependencyName(((Token)GrammaticaNodeUtils.FindChildOf(node, "IDENTIFIER")).GetImage()); } functionScope = null; if (((Token)GrammaticaNodeUtils.FindChildOf(node, "IDENTIFIER")).GetImage().Equals(activeMainFunction)) { RemoveTypeFromMain(node); } scopeVars = new ArrayList(); replaceIdentifier = new Hashtable(); return node; }
/** * Creates a Graph of function calls to decide to what file goes each * function when the HLSL have more than one main function. */ public override void EnterFunctionOrVariableDeclaration(Production node) { functionScope = new DependencyGraphNode("Nova Função"); dependencyGraph.AddDependant(functionScope); scopeVars = new ArrayList(); replaceIdentifier = new Hashtable(); }
public void RemoveDependant(DependencyGraphNode dep) { dependants.Remove(dep); }
public void AddDependant(DependencyGraphNode dep) { dependants.Add(dep); }