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>
This commit is contained in:
1 parent
d8a2e28fd5
commit
0b77c2ff3c
7 files changed
+999
-594
No files matched your search
@@ -95,6 +95,26 @@ class RitzRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
js_create_text_with_int(prefixPtr, intValue) {
|
||||
const prefix = this.readString(prefixPtr);
|
||||
const text = prefix + intValue.toString();
|
||||
const textNode = document.createTextNode(text);
|
||||
const id = this.nextNodeId++;
|
||||
this.nodes.set(id, textNode);
|
||||
this._log(`createTextWithInt("${prefix}", ${intValue}) = "${text}" (id=${id})`);
|
||||
return id;
|
||||
}
|
||||
|
||||
js_update_text_with_int(nodeId, prefixPtr, intValue) {
|
||||
const node = this.nodes.get(nodeId);
|
||||
const prefix = this.readString(prefixPtr);
|
||||
const text = prefix + intValue.toString();
|
||||
if (node) {
|
||||
node.textContent = text;
|
||||
this._log(`updateTextWithInt(${nodeId}, "${prefix}", ${intValue}) = "${text}"`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===== Signal Management =====
|
||||
|
||||
updateSignals() {
|
||||
@@ -288,11 +308,13 @@ class RitzLoader {
|
||||
env: {
|
||||
js_create_element: (ptr) => runtime.js_create_element(ptr),
|
||||
js_create_text: (ptr) => runtime.js_create_text(ptr),
|
||||
js_create_text_with_int: (p, i) => runtime.js_create_text_with_int(p, i),
|
||||
js_append_child: (p, c) => runtime.js_append_child(p, c),
|
||||
js_set_attribute: (e, n, v) => runtime.js_set_attribute(e, n, v),
|
||||
js_set_root: (e) => runtime.js_set_root(e),
|
||||
js_bind_event: (e, n, h) => runtime.js_bind_event(e, n, h),
|
||||
js_update_text_content: (n, t) => runtime.js_update_text_content(n, t),
|
||||
js_update_text_with_int: (n, p, i) => runtime.js_update_text_with_int(n, p, i),
|
||||
js_create_marker: () => runtime.js_create_marker(),
|
||||
js_replace_at_marker: (m, o, n) => runtime.js_replace_at_marker(m, o, n),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user