Evaluation¶
Realizes A-EVAL-1; requirements R-EVAL-001 – R-EVAL-011, R-PACK-005, R-IMP-001 – R-IMP-006.
Evaluator — evaluate.py¶
Evaluator(registry, diagnostics, default_pack=, pack_override=, imports=ImportContext(...))
evaluates one Module into a Screen (M-VIEW-3):
_directivesreads@Screenarguments intometa(R-EVAL-010)._select_packapplies the order fence/optionpack→ firstimport <Module>known toPackRegistry.for_module→meta["pack"]→default_pack(R-PACK-005)._load_importsresolvesimport "path"(_resolve_import: absolute, then the base directory, thensearch_paths; each as written and with.mockitdown), recursing into the imported file's imports with aseenset; files are parsed through the module-levelImportCachekeyed by path and mtime (R-IMP).- The block's own structs are registered last, replacing imported ones (R-IMP-004).
block(statements, Env())evaluates statements to views.
Scopes are Env objects chained by parent. block creates a child scope per block;
_instantiate creates a fresh Env() for a struct body (caller variables invisible, R-EVAL-005.C6).
Views versus values¶
Two mutually recursive entry points:
views(expr, env)— where a view is expected: calls go to_call_view(ForEach → struct → variable → pack element → unknown) or_apply_modifierfor member calls; literals becomeText.value(expr, env)— where a value is expected: literals, collections, enum values, members (_member_value), calls (_call_value:.constant(x), view calls →ViewList, unknown callees →CallValue), operators (_binary), ranges and subscripts.
Closures are captured as Thunk(closure, env) and run only where views are expected
(run_thunk, which also binds closure parameters and destructures tuples for ForEach).
Elements, structs, modifiers¶
_element_viewbuilds aView(M-VIEW-1) from the element'sdefault_attrs, labelled arguments, positionalparams, trailing closures (children and slots) and closure/view-valued arguments (slots); action closures are dropped (R-EVAL-004)._instantiatebinds struct arguments as in R-EVAL-005, guards depth withMAX_DEPTH = 48, and tags root views withcomponent._for_eachnormalises the data (count, list, dict items, string), truncates atMAX_ITERATIONS = 500._apply_modifierresolves the modifier against the pack'smodifiersmap, thenvocabulary.RENDERED, thenvocabulary.IGNORED(R-EVAL-009). Mapped modifiers writeview.attrs[attr]; rendered ones append aModifier(M-VIEW-2).
Vocabulary — vocabulary.py¶
RENDERED (modifiers the renderer interprets), IGNORED (behaviour-only SwiftUI modifiers) and
NEUTRAL_MODULES (imports that select no pack), frozensets loaded from the packaged
vocabulary.json (rendered, ignored, neutral_modules), a copy of
shared/language/vocabulary.json (R-REPO-002.C4). Adding a rendered modifier requires a style
builder or renderer handler and a specification change (R-EVAL-009.C4).
Known debt¶
None open; the deviations #1 and #2 recorded on the overview were fixed in 0.1.1.
Tests: tests/test_render.py (EvaluateRenderTests).
Revision history¶
| Version | Date | Change |
|---|---|---|
| 0.1.0 | 2026-11-24 | Page written |
| 0.1.1 | 2026-11-24 | Debt #1, #2 fixed |
| 0.3.2 | 2026-11-25 | Vocabulary loaded from shared/language/vocabulary.json 1 |