diff --git a/examples/runtime/ritz-runtime.js b/examples/runtime/ritz-runtime.js index 4143e0e..4292517 100644 --- a/examples/runtime/ritz-runtime.js +++ b/examples/runtime/ritz-runtime.js @@ -277,12 +277,8 @@ class RitzLoader { } // Pass props as positional arguments - // Components now RETURN the root element ID instead of calling js_set_root const propValues = Object.values(props); - const rootElementId = renderFn(...propValues); - - // Mount the returned element to the DOM - runtime.js_set_root(rootElementId); + renderFn(...propValues); // Update signals runtime.updateSignals(); diff --git a/examples/tabs/Tabs.ll b/examples/tabs/Tabs.ll index cf6bd75..c776f15 100644 --- a/examples/tabs/Tabs.ll +++ b/examples/tabs/Tabs.ll @@ -299,7 +299,7 @@ entry: } ; Component render function -define void @render_Tabs() { +define void @render_Tabs(i32 %orientation) { entry: %var56 = call i32 @js_create_element(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.0, i32 0, i32 0)) call void @js_set_attribute(i32 %var56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.28, i32 0, i32 0)) diff --git a/examples/tabs/Tabs.wasm b/examples/tabs/Tabs.wasm index 9ee906c..c7ec38d 100755 Binary files a/examples/tabs/Tabs.wasm and b/examples/tabs/Tabs.wasm differ diff --git a/ritz/__pycache__/llvm_codegen_signals.cpython-313.pyc b/ritz/__pycache__/llvm_codegen_signals.cpython-313.pyc index 4d12edb..38a7dc5 100644 Binary files a/ritz/__pycache__/llvm_codegen_signals.cpython-313.pyc and b/ritz/__pycache__/llvm_codegen_signals.cpython-313.pyc differ diff --git a/ritz/llvm_codegen_signals.py b/ritz/llvm_codegen_signals.py index 52a89dd..ec0b3ae 100644 --- a/ritz/llvm_codegen_signals.py +++ b/ritz/llvm_codegen_signals.py @@ -196,8 +196,17 @@ class SignalLLVMIRGenerator: def _emit_component(self, ir: dict[str, Any]) -> None: """Emit component render function.""" component_name = ir["name"] + + # Build parameter list + params = ir.get("params", []) + param_list = [] + for param in params: + # For now, all params are i32 + param_list.append(f"i32 %{param['name']}") + param_str = ", ".join(param_list) if param_list else "" + self.lines.append("; Component render function") - self.lines.append(f"define void @render_{component_name}() {{") + self.lines.append(f"define void @render_{component_name}({param_str}) {{") self.lines.append("entry:") # Process component body (skip signals and functions, already handled)