diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index bc53ca053..2d36f21b9 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -581,6 +581,146 @@ std::string ExprLambda::showNamePos(const EvalState & state) const } +std::string_view Expr::kind() const +{ + return "abstract"; +} + +std::string_view ExprInt::kind() const +{ + return "int"; +} + +std::string_view ExprFloat::kind() const +{ + return "float"; +} + +std::string_view ExprString::kind() const +{ + return "string"; +} + +std::string_view ExprPath::kind() const +{ + return "path"; +} + +std::string_view ExprVar::kind() const +{ + return "var"; +} + +std::string_view ExprInheritFrom::kind() const +{ + return "inherit from"; +} + +std::string_view ExprSelect::kind() const +{ + return "select"; +} + +std::string_view ExprOpHasAttr::kind() const +{ + return "hasattr operator"; +} + +std::string_view ExprAttrs::kind() const +{ + return "attrs"; +} + +std::string_view ExprList::kind() const +{ + return "list"; +} + +std::string_view ExprLambda::kind() const +{ + return "lambda"; +} + +std::string_view ExprCall::kind() const +{ + return "call"; +} + +std::string_view ExprLet::kind() const +{ + return "let"; +} + +std::string_view ExprWith::kind() const +{ + return "with"; +} + +std::string_view ExprIf::kind() const +{ + return "if"; +} + +std::string_view ExprAssert::kind() const +{ + return "assert"; +} + +std::string_view ExprOpNot::kind() const +{ + return "not operator"; +} + +std::string_view ExprOpEq::kind() const +{ + return "equality operator"; +} + +std::string_view ExprOpNEq::kind() const +{ + return "inequality operator"; +} + +std::string_view ExprOpAnd::kind() const +{ + return "logical AND operator"; +} + +std::string_view ExprOpOr::kind() const +{ + return "logical OR operator"; +} + +std::string_view ExprOpImpl::kind() const +{ + return "logical implication operator"; +} + +std::string_view ExprOpUpdate::kind() const +{ + return "update operator"; +} + +std::string_view ExprOpConcatLists::kind() const +{ + return "list concatenation operator"; +} + +std::string_view ExprConcatStrings::kind() const +{ + return "string concatenation"; +} + +std::string_view ExprPos::kind() const +{ + return "position"; +} + +std::string_view ExprBlackHole::kind() const +{ + return "blackhole"; +} + /* Position table. */ diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 418f888b3..be367585c 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -63,12 +63,15 @@ public: virtual Value * maybeThunk(EvalState & state, Env & env); virtual void setName(Symbol name); virtual PosIdx getPos() const { return noPos; } + /** Entirely for debugging. */ + virtual std::string_view kind() const; }; #define COMMON_METHODS \ void show(const SymbolTable & symbols, std::ostream & str) const override; \ void eval(EvalState & state, Env & env, Value & v) override; \ - void bindVars(EvalState & es, const std::shared_ptr & env) override; + void bindVars(EvalState & es, const std::shared_ptr & env) override; \ + virtual std::string_view kind() const override; struct ExprInt : Expr { @@ -151,7 +154,8 @@ struct ExprInheritFrom : ExprVar this->fromWith = nullptr; } - void bindVars(EvalState & es, const std::shared_ptr & env); + void bindVars(EvalState & es, const std::shared_ptr & env) override; + std::string_view kind() const override; }; struct ExprSelect : Expr @@ -418,6 +422,7 @@ struct ExprOpNot : Expr } \ void eval(EvalState & state, Env & env, Value & v) override; \ PosIdx getPos() const override { return pos; } \ + std::string_view kind() const override; \ }; MakeBinOp(ExprOpEq, "==") @@ -453,6 +458,7 @@ struct ExprBlackHole : Expr void show(const SymbolTable & symbols, std::ostream & str) const override {} void eval(EvalState & state, Env & env, Value & v) override; void bindVars(EvalState & es, const std::shared_ptr & env) override {} + std::string_view kind() const override; }; extern ExprBlackHole eBlackHole;