feat: implement ADT RC - pointer fields in algebraic data types

ADT values with pointer fields (like recursive Tree types) now properly
manage memory:

- Assign unique type tags (starting at 100) to each ADT type
- Track which ADTs have pointer fields that need cleanup
- Generate lux_drop_adt() function with per-ADT drop logic
- Allocate ADT pointer fields with lux_rc_alloc instead of malloc
- Track ADT variables with pointer fields in scope
- Emit field cleanup code at scope exit (switch on tag, decref fields)

Test results:
- ADT test: [RC] No leaks: 6 allocs, 6 frees
- List test: [RC] No leaks: 31 allocs, 31 frees
- Closure test: [RC] No leaks: 8 allocs, 8 frees
- All 263 tests pass

Remaining: early returns, complex conditionals.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 13:24:21 -05:00
parent 397c633d51
commit 5098104aaf
4 changed files with 204 additions and 12 deletions

2
.gitignore vendored
View File

@@ -5,3 +5,5 @@
hello
test_rc
test_rc2
test_adt_rc
test_closure_rc