1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

libexpr: Split out MakeBinOpMembers from MakeBinOp

This commit is contained in:
Sergei Zimmerman 2025-09-24 01:04:23 +03:00
parent 73d3ab05b6
commit e282175f48
No known key found for this signature in database

View file

@ -574,38 +574,41 @@ struct ExprOpNot : Expr
COMMON_METHODS COMMON_METHODS
}; };
#define MakeBinOp(name, s) \ #define MakeBinOpMembers(name, s) \
struct name : Expr \ PosIdx pos; \
{ \ Expr *e1, *e2; \
PosIdx pos; \ name(Expr * e1, Expr * e2) \
Expr *e1, *e2; \ : e1(e1) \
name(Expr * e1, Expr * e2) \ , e2(e2){}; \
: e1(e1) \ name(const PosIdx & pos, Expr * e1, Expr * e2) \
, e2(e2) {}; \ : pos(pos) \
name(const PosIdx & pos, Expr * e1, Expr * e2) \ , e1(e1) \
: pos(pos) \ , e2(e2){}; \
, e1(e1) \ void show(const SymbolTable & symbols, std::ostream & str) const override \
, e2(e2) {}; \ { \
void show(const SymbolTable & symbols, std::ostream & str) const override \ str << "("; \
{ \ e1->show(symbols, str); \
str << "("; \ str << " " s " "; \
e1->show(symbols, str); \ e2->show(symbols, str); \
str << " " s " "; \ str << ")"; \
e2->show(symbols, str); \ } \
str << ")"; \ void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override \
} \ { \
void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override \ e1->bindVars(es, env); \
{ \ e2->bindVars(es, env); \
e1->bindVars(es, env); \ } \
e2->bindVars(es, env); \ void eval(EvalState & state, Env & env, Value & v) override; \
} \ PosIdx getPos() const override \
void eval(EvalState & state, Env & env, Value & v) override; \ { \
PosIdx getPos() const override \ return pos; \
{ \
return pos; \
} \
} }
#define MakeBinOp(name, s) \
struct name : Expr \
{ \
MakeBinOpMembers(name, s) \
};
MakeBinOp(ExprOpEq, "=="); MakeBinOp(ExprOpEq, "==");
MakeBinOp(ExprOpNEq, "!="); MakeBinOp(ExprOpNEq, "!=");
MakeBinOp(ExprOpAnd, "&&"); MakeBinOp(ExprOpAnd, "&&");