nixd
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
nixf::VariableLookupAnalysis Class Reference

#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 DefinitiontoDef (const Node &N) const
 Get definition record for some name.
 
const EnvNodeenv (const Node *N) const
 

Detailed Description

Definition at line 112 of file VariableLookup.h.

Member Typedef Documentation

◆ EnvMap

using nixf::VariableLookupAnalysis::EnvMap = std::map<const Node *, std::shared_ptr<EnvNode>>

Definition at line 127 of file VariableLookup.h.

◆ ToDefMap

using nixf::VariableLookupAnalysis::ToDefMap = std::map<const Node *, std::shared_ptr<Definition>>

Definition at line 126 of file VariableLookup.h.

Member Enumeration Documentation

◆ LookupResultKind

Enumerator
Undefined 
FromWith 
Defined 
NoSuchVar 

Definition at line 114 of file VariableLookup.h.

Constructor & Destructor Documentation

◆ VariableLookupAnalysis()

VariableLookupAnalysis::VariableLookupAnalysis ( std::vector< Diagnostic > & Diags)

Definition at line 472 of file VariableLookup.cpp.

Member Function Documentation

◆ env()

const EnvNode * VariableLookupAnalysis::env ( const Node * N) const

Definition at line 475 of file VariableLookup.cpp.

Referenced by nixd::upEnv().

◆ query()

LookupResult nixf::VariableLookupAnalysis::query ( const ExprVar & Var) const
inline

Query the which name/with binds to specific varaible.

Definition at line 174 of file VariableLookup.h.

References nixf::VariableLookupAnalysis::LookupResult::Kind, and NoSuchVar.

Referenced by nixd::idioms::mkVarSelector().

◆ runOnAST()

void VariableLookupAnalysis::runOnAST ( const Node & Root)

Perform variable lookup analysis (def-use) on AST.

Note
This method should be invoked after any other method called.
The result remains immutable thus it can be shared among threads.

Definition at line 341 of file VariableLookup.cpp.

Referenced by main().

◆ toDef()

const Definition * nixf::VariableLookupAnalysis::toDef ( const Node & N) const
inline

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:

  1. attrname "key" syntax is recorded.

"with" keyword is recorded.

  1. Lambda arguments, record its identifier.

Definition at line 192 of file VariableLookup.h.


The documentation for this class was generated from the following files: