Lines Matching refs:NodeId

40     SrcToDst = std::make_unique<NodeId[]>(Size);  in Mapping()
41 DstToSrc = std::make_unique<NodeId[]>(Size); in Mapping()
44 void link(NodeId Src, NodeId Dst) { in link()
48 NodeId getDst(NodeId Src) const { return SrcToDst[Src]; } in getDst()
49 NodeId getSrc(NodeId Dst) const { return DstToSrc[Dst]; } in getSrc()
50 bool hasSrc(NodeId Src) const { return getDst(Src).isValid(); } in hasSrc()
51 bool hasDst(NodeId Dst) const { return getSrc(Dst).isValid(); } in hasDst()
54 std::unique_ptr<NodeId[]> SrcToDst, DstToSrc;
72 NodeId getMapped(const std::unique_ptr<SyntaxTree::Impl> &Tree, in getMapped()
73 NodeId Id) const { in getMapped()
82 bool identical(NodeId Id1, NodeId Id2) const;
85 bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
88 bool haveSameParents(const Mapping &M, NodeId Id1, NodeId Id2) const;
92 void addOptimalMapping(Mapping &M, NodeId Id1, NodeId Id2) const;
96 double getJaccardSimilarity(const Mapping &M, NodeId Id1, NodeId Id2) const;
99 NodeId findCandidate(const Mapping &M, NodeId Id1) const;
133 std::vector<NodeId> Leaves;
136 std::vector<NodeId> NodesBfs;
139 NodeId getRootId() const { return 0; } in getRootId()
143 const Node &getNode(NodeId Id) const { return Nodes[Id]; } in getNode()
144 Node &getMutableNode(NodeId Id) { return Nodes[Id]; } in getMutableNode()
145 bool isValidNodeId(NodeId Id) const { return Id >= 0 && Id < getSize(); } in isValidNodeId()
147 int getNumberOfDescendants(NodeId Id) const;
148 bool isInSubtree(NodeId Id, NodeId SubtreeRoot) const;
149 int findPositionInParent(NodeId Id, bool Shifted = false) const;
155 std::string getNodeValue(NodeId Id) const;
191 NodeId Parent;
196 template <class T> std::tuple<NodeId, NodeId> PreTraverse(T *ASTNode) { in PreTraverse()
197 NodeId MyId = Id; in PreTraverse()
214 void PostTraverse(std::tuple<NodeId, NodeId> State) { in PostTraverse()
215 NodeId MyId, PreviousParent; in PostTraverse()
228 for (NodeId Child : N.Children) in PostTraverse()
280 static std::vector<NodeId> getSubtreePostorder(const SyntaxTree::Impl &Tree, in getSubtreePostorder()
281 NodeId Root) { in getSubtreePostorder()
282 std::vector<NodeId> Postorder; in getSubtreePostorder()
283 std::function<void(NodeId)> Traverse = [&](NodeId Id) { in getSubtreePostorder()
285 for (NodeId Child : N.Children) in getSubtreePostorder()
293 static std::vector<NodeId> getSubtreeBfs(const SyntaxTree::Impl &Tree, in getSubtreeBfs()
294 NodeId Root) { in getSubtreeBfs()
295 std::vector<NodeId> Ids; in getSubtreeBfs()
299 for (NodeId Child : Tree.getNode(Ids[Expanded++]).Children) in getSubtreeBfs()
308 std::function<void(NodeId)> PostorderTraverse = [&](NodeId Id) { in initTree()
309 for (NodeId Child : getNode(Id).Children) in initTree()
319 for (NodeId Leaf : Leaves) { in setLeftMostDescendants()
321 NodeId Parent, Cur = Leaf; in setLeftMostDescendants()
330 int SyntaxTree::Impl::getNumberOfDescendants(NodeId Id) const { in getNumberOfDescendants()
334 bool SyntaxTree::Impl::isInSubtree(NodeId Id, NodeId SubtreeRoot) const { in isInSubtree()
338 int SyntaxTree::Impl::findPositionInParent(NodeId Id, bool Shifted) const { in findPositionInParent()
339 NodeId Parent = getNode(Id).Parent; in findPositionInParent()
408 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const { in getNodeValue()
490 std::vector<NodeId> RootIds;
497 Subtree(const SyntaxTree::Impl &Tree, NodeId SubtreeRoot) : Tree(Tree) { in Subtree()
503 NodeId getIdInRoot(SNodeId Id) const { in getIdInRoot()
515 NodeId getPostorderOffset() const { in getPostorderOffset()
566 const SyntaxTree::Impl &T2, NodeId Id1, NodeId Id2) in ZhangShashaMatcher()
578 std::vector<std::pair<NodeId, NodeId>> getMatchingNodes() { in getMatchingNodes()
579 std::vector<std::pair<NodeId, NodeId>> Matches; in getMatchingNodes()
617 NodeId Id1 = S1.getIdInRoot(Row); in getMatchingNodes()
618 NodeId Id2 = S2.getIdInRoot(Col); in getMatchingNodes()
711 bool operator()(NodeId Id1, NodeId Id2) const { in operator ()()
722 std::vector<NodeId> Container;
723 PriorityQueue<NodeId, std::vector<NodeId>, HeightLess> List;
729 void push(NodeId id) { List.push(id); } in push()
731 std::vector<NodeId> pop() { in pop()
733 std::vector<NodeId> Result; in pop()
749 void open(NodeId Id) { in open()
750 for (NodeId Child : Tree.getNode(Id).Children) in open()
756 bool ASTDiff::Impl::identical(NodeId Id1, NodeId Id2) const { in identical()
769 bool ASTDiff::Impl::isMatchingPossible(NodeId Id1, NodeId Id2) const { in isMatchingPossible()
773 bool ASTDiff::Impl::haveSameParents(const Mapping &M, NodeId Id1, in haveSameParents()
774 NodeId Id2) const { in haveSameParents()
775 NodeId P1 = T1.getNode(Id1).Parent; in haveSameParents()
776 NodeId P2 = T2.getNode(Id2).Parent; in haveSameParents()
781 void ASTDiff::Impl::addOptimalMapping(Mapping &M, NodeId Id1, in addOptimalMapping()
782 NodeId Id2) const { in addOptimalMapping()
787 std::vector<std::pair<NodeId, NodeId>> R = Matcher.getMatchingNodes(); in addOptimalMapping()
789 NodeId Src = Tuple.first; in addOptimalMapping()
790 NodeId Dst = Tuple.second; in addOptimalMapping()
796 double ASTDiff::Impl::getJaccardSimilarity(const Mapping &M, NodeId Id1, in getJaccardSimilarity()
797 NodeId Id2) const { in getJaccardSimilarity()
801 for (NodeId Src = Id1 + 1; Src <= N1.RightMostDescendant; ++Src) { in getJaccardSimilarity()
802 NodeId Dst = M.getDst(Src); in getJaccardSimilarity()
815 NodeId ASTDiff::Impl::findCandidate(const Mapping &M, NodeId Id1) const { in findCandidate()
816 NodeId Candidate; in findCandidate()
818 for (NodeId Id2 : T2) { in findCandidate()
833 std::vector<NodeId> Postorder = getSubtreePostorder(T1, T1.getRootId()); in matchBottomUp()
834 for (NodeId Id1 : Postorder) { in matchBottomUp()
846 N1.Children, [&](NodeId Child) { return M.hasSrc(Child); }); in matchBottomUp()
849 NodeId Id2 = findCandidate(M, Id1); in matchBottomUp()
870 for (NodeId Id : L1.pop()) in matchTopDown()
875 for (NodeId Id : L2.pop()) in matchTopDown()
879 std::vector<NodeId> H1, H2; in matchTopDown()
882 for (NodeId Id1 : H1) { in matchTopDown()
883 for (NodeId Id2 : H2) { in matchTopDown()
890 for (NodeId Id1 : H1) { in matchTopDown()
894 for (NodeId Id2 : H2) { in matchTopDown()
917 for (NodeId Id1 : T1) { in computeChangeKinds()
923 for (NodeId Id2 : T2) { in computeChangeKinds()
929 for (NodeId Id1 : T1.NodesBfs) { in computeChangeKinds()
930 NodeId Id2 = M.getDst(Id1); in computeChangeKinds()
940 for (NodeId Id2 : T2.NodesBfs) { in computeChangeKinds()
941 NodeId Id1 = M.getSrc(Id2); in computeChangeKinds()
965 NodeId ASTDiff::getMapped(const SyntaxTree &SourceTree, NodeId Id) const { in getMapped()
977 const Node &SyntaxTree::getNode(NodeId Id) const { in getNode()
982 NodeId SyntaxTree::getRootId() const { return TreeImpl->getRootId(); } in getRootId()
988 int SyntaxTree::findPositionInParent(NodeId Id) const { in findPositionInParent()
1008 std::string SyntaxTree::getNodeValue(NodeId Id) const { in getNodeValue()