From 59fedbe78d66b13c17c3d657dc171c2768f1c0db Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 21 Feb 2026 20:46:21 +0300 Subject: [PATCH] types: add `hasAttrNode` for `?` operator support Signed-off-by: NotAShelf Change-Id: I73691d86c8ce277bacc0dd7ed33939c96a6a6964 --- src/irc/types.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/irc/types.h b/src/irc/types.h index 68aedbe..50f1cb9 100644 --- a/src/irc/types.h +++ b/src/irc/types.h @@ -29,7 +29,8 @@ enum class NodeType : uint8_t { UNARY_OP = 0x23, ATTRSET = 0x30, SELECT = 0x31, - WITH = 0x32, + HAS_ATTR = 0x32, + WITH = 0x33, IF = 0x40, LET = 0x50, LETREC = 0x51, @@ -134,6 +135,13 @@ struct SelectNode { SelectNode(std::shared_ptr e, std::shared_ptr a, uint32_t l = 0); }; +struct HasAttrNode { + std::shared_ptr expr; + std::shared_ptr attr; + uint32_t line = 0; + HasAttrNode(std::shared_ptr e, std::shared_ptr a, uint32_t l = 0); +}; + struct WithNode { std::shared_ptr attrs; std::shared_ptr body; @@ -198,6 +206,7 @@ public: UnaryOpNode, AttrsetNode, SelectNode, + HasAttrNode, WithNode, IfNode, LetNode, @@ -238,6 +247,9 @@ inline UnaryOpNode::UnaryOpNode(UnaryOp o, std::shared_ptr operand, uint32 inline SelectNode::SelectNode(std::shared_ptr e, std::shared_ptr a, uint32_t l) : expr(e), attr(a), line(l) {} +inline HasAttrNode::HasAttrNode(std::shared_ptr e, std::shared_ptr a, uint32_t l) + : expr(e), attr(a), line(l) {} + inline WithNode::WithNode(std::shared_ptr a, std::shared_ptr b, uint32_t l) : attrs(a), body(b), line(l) {}