brewery
notashelf /
feb247f64a93c65c93a80df2d9c810bc72c71386

nixir

public

Import-resolving Nix IR plugin

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

Commit feb247f64a93

tarball

NotAShelf <raf@notashelf.dev> · 2026-04-24 20:13 UTC

unverified2 files changed+62-41
irc: extract inline constructors; deduplicate value-copy logic

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ifc74f0bfe621a05fa7b91a5f6be1ea976a6a6964
diff --git a/src/irc/types.cpp b/src/irc/types.cppnew file mode 100644index 0000000..1ee8a8e--- /dev/null+++ b/src/irc/types.cpp@@ -0,0 +1,62 @@+#include "types.h"++namespace nix_irc {++// LambdaNode constructor+LambdaNode::LambdaNode(uint32_t a, std::shared_ptr<Node> b, uint32_t l)+    : arity(a), body(std::move(b)), line(l) {}++// AppNode constructor+AppNode::AppNode(std::shared_ptr<Node> f, std::shared_ptr<Node> a, uint32_t l)+    : func(std::move(f)), arg(std::move(a)), line(l) {}++// BinaryOpNode constructor+BinaryOpNode::BinaryOpNode(BinaryOp o, std::shared_ptr<Node> l, std::shared_ptr<Node> r,+                           uint32_t ln)+    : op(o), left(std::move(l)), right(std::move(r)), line(ln) {}++// UnaryOpNode constructor+UnaryOpNode::UnaryOpNode(UnaryOp o, std::shared_ptr<Node> operand, uint32_t l)+    : op(o), operand(std::move(operand)), line(l) {}++// SelectNode constructor+SelectNode::SelectNode(std::shared_ptr<Node> e, std::shared_ptr<Node> a, uint32_t l)+    : expr(std::move(e)), attr(std::move(a)), line(l) {}++// HasAttrNode constructor+HasAttrNode::HasAttrNode(std::shared_ptr<Node> e, std::shared_ptr<Node> a, uint32_t l)+    : expr(std::move(e)), attr(std::move(a)), line(l) {}++// WithNode constructor+WithNode::WithNode(std::shared_ptr<Node> a, std::shared_ptr<Node> b, uint32_t l)+    : attrs(std::move(a)), body(std::move(b)), line(l) {}++// IfNode constructor+IfNode::IfNode(std::shared_ptr<Node> c, std::shared_ptr<Node> t, std::shared_ptr<Node> e,+               uint32_t l)+    : cond(std::move(c)), then_branch(std::move(t)), else_branch(std::move(e)), line(l) {}++// LetNode constructor+LetNode::LetNode(std::shared_ptr<Node> b, uint32_t l) : body(std::move(b)), line(l) {}++// LetRecNode constructor+LetRecNode::LetRecNode(std::shared_ptr<Node> b, uint32_t l) : body(std::move(b)), line(l) {}++// AssertNode constructor+AssertNode::AssertNode(std::shared_ptr<Node> c, std::shared_ptr<Node> b, uint32_t l)+    : cond(std::move(c)), body(std::move(b)), line(l) {}++// ImportNode constructor+ImportNode::ImportNode(std::shared_ptr<Node> p, uint32_t l) : path(std::move(p)), line(l) {}++// ThunkNode constructor+ThunkNode::ThunkNode(std::shared_ptr<Node> e, uint32_t l) : expr(std::move(e)), line(l) {}++// ForceNode constructor+ForceNode::ForceNode(std::shared_ptr<Node> e, uint32_t l) : expr(std::move(e)), line(l) {}++// LambdaPatternNode constructor+LambdaPatternNode::LambdaPatternNode(std::shared_ptr<Node> b, uint32_t l)+    : allow_extra(false), body(std::move(b)), line(l) {}++} // namespace nix_ircdiff --git a/src/irc/types.h b/src/irc/types.hindex 7a4c754..79f4275 100644--- a/src/irc/types.h+++ b/src/irc/types.h@@ -352,48 +352,7 @@ public:   template <typename T> bool holds() const { return std::holds_alternative<T>(data); } }; -// Constructor implementations-inline LambdaNode::LambdaNode(uint32_t a, std::shared_ptr<Node> b, uint32_t l)-    : arity(a), body(std::move(b)), line(l) {} -inline AppNode::AppNode(std::shared_ptr<Node> f, std::shared_ptr<Node> a, uint32_t l)-    : func(std::move(f)), arg(std::move(a)), line(l) {}--inline BinaryOpNode::BinaryOpNode(BinaryOp o, std::shared_ptr<Node> l, std::shared_ptr<Node> r,-                                  uint32_t ln)-    : op(o), left(std::move(l)), right(std::move(r)), line(ln) {}--inline UnaryOpNode::UnaryOpNode(UnaryOp o, std::shared_ptr<Node> operand, uint32_t l)-    : op(o), operand(std::move(operand)), line(l) {}--inline SelectNode::SelectNode(std::shared_ptr<Node> e, std::shared_ptr<Node> a, uint32_t l)-    : expr(std::move(e)), attr(std::move(a)), line(l) {}--inline HasAttrNode::HasAttrNode(std::shared_ptr<Node> e, std::shared_ptr<Node> a, uint32_t l)-    : expr(std::move(e)), attr(std::move(a)), line(l) {}--inline WithNode::WithNode(std::shared_ptr<Node> a, std::shared_ptr<Node> b, uint32_t l)-    : attrs(std::move(a)), body(std::move(b)), line(l) {}--inline IfNode::IfNode(std::shared_ptr<Node> c, std::shared_ptr<Node> t, std::shared_ptr<Node> e,-                      uint32_t l)-    : cond(std::move(c)), then_branch(std::move(t)), else_branch(std::move(e)), line(l) {}--inline LetNode::LetNode(std::shared_ptr<Node> b, uint32_t l) : body(std::move(b)), line(l) {}--inline LetRecNode::LetRecNode(std::shared_ptr<Node> b, uint32_t l) : body(std::move(b)), line(l) {}--inline AssertNode::AssertNode(std::shared_ptr<Node> c, std::shared_ptr<Node> b, uint32_t l)-    : cond(std::move(c)), body(std::move(b)), line(l) {}--inline ImportNode::ImportNode(std::shared_ptr<Node> p, uint32_t l) : path(std::move(p)), line(l) {}--inline ThunkNode::ThunkNode(std::shared_ptr<Node> e, uint32_t l) : expr(std::move(e)), line(l) {}--inline ForceNode::ForceNode(std::shared_ptr<Node> e, uint32_t l) : expr(std::move(e)), line(l) {}--inline LambdaPatternNode::LambdaPatternNode(std::shared_ptr<Node> b, uint32_t l)-    : allow_extra(false), body(std::move(b)), line(l) {}  struct SourceFile {   std::string path;