nixd
Loading...
Searching...
No Matches
libnixf/include/nixf/Sema/ParentMap.h
Go to the documentation of this file.
1/// \file
2/// \brief ParentMap analysis.
3///
4/// This is used to construct upward edges. For each node, record it's direct
5/// parent. (Abstract Syntax TREE only have one parent for each node).
6
7#pragma once
8
10
11#include <map>
12
13namespace nixf {
14
16 std::map<const Node *, const Node *> ParentMap;
17
18 void dfs(const Node *N, const Node *Parent);
19
20public:
21 void runOnAST(const Node &Root);
22
23 [[nodiscard]] const Node *query(const Node &N) const;
24
25 static bool isRoot(const Node *Up, const Node &N);
26
27 /// \brief Search up until the node becomes a concrete expression.
28 /// a
29 /// ^<----- ID -> ExprVar
30 [[nodiscard]] const Node *upExpr(const Node &N) const;
31
32 /// \brief Search up until some kind of node is found.
33 [[nodiscard]] const Node *upTo(const Node &N, Node::NodeKind Kind) const;
34
35 [[nodiscard]] bool isRoot(const Node &N) const;
36};
37
38} // namespace nixf
const Node * upExpr(const Node &N) const
Search up until the node becomes a concrete expression. a ^<--— ID -> ExprVar.
static bool isRoot(const Node *Up, const Node &N)
const Node * upTo(const Node &N, Node::NodeKind Kind) const
Search up until some kind of node is found.
const Node * query(const Node &N) const