Fix nested components - render functions now return i32
Changes: - Component render functions return i32 (root element) instead of void - Nested components (yield SomeComponent()) now work correctly - Added main() entry point that calls top-level component and sets root - Updated runtime to call main() instead of render_ComponentName() Note: Active state in ternary expressions still needs reactive updates This commit fixes the nested component rendering issue All tests passing (51 passed, 2 skipped) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
adf95f424d
commit
b0e38db22c
26 files changed
+2310
-1222
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -57,7 +57,7 @@ def Button(label):
|
||||
llvm_ir = generate_llvm_ir(ir)
|
||||
|
||||
# Should generate render function with parameter
|
||||
assert "define void @render_Button(i32 %label)" in llvm_ir
|
||||
assert "define i32 @render_Button(i32 %label)" in llvm_ir
|
||||
|
||||
|
||||
def test_parse_yield_component_with_args():
|
||||
@@ -111,8 +111,8 @@ def Parent():
|
||||
components = parse_component(source)
|
||||
llvm_ir = generate_llvm_ir(components)
|
||||
|
||||
# Should call render_Child with argument
|
||||
assert "call void @render_Child(i32 42)" in llvm_ir
|
||||
# Should call render_Child with argument and capture return value
|
||||
assert "call i32 @render_Child(i32 42)" in llvm_ir
|
||||
|
||||
|
||||
def test_component_with_default_param():
|
||||
@@ -180,7 +180,7 @@ def Counter(initial_count):
|
||||
llvm_ir = generate_llvm_ir(ir)
|
||||
|
||||
# Should accept parameter
|
||||
assert "define void @render_Counter(i32 %initial_count)" in llvm_ir
|
||||
assert "define i32 @render_Counter(i32 %initial_count)" in llvm_ir
|
||||
|
||||
# Signal should be initialized with parameter value
|
||||
# This will require storing the param value to the signal global
|
||||
@@ -25,7 +25,7 @@ def test_llvm_hello_world_structure():
|
||||
llvm_ir = generate_llvm_ir(ir_dict)
|
||||
|
||||
# Check basic LLVM IR structure
|
||||
assert "define void @render_HelloWorld()" in llvm_ir
|
||||
assert "define i32 @render_HelloWorld()" in llvm_ir
|
||||
assert "ret void" in llvm_ir
|
||||
|
||||
# Should have string constants
|
||||
@@ -115,10 +115,12 @@ def test_llvm_ir_syntax_valid():
|
||||
llvm_ir = generate_llvm_ir(ir_dict)
|
||||
|
||||
# Basic syntax checks
|
||||
assert llvm_ir.count("define") == llvm_ir.count("ret void") # All functions return
|
||||
assert llvm_ir.count("define") == llvm_ir.count("ret") # All functions have returns
|
||||
assert "%" in llvm_ir # Has SSA variables
|
||||
assert "call" in llvm_ir # Has function calls
|
||||
assert "@" in llvm_ir # Has global symbols
|
||||
assert "define void @main()" in llvm_ir # Has main entry point
|
||||
assert "define i32 @render_" in llvm_ir # Component functions return i32
|
||||
|
||||
|
||||
def test_llvm_ir_compiles_with_llc():
|
||||
|
||||
@@ -76,7 +76,7 @@ def SimpleTabs():
|
||||
llvm_ir = generate_llvm_ir(ir)
|
||||
|
||||
# Should generate render function for TabButton with parameters
|
||||
assert "define void @render_TabButton(" in llvm_ir
|
||||
assert "define i32 @render_TabButton(" in llvm_ir
|
||||
|
||||
# Should call TabButton from SimpleTabs with arguments
|
||||
assert "call void @render_TabButton(" in llvm_ir
|
||||
assert "call i32 @render_TabButton(" in llvm_ir
|
||||
Reference in new issue
Block a user