17 :
Node(NK_Op, Range), OpKind(OpKind) {}
26 const std::shared_ptr<Op> O;
30 :
Expr(Kind, Range), O(std::move(O)) {
31 assert(this->O &&
"O must not be null");
34 [[nodiscard]]
Op &
op()
const {
return *O; }
40 const std::shared_ptr<Expr> LHS;
41 const std::shared_ptr<Expr> RHS;
45 std::shared_ptr<Expr> LHS, std::shared_ptr<Expr> RHS)
46 :
ExprOp(NK_ExprBinOp, Range, std::move(O)), LHS(std::move(LHS)),
47 RHS(std::move(RHS)) {}
49 [[nodiscard]]
Expr *
lhs()
const {
return LHS.get(); }
50 [[nodiscard]]
Expr *
rhs()
const {
return RHS.get(); }
53 return {&
op(), LHS.get(), RHS.get()};
58 const std::shared_ptr<Expr> E;
59 const std::shared_ptr<AttrPath> Path;
63 std::shared_ptr<Expr> E, std::shared_ptr<AttrPath> Path)
64 :
ExprOp(NK_ExprOpHasAttr, Range, std::move(O)), E(std::move(E)),
65 Path(std::move(Path)) {}
67 [[nodiscard]]
Expr *
expr()
const {
return E.get(); }
71 return {E.get(), Path.get()};
76 const std::shared_ptr<Expr> E;
80 std::shared_ptr<Expr> E)
81 :
ExprOp(NK_ExprUnaryOp, Range, std::move(O)), E(std::move(E)) {}
83 [[nodiscard]]
Expr *
expr()
const {
return E.get(); }
86 return {&
op(), E.get()};
ExprBinOp(LexerCursorRange Range, std::shared_ptr< Op > O, std::shared_ptr< Expr > LHS, std::shared_ptr< Expr > RHS)
ChildVector children() const override
ChildVector children() const override
AttrPath * attrpath() const
ExprOpHasAttr(LexerCursorRange Range, std::shared_ptr< Op > O, std::shared_ptr< Expr > E, std::shared_ptr< AttrPath > Path)
Abstract class for binary operators and unary operators.
ChildVector children() const override
ExprOp(NodeKind Kind, LexerCursorRange Range, std::shared_ptr< Op > O)
ExprUnaryOp(LexerCursorRange Range, std::shared_ptr< Op > O, std::shared_ptr< Expr > E)
ChildVector children() const override
boost::container::small_vector< Node *, 8 > ChildVector
ChildVector children() const override
tok::TokenKind op() const
Op(LexerCursorRange Range, tok::TokenKind OpKind)