diff --git a/nixd/include/nixd/Sema/Lowering.h b/nixd/include/nixd/Sema/Lowering.h index 906bbf356..9cdc367d3 100644 --- a/nixd/include/nixd/Sema/Lowering.h +++ b/nixd/include/nixd/Sema/Lowering.h @@ -36,8 +36,8 @@ struct Lowering { std::vector &Diags; EvalContext &Ctx; - nix::Expr *lower(syntax::Node *Root); - nix::ExprLambda *lowerFunction(syntax::Function *Fn); + nix::Expr *lower(const syntax::Node *Root); + nix::ExprLambda *lowerFunction(const syntax::Function *Fn); nix::Formal lowerFormal(const syntax::Formal &Formal); nix::AttrPath lowerAttrPath(const syntax::AttrPath &Path); nix::ExprAttrs *lowerBinds(const syntax::Binds &Binds); diff --git a/nixd/lib/Sema/Lowering.cpp b/nixd/lib/Sema/Lowering.cpp index 661b89756..9dc197dc6 100644 --- a/nixd/lib/Sema/Lowering.cpp +++ b/nixd/lib/Sema/Lowering.cpp @@ -21,7 +21,7 @@ nix::Formal Lowering::lowerFormal(const syntax::Formal &Formal) { return F; } -nix::ExprLambda *Lowering::lowerFunction(syntax::Function *Fn) { +nix::ExprLambda *Lowering::lowerFunction(const syntax::Function *Fn) { // Implementation note: // The official parser does this in the semantic action, and we deferred it // here, as a part of the progressive lowering process. @@ -218,17 +218,17 @@ nix::ExprAttrs *Lowering::lowerBinds(const syntax::Binds &Binds) { return Builder.finish(); } -nix::Expr *Lowering::lower(nixd::syntax::Node *Root) { +nix::Expr *Lowering::lower(const nixd::syntax::Node *Root) { if (!Root) return nullptr; switch (Root->getKind()) { case Node::NK_Function: { - auto *Fn = dynamic_cast(Root); + const auto *Fn = dynamic_cast(Root); return lowerFunction(Fn); } case Node::NK_Assert: { - auto *Assert = dynamic_cast(Root); + const auto *Assert = dynamic_cast(Root); auto *Cond = lower(Assert->Cond); auto *Body = lower(Assert->Body); auto *NixAssert = @@ -236,7 +236,7 @@ nix::Expr *Lowering::lower(nixd::syntax::Node *Root) { return NixAssert; } case Node::NK_With: { - auto *With = dynamic_cast(Root); + const auto *With = dynamic_cast(Root); auto *Attrs = lower(With->Attrs); auto *Body = lower(With->Body); auto *NixWith = @@ -244,11 +244,11 @@ nix::Expr *Lowering::lower(nixd::syntax::Node *Root) { return NixWith; } case Node::NK_Binds: { - auto *Binds = dynamic_cast(Root); + const auto *Binds = dynamic_cast(Root); return lowerBinds(*Binds); } case Node::NK_AttrSet: { - auto *AttrSet = dynamic_cast(Root); + const auto *AttrSet = dynamic_cast(Root); assert(AttrSet->AttrBinds && "null AttrBinds of the AttrSet!"); nix::ExprAttrs *Binds = lowerBinds(*AttrSet->AttrBinds); Binds->recursive = AttrSet->Recursive;