Integrate reactive rendering into _emit_if()
Modified _emit_if() to: - Create marker node via js_create_marker() - Append marker to parent element - Store marker ID in global - Call _init_conditional_X() to render and insert active branch Branch render functions work correctly: - Build element tree locally - Return root element ID - Called by init function to pre-render all branches Fallback to _emit_if_static() if conditional not collected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
8bf1c38858
commit
44db8ff022
4 files changed
+810
-400
No files matched your search
+783
-399
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
@@ -461,7 +461,33 @@ class SignalLLVMIRGenerator:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def _emit_if(self, stmt: dict[str, Any]) -> str | None:
|
def _emit_if(self, stmt: dict[str, Any]) -> str | None:
|
||||||
"""Emit an if statement."""
|
"""Emit an if statement with reactive rendering."""
|
||||||
|
# Get conditional ID from our collected conditionals
|
||||||
|
cond_id = self.conditional_map.get(id(stmt))
|
||||||
|
|
||||||
|
if cond_id is None:
|
||||||
|
# Fallback to static rendering if not collected (shouldn't happen)
|
||||||
|
return self._emit_if_static(stmt)
|
||||||
|
|
||||||
|
# Create marker node
|
||||||
|
marker_var = self._new_var()
|
||||||
|
self.lines.append(f" %{marker_var} = call i32 @js_create_marker()")
|
||||||
|
|
||||||
|
# Append marker to parent if we have one
|
||||||
|
if self.parent_element_stack:
|
||||||
|
parent_var = self.parent_element_stack[-1]
|
||||||
|
self.lines.append(f" call void @js_append_child(i32 %{parent_var}, i32 %{marker_var})")
|
||||||
|
|
||||||
|
# Store marker ID in global
|
||||||
|
self.lines.append(f" store i32 %{marker_var}, i32* @cond_{cond_id}_marker")
|
||||||
|
|
||||||
|
# Call init function to render and insert active branch
|
||||||
|
self.lines.append(f" call void @_init_conditional_{cond_id}()")
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _emit_if_static(self, stmt: dict[str, Any]) -> str | None:
|
||||||
|
"""Emit an if statement with static (non-reactive) rendering."""
|
||||||
# Generate unique labels for this if statement
|
# Generate unique labels for this if statement
|
||||||
if_id = self._new_var()
|
if_id = self._new_var()
|
||||||
then_label = f"if.then.{if_id}"
|
then_label = f"if.then.{if_id}"
|
||||||
|
|||||||
Reference in new issue
Block a user