|
nixd
|
#include <VariableLookup.h>
Classes | |
| struct | LookupResult |
Public Types | |
| enum class | LookupResultKind { Undefined , FromWith , Defined , NoSuchVar } |
| using | ToDefMap = std::map<const Node *, std::shared_ptr<Definition>> |
| using | EnvMap = std::map<const Node *, std::shared_ptr<EnvNode>> |
Public Member Functions | |
| VariableLookupAnalysis (std::vector< Diagnostic > &Diags) | |
| void | runOnAST (const Node &Root) |
| Perform variable lookup analysis (def-use) on AST. | |
| LookupResult | query (const ExprVar &Var) const |
| Query the which name/with binds to specific varaible. | |
| const Definition * | toDef (const Node &N) const |
| Get definition record for some name. | |
| const EnvNode * | env (const Node *N) const |
| std::vector< const ExprWith * > | getWithScopes (const ExprVar &Var) const |
| Get all with expressions that could provide the binding for a variable. | |
Definition at line 112 of file VariableLookup.h.
| using nixf::VariableLookupAnalysis::EnvMap = std::map<const Node *, std::shared_ptr<EnvNode>> |
Definition at line 127 of file VariableLookup.h.
| using nixf::VariableLookupAnalysis::ToDefMap = std::map<const Node *, std::shared_ptr<Definition>> |
Definition at line 126 of file VariableLookup.h.
|
strong |
| Enumerator | |
|---|---|
| Undefined | |
| FromWith | |
| Defined | |
| NoSuchVar | |
Definition at line 114 of file VariableLookup.h.
| VariableLookupAnalysis::VariableLookupAnalysis | ( | std::vector< Diagnostic > & | Diags | ) |
Definition at line 514 of file VariableLookup.cpp.
Definition at line 517 of file VariableLookup.cpp.
Referenced by nixd::upEnv().
|
inlinenodiscard |
Get all with expressions that could provide the binding for a variable.
For variables resolved from with scopes, multiple enclosing with expressions may potentially provide the binding. This method returns all such with expressions, ordered from innermost to outermost.
This is useful for detecting indirect nested with scenarios where converting an outer with to let/inherit could change semantics.
| Var | The variable to query. |
Definition at line 223 of file VariableLookup.h.
|
inlinenodiscard |
Query the which name/with binds to specific varaible.
Definition at line 182 of file VariableLookup.h.
References NoSuchVar.
Referenced by nixd::addToFormalsAction(), and nixd::idioms::mkVarSelector().
| void VariableLookupAnalysis::runOnAST | ( | const Node & | Root | ) |
Perform variable lookup analysis (def-use) on AST.
Definition at line 491 of file VariableLookup.cpp.
References nixf::PrimOpsInfo.
Referenced by main().
|
inlinenodiscard |
Get definition record for some name.
For some cases, we need to get "definition" record to find all references to this definition, on AST.
Thus we need to store AST -> Definition There are many pointers on AST, the convention is:
"with" keyword is recorded.
Definition at line 200 of file VariableLookup.h.