Add component parameter support and fix JS runtime
- Emit function parameters in component signature - JS runtime passes props as positional arguments - Remove incorrect return value handling (components call js_set_root internally) - Enables: def Tabs(orientation=0) - All tests passing (30/30)
This commit is contained in:
1 parent
41474aceda
commit
cdddbf675a
5 files changed
+12
-7
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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))
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user