SX renderer: adapter-html.sx as sole renderer, conditions, pattern matching

Evaluator: conditions/restarts, pattern matching, render-trace support.
adapter-html.sx: full SX-defined HTML renderer replacing native OCaml.
spec/render.sx: updated render mode helpers.
sx_browser.ml: use SX render-to-html instead of native.
sx_ref.ml: evaluator updates for conditions + match.
Bootstrap + transpiler updates for new forms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 01:28:53 +00:00
parent 015781313c
commit e1ef883339
15 changed files with 3460 additions and 2320 deletions

View File

@@ -854,6 +854,10 @@ let () =
| [Component c] -> c.c_body
| [Island i] -> i.i_body
| _ -> Nil);
register "component-file" (fun args ->
match args with [v] -> component_file v | _ -> Nil);
register "component-set-file!" (fun args ->
match args with [v; f] -> component_set_file v f | _ -> Nil);
register "macro?" (fun args ->
match args with [Macro _] -> Bool true | _ -> Bool false);
register "for-each-indexed" (fun args ->

File diff suppressed because one or more lines are too long

View File

@@ -102,7 +102,7 @@ let get_val container key =
| "match-val" -> f.cf_extra | "current-item" -> f.cf_extra
| "update-fn" -> f.cf_extra | "head-name" -> f.cf_extra
| "emitted" -> f.cf_extra2 | "effect-list" -> f.cf_extra2
| "first-render" -> f.cf_extra2
| "first-render" -> f.cf_extra2 | "file" -> f.cf_env
| _ -> Nil)
| Dict d, String k -> dict_get d k
| Dict d, Keyword k -> dict_get d k

View File

@@ -111,6 +111,7 @@ and component = {
c_body : value;
c_closure : env;
c_affinity : string; (** "auto" | "client" | "server" *)
mutable c_file : string option; (** Source file path *)
mutable c_compiled : vm_closure option; (** Lazy JIT cache *)
}
@@ -120,6 +121,7 @@ and island = {
i_has_children : bool;
i_body : value;
i_closure : env;
mutable i_file : string option; (** Source file path *)
}
and macro = {
@@ -287,7 +289,7 @@ let make_component name params has_children body closure affinity =
Component {
c_name = n; c_params = ps; c_has_children = hc;
c_body = body; c_closure = unwrap_env_val closure; c_affinity = aff;
c_compiled = None;
c_file = None; c_compiled = None;
}
let make_island name params has_children body closure =
@@ -297,6 +299,7 @@ let make_island name params has_children body closure =
Island {
i_name = n; i_params = ps; i_has_children = hc;
i_body = body; i_closure = unwrap_env_val closure;
i_file = None;
}
let make_macro params rest_param body closure name =
@@ -400,6 +403,19 @@ let component_name = function
| Island i -> String i.i_name
| v -> raise (Eval_error ("Expected component, got " ^ type_of v))
let component_file = function
| Component c -> (match c.c_file with Some f -> String f | None -> Nil)
| Island i -> (match i.i_file with Some f -> String f | None -> Nil)
| _ -> Nil
let component_set_file v f =
(match v, f with
| Component c, String s -> c.c_file <- Some s
| Island i, String s -> i.i_file <- Some s
| _ -> ()); Nil
let component_set_file_b = component_set_file
let component_params = function
| Component c -> List (List.map (fun s -> String s) c.c_params)
| Island i -> List (List.map (fun s -> String s) i.i_params)