brewery
notashelf /
f4135a5dca352a1dadd167128eab556b5e1ae08e

nixir

public

Import-resolving Nix IR plugin

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/nixir.git

Commit f4135a5dca35

tarball

NotAShelf <raf@notashelf.dev> · 2026-02-21 21:07 UTC

unverified2 files changed+12-4
types/serializer: add `HasAttrNode` binary encoding for `?` operator

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ibfb89151eb80ab1ae1d8878b6849d2c96a6a6964
diff --git a/src/irc/serializer.cpp b/src/irc/serializer.cppindex 7a83e55..8819789 100644--- a/src/irc/serializer.cpp+++ b/src/irc/serializer.cpp@@ -271,7 +271,14 @@ struct Deserializer::Impl {             case NodeType::SELECT: {                 auto expr = read_node();                 auto attr = read_node();-                return std::make_shared<Node>(SelectNode(expr, attr, line));+                uint8_t has_default = read_u8();+                std::optional<std::shared_ptr<Node>> default_expr;+                if (has_default) {+                    default_expr = read_node();+                }+                SelectNode select_node(expr, attr, line);+                select_node.default_expr = default_expr;+                return std::make_shared<Node>(std::move(select_node));             }             case NodeType::HAS_ATTR: {                 auto expr = read_node();diff --git a/src/irc/types.h b/src/irc/types.hindex 50f1cb9..d10acf1 100644--- a/src/irc/types.h+++ b/src/irc/types.h@@ -14,7 +14,7 @@ namespace nix_irc {  constexpr uint32_t IR_MAGIC = 0x4E495258;-constexpr uint32_t IR_VERSION = 1;+constexpr uint32_t IR_VERSION = 2;  enum class NodeType : uint8_t {     CONST_INT = 0x01,@@ -29,8 +29,8 @@ enum class NodeType : uint8_t {     UNARY_OP = 0x23,     ATTRSET = 0x30,     SELECT = 0x31,-    HAS_ATTR = 0x32,-    WITH = 0x33,+    HAS_ATTR = 0x34,+    WITH = 0x32,     IF = 0x40,     LET = 0x50,     LETREC = 0x51,@@ -94,6 +94,7 @@ struct LambdaNode {     uint32_t arity = 1;     std::shared_ptr<Node> body;     std::optional<std::string> param_name;+    bool strict_pattern = true;     uint32_t line = 0;     LambdaNode(uint32_t a, std::shared_ptr<Node> b, uint32_t l = 0); };