/// <summary> /// Checks whether this node has an outgoing predicate equal to <paramref name="key"/>. /// </summary> /// <param name="key">The node to check.</param> /// <returns>Whether this node has an outgoing predicate equal to <paramref name="key"/>.</returns> public bool ContainsKey(INode key) { if (key is null) { return(false); } return(PredicateNodes.Contains(key)); }
public override void Visit(StartNode node) { // Startnode is responcible for ignoring top-down programming // This is done by visiting the diffent global nodes in the correct order, to ensure that functions, predicate, and extend nodes // can see each other when the program is run the first time // This is very important because if this was not the case, predicates wouldnt be able to use extend attributes of classes. Global = true; /* Inspections order of AST nodes. VERY IMPORTANT * 1. Extend nodes * 2. Functions nodes * 3. Predicate node ( Makes it possible for Predicates to call functions, but this has been removed) * 4. Function bodies * 5. Predicate bodies */ SymbolTable.SetCurrentNode(node); List <AbstractNode> PredicateNodes; List <AbstractNode> FunctionNodes; // Visit all extend nodes as the first task node.Children.Where(x => x is ExtendNode).ToList().ForEach(x => x.Accept(this)); // Index all function nodes FunctionNodes = node.Children.Where(x => x is FunctionNode).ToList(); // Accept all the function nodes, so they can enter themselfes in the symboltable // Also to enter all the parameters into the symbol table FunctionNodes.ForEach(x => x.Accept(this)); // grab all predicate nodes, that are not in a function, and add them to a list PredicateNodes = node.Children.Where(x => x is PredicateNode).ToList(); var VariableNodes = node.Children.Where(x => x is VariableDclNode).ToList(); var GraphNodes = node.Children.Where(x => x is GraphNode).ToList(); // Accept them all, but dont acces their body GraphNodes.ForEach(x => (x as GraphNode).Global = true); GraphNodes.ForEach(x => x.Accept(this)); VariableNodes.ForEach(x => (x as VariableDclNode).Global = true); VariableNodes.ForEach(x => x.Accept(this)); PredicateNodes.ForEach(x => x.Accept(this)); // Now that everything is declared for both functions and predicates, Visit their body(children) _initialBuildDone = true; FunctionNodes.ForEach(x => VisitChildrenNewScope(x)); PredicateNodes.ForEach(x => VisitChildrenNewScope(x)); // Set initialBuildDone so predicates now will visit their children when visited inside functions //VisitChildren(node); SymbolTable.SymbolTableBuilderDone = true; }