1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 12:06: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,18 +574,16 @@ struct ExprOpNot : Expr
COMMON_METHODS COMMON_METHODS
}; };
#define MakeBinOp(name, s) \ #define MakeBinOpMembers(name, s) \
struct name : Expr \
{ \
PosIdx pos; \ PosIdx pos; \
Expr *e1, *e2; \ Expr *e1, *e2; \
name(Expr * e1, Expr * e2) \ name(Expr * e1, Expr * e2) \
: e1(e1) \ : e1(e1) \
, e2(e2) {}; \ , e2(e2){}; \
name(const PosIdx & pos, Expr * e1, Expr * e2) \ name(const PosIdx & pos, Expr * e1, Expr * e2) \
: pos(pos) \ : pos(pos) \
, e1(e1) \ , e1(e1) \
, e2(e2) {}; \ , e2(e2){}; \
void show(const SymbolTable & symbols, std::ostream & str) const override \ void show(const SymbolTable & symbols, std::ostream & str) const override \
{ \ { \
str << "("; \ str << "("; \
@ -603,9 +601,14 @@ struct ExprOpNot : Expr
PosIdx getPos() const 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, "&&");