feat(lang): L11 views and templates - the UI is markup, not code
A `view Name { field = x; function q(..); on e(..) }` declaration is the one bridge between a
program and its UI: it writes view_<name>() -> UiView, whose model is a Value of every field and
whose call runs a query or an event by name.
ludic.ui is a template runtime:
- HTML-shaped XML screens and components, loaded at run time;
- {expression} bindings, if/else/each, props, slots, per-instance state;
- on-press / onclick actions (event, set, emit);
- component libraries (export="true", <import src as>).
Styling:
- stylesheets in <style> or importable .lss files (@import);
- CSS selectors (#id, .class, [attr=v], descendant and > combinators, :hover, :disabled,
:first-child, :last-child, :nth-child, :not) weighed by specificity;
- the box model and flex under CSS's property names.
Also:
- default parameters, and positional-then-named calls;
- Value gains a float kind;
- a function shadowing a runtime one is refused;
- an index is evaluated before the slice is read;
- runtime errors name the right file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
334469ef61
commit
66a2bc2214
64 changed files with 74806 additions and 63975 deletions
|
|
@ -462,6 +462,7 @@ namespace Value {
|
|||
alias null() = value_null
|
||||
alias int(n) = value_int
|
||||
alias fixed(f) = value_fixed
|
||||
alias float(x) = value_float
|
||||
alias bool(b) = value_bool
|
||||
alias str(s) = value_str
|
||||
alias list() = value_list
|
||||
|
|
@ -475,6 +476,7 @@ namespace Value {
|
|||
alias count(value) = value_count
|
||||
alias kind(value) = value_kind
|
||||
alias as_int(value) = value_as_int
|
||||
alias as_float(value) = value_as_float
|
||||
alias as_str(value) = value_as_str
|
||||
}
|
||||
namespace Json {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# shape a JSON save round-trips through. A node is one of:
|
||||
#
|
||||
# kind 0 null kind 1 int kind 2 fixed kind 3 bool
|
||||
# kind 4 str kind 5 list kind 6 object
|
||||
# kind 4 str kind 5 list kind 6 object kind 7 float
|
||||
#
|
||||
# ludicc splices this file when it sees Value.* / Json.* / Reflect.serialize /
|
||||
# Reflect.apply (parse.ludic). Everything is plain Ludic over heap records — no
|
||||
|
|
@ -39,6 +39,7 @@ function value_fixed(f: int) -> Val { let v = value_new(2); v.num = f; return v
|
|||
function value_bool(b: int) -> Val { let v = value_new(3); if b != 0 { v.num = 1 }; return v }
|
||||
function value_str(s: pointer) -> Val { let v = value_new(4); v.txt = s; return v }
|
||||
function value_list() -> Val { return value_new(5) }
|
||||
function value_float(x: float) -> Val { let v = value_new(7); v.num = float_bits(x); return v } # num = the IEEE bits
|
||||
function value_object() -> Val { return value_new(6) }
|
||||
|
||||
# --- builders (return the container, so calls chain) ------------------------
|
||||
|
|
@ -53,7 +54,16 @@ function value_put(obj: Val, key: pointer, item: Val) -> Val {
|
|||
# --- accessors --------------------------------------------------------------
|
||||
function value_kind(v: Val) -> int { return v.tag }
|
||||
function value_count(v: Val) -> int { return len(v.kids) }
|
||||
function value_as_int(v: Val) -> int { return v.num }
|
||||
function value_as_int(v: Val) -> int {
|
||||
if v.tag == 7 { return int(float_from_bits(v.num)) }
|
||||
return v.num
|
||||
}
|
||||
# a number as a float, whichever kind it was written as
|
||||
function value_as_float(v: Val) -> float {
|
||||
if v.tag == 7 { return float_from_bits(v.num) }
|
||||
if v.tag == 2 { return float(v.num) / 65536.0 }
|
||||
return float(v.num)
|
||||
}
|
||||
function value_as_str(v: Val) -> string { if v.txt == null { return "" }; return v.txt }
|
||||
function value_at(list: Val, i: int) -> Val {
|
||||
if i < 0 or i >= len(list.kids) { return value_null() }
|
||||
|
|
@ -118,6 +128,7 @@ function json_encode(v: Val) -> string {
|
|||
if v.tag == 2 { return json_fixed_str(v.num) }
|
||||
if v.tag == 3 { if v.num != 0 { return "true" }; return "false" }
|
||||
if v.tag == 4 { return json_quote(v.txt) }
|
||||
if v.tag == 7 { return string(float_from_bits(v.num)) }
|
||||
if v.tag == 5 {
|
||||
var out = "["
|
||||
var i = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue