3 Commits
Author SHA1 Message Date
Aaron SinclairandClaude 0b77c2ff3c Implement reactive text nodes & fix LLVM syntax for clang 20
**Reactive Text Nodes:**
- F-strings with signal dependencies now update automatically
- Added js_create_text_with_int() and js_update_text_with_int() for efficient "prefix{int}" pattern
- Text nodes stored in @reactive_text_N_node globals for updates
- Scan and track f-string dependencies during collection phase

**Binary Operations:**
- Implemented BinOp support in parser and codegen
- Maps Add → add i32, Sub → sub i32, Mult → mul i32, Div → sdiv i32, Mod → srem i32
- count = count + 1 now generates correct arithmetic instead of store i32 0

**LLVM Syntax Fixes (clang 20 compatibility):**
- Fixed getelementptr syntax: removed parentheses around type
- Before: getelementptr inbounds ([N x i8], [N x i8]* @str, ...)
- After:  getelementptr inbounds [N x i8], [N x i8]* @str, ...
- Created _emit_string_ptr() helper for consistent string pointer generation
- Fixed in: element creation, attribute setting, event binding, select instructions

**Runtime (ritz-runtime.js):**
- Added js_create_text_with_int(prefix, intValue) - creates text node with "prefix" + intValue
- Added js_update_text_with_int(node, prefix, intValue) - updates text content

**Result:**
✅ TextInput counter increments/decrements correctly
✅ Tabs example works (reactive attributes, conditionals)
✅ Both examples compile with clang 20

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 15:00:36 -08:00
Aaron SinclairandClaude e1219ea0c1 Implement binary operations (BinOp) support
**Parser changes (parser.py):**
- Added ast.BinOp handling in _transform_expr()
- Emits: {type: "binop", left: ..., op: "Add|Sub|Mult|Div|Mod", right: ...}

**Codegen changes (llvm_codegen_signals.py):**
- Added BinOp handling in _emit_expr()
- Maps Python ops to LLVM instructions:
  - Add → add i32
  - Sub → sub i32
  - Mult → mul i32
  - Div → sdiv i32 (signed division)
  - Mod → srem i32 (signed remainder)

**Result:**
Before: count = count + 1 → store i32 0 (WRONG!)
After:  count = count + 1 → load, add i32 1, store ✓

**Still TODO:**
The counter buttons now UPDATE the signal correctly, but the display
doesn't update because f-string text nodes aren't reactive yet.
We need reactive text nodes (similar to reactive attributes).

All 55 tests passing ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 12:18:16 -08:00
Aaron SinclairandClaude 443cca5662 Add TextInput example exposing type system limitations + roadmap
Created a new example that demonstrates what we need for proper string/type support:

**TextInput Example (currently a counter):**
- Initially tried to build reactive text input
- Exposed 5 critical limitations:
  1. String signals stored as i32 (should be i8*)
  2. F-string interpolation incomplete (f"Count: {count}" → "0")
  3. No oninput event (only onclick supported)
  4. No event value passing (can't get input.value)
  5. No string operations (len, concat, etc.)

**Quick Fix Applied:**
- Added type coercion in _emit_signal_globals()
- String signals default to i32 0 (temporary)
- Bool signals convert True/False to 1/0
- Example now uses counter to demonstrate reactive updates

**TYPE_SYSTEM_ROADMAP.md:**
Complete implementation plan for proper type support:
- Phase 1: Type hints extraction (already works!)
- Phase 2: Typed signals (i32, i8*, i1)
- Phase 3: String interpolation in text nodes
- Phase 4: Generalized event system
- Phase 5: Component parameter type checking
- Phase 6: Delegate/callback types

This example will drive the type system implementation. Once complete,
text input will work with proper string signals and reactive updates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 11:53:56 -08:00