nixd
|
#include <SemaActions.h>
Public Types | |
using | FormalVector = Formals::FormalVector |
Public Member Functions | |
Sema (std::string_view Src, std::vector< Diagnostic > &Diags) | |
void | checkFormalSep (const FormalVector &FV) |
Check if there is a seperator "," between formals. | |
void | checkFormalEllipsis (const FormalVector &FV) |
Check if ellipsis "...". | |
void | checkFormalEmpty (const FormalVector &FV) |
Diagnose empty formal i.e. single comma. | |
void | dedupFormal (std::map< std::string, const Formal * > &Dedup, const FormalVector &FV) |
Deduplicate formals. | |
std::shared_ptr< Formals > | onFormals (LexerCursorRange Range, FormalVector FV) |
void | dupAttr (std::string Name, LexerCursorRange Range, LexerCursorRange Prev) |
void | checkAttrRecursiveForMerge (const ExprAttrs &XAttrs, const ExprAttrs &YAttrs) |
Check if these two attrsets has the same "recursive" modifier. | |
void | mergeAttrSets (SemaAttrs &XAttrs, const SemaAttrs &YAttrs) |
Perform attrsets merging while duplicated fields are both attrsets. | |
void | insertAttr (SemaAttrs &SA, std::shared_ptr< AttrName > Name, std::shared_ptr< Expr > E, Attribute::AttributeKind Kind) |
SemaAttrs * | selectOrCreate (SemaAttrs &SA, const std::vector< std::shared_ptr< AttrName > > &Path) |
void | addAttr (SemaAttrs &Attr, const AttrPath &Path, std::shared_ptr< Expr > E) |
Insert the binding: AttrPath = E; into Attr . | |
void | lowerInheritName (SemaAttrs &SA, std::shared_ptr< AttrName > Name, std::shared_ptr< Expr > E, Attribute::AttributeKind InheritKind) |
void | lowerInherit (SemaAttrs &Attr, const Inherit &Inherit) |
void | lowerBinds (SemaAttrs &SA, const Binds &B) |
std::shared_ptr< ExprAttrs > | onExprAttrs (LexerCursorRange Range, std::shared_ptr< Binds > Binds, std::shared_ptr< Misc > Rec) |
std::shared_ptr< LambdaArg > | onLambdaArg (LexerCursorRange Range, std::shared_ptr< Identifier > ID, std::shared_ptr< Formals > F) |
Static Public Member Functions | |
static void | removeFormal (Fix &F, const FormalVector::const_iterator &Rm, const FormalVector &FV) |
Make text edits to remove a formal. | |
static std::pair< std::shared_ptr< Expr >, Attribute::AttributeKind > | desugarInheritExpr (std::shared_ptr< AttrName > Name, std::shared_ptr< Expr > E) |
Desugar inherit (expr) a, inherit a, into select, or variable. | |
Definition at line 16 of file SemaActions.h.
Definition at line 24 of file SemaActions.h.
|
inline |
Definition at line 21 of file SemaActions.h.
Insert the binding: AttrPath = E;
into Attr
.
Definition at line 155 of file SemaActions.cpp.
References insertAttr(), nixf::Attribute::Plain, and selectOrCreate().
Referenced by lowerBinds().
Check if these two attrsets has the same "recursive" modifier.
Official nix implementation implicitly discards the second modifier, this is somehow error-prone, let's detect it.
Definition at line 22 of file SemaActions.cpp.
References nixf::ExprAttrs::isRecursive(), nixf::Node::range(), and nixf::ExprAttrs::rec().
Referenced by insertAttr().
void nixf::Sema::checkFormalEllipsis | ( | const FormalVector & | FV | ) |
Check if ellipsis "...".
Definition at line 184 of file SemaActions.cpp.
References nixf::Formal::comma(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Formal::isEllipsis(), nixf::TextEdit::mkInsertion(), nixf::Node::range(), nixf::Node::rCur(), removeFormal(), and nixf::Node::src().
Referenced by onFormals().
void nixf::Sema::checkFormalEmpty | ( | const FormalVector & | FV | ) |
Diagnose empty formal i.e. single comma.
Definition at line 229 of file SemaActions.cpp.
References nixf::Formal::comma(), nixf::Fix::edit(), nixf::Faded, nixf::Diagnostic::fix(), nixf::Formal::id(), nixf::Formal::isEllipsis(), nixf::TextEdit::mkRemoval(), nixf::Node::range(), and nixf::PartialDiagnostic::tag().
Referenced by onFormals().
void nixf::Sema::checkFormalSep | ( | const FormalVector & | FV | ) |
Check if there is a seperator "," between formals.
Definition at line 215 of file SemaActions.cpp.
References nixf::Formal::comma(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Node::lCur(), nixf::TextEdit::mkInsertion(), and nixf::Node::range().
Referenced by onFormals().
void nixf::Sema::dedupFormal | ( | std::map< std::string, const Formal * > & | Dedup, |
const FormalVector & | FV ) |
Deduplicate formals.
Definition at line 251 of file SemaActions.cpp.
References nixf::Formal::id(), nixf::Identifier::name(), nixf::Diagnostic::note(), and nixf::Node::range().
Referenced by onFormals().
|
static |
Desugar inherit (expr) a, inherit a, into select, or variable.
Definition at line 337 of file SemaActions.cpp.
References nixf::Attribute::Inherit, and nixf::Attribute::InheritFrom.
Referenced by lowerInherit().
void nixf::Sema::dupAttr | ( | std::string | Name, |
LexerCursorRange | Range, | ||
LexerCursorRange | Prev ) |
Definition at line 15 of file SemaActions.cpp.
Referenced by insertAttr(), lowerInheritName(), mergeAttrSets(), and selectOrCreate().
void nixf::Sema::insertAttr | ( | SemaAttrs & | SA, |
std::shared_ptr< AttrName > | Name, | ||
std::shared_ptr< Expr > | E, | ||
Attribute::AttributeKind | Kind ) |
Definition at line 67 of file SemaActions.cpp.
References checkAttrRecursiveForMerge(), dupAttr(), and mergeAttrSets().
Referenced by addAttr().
Definition at line 316 of file SemaActions.cpp.
References addAttr(), nixf::Binds::bindings(), and lowerInherit().
Referenced by onExprAttrs().
Definition at line 308 of file SemaActions.cpp.
References desugarInheritExpr(), nixf::Inherit::expr(), lowerInheritName(), and nixf::Inherit::names().
Referenced by lowerBinds().
void nixf::Sema::lowerInheritName | ( | SemaAttrs & | SA, |
std::shared_ptr< AttrName > | Name, | ||
std::shared_ptr< Expr > | E, | ||
Attribute::AttributeKind | InheritKind ) |
Definition at line 282 of file SemaActions.cpp.
References dupAttr(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::TextEdit::mkRemoval(), nixf::Attribute::Plain, nixf::Striked, and nixf::PartialDiagnostic::tag().
Referenced by lowerInherit().
Perform attrsets merging while duplicated fields are both attrsets.
e.g.
We may want to merge both "a = " attrsets into a single one, instead of report duplicating attrs.
Definition at line 42 of file SemaActions.cpp.
References dupAttr().
Referenced by insertAttr().
std::shared_ptr< ExprAttrs > nixf::Sema::onExprAttrs | ( | LexerCursorRange | Range, |
std::shared_ptr< Binds > | Binds, | ||
std::shared_ptr< Misc > | Rec ) |
Definition at line 352 of file SemaActions.cpp.
References lowerBinds().
Referenced by nixf::Parser::parseExprAttrs(), and nixf::Parser::parseExprLet().
std::shared_ptr< Formals > nixf::Sema::onFormals | ( | LexerCursorRange | Range, |
FormalVector | FV ) |
Definition at line 272 of file SemaActions.cpp.
References checkFormalEllipsis(), checkFormalEmpty(), checkFormalSep(), and dedupFormal().
Referenced by nixf::Parser::parseFormals().
std::shared_ptr< LambdaArg > nixf::Sema::onLambdaArg | ( | LexerCursorRange | Range, |
std::shared_ptr< Identifier > | ID, | ||
std::shared_ptr< Formals > | F ) |
Definition at line 362 of file SemaActions.cpp.
References nixf::Diagnostic::note().
Referenced by nixf::Parser::parseLambdaArg().
|
static |
Make text edits to remove a formal.
Definition at line 170 of file SemaActions.cpp.
References nixf::Formal::comma(), nixf::Fix::edit(), nixf::TextEdit::mkRemoval(), and nixf::Node::range().
Referenced by checkFormalEllipsis().
SemaAttrs * nixf::Sema::selectOrCreate | ( | SemaAttrs & | SA, |
const std::vector< std::shared_ptr< AttrName > > & | Path ) |
Select into Attr
the attribute specified by Path
, or create one if not exists, until reached the inner-most attr. Similar to mkdir -p
.
Definition at line 104 of file SemaActions.cpp.
References dupAttr(), and nixf::Attribute::Plain.
Referenced by addAttr().