This commit is contained in:
2026-06-21 18:44:42 -05:00
parent d4b9278838
commit cbdaca4a90
8 changed files with 48 additions and 27 deletions
+12 -7
View File
@@ -115,15 +115,19 @@ struct CompiledScript {
struct ObjectRuntime {
object_id: ObjectId,
/// Key into [`ScriptHost::scripts`] for this object's compiled script — the
/// pool name for a named script, or the source text for an embedded built-in.
/// world-pool name for a named script, or the synthetic `BUILTIN_*` name for an
/// expanded built-in.
script_key: String,
scope: Scope<'static>,
output_queue: ObjQueue,
}
/// The compile-key for an object's script: the embedded source itself for a
/// built-in (so identical built-ins share one compiled AST), or the world-pool
/// name for a named script. `None` if the object has no script.
/// The compile-key for an object's script: the object's `script_name` — a
/// world-pool name for a named script, or a synthetic `BUILTIN_*` name set by
/// [`Board::expand_builtin_archetypes`](crate::board::Board::expand_builtin_archetypes)
/// for an expanded built-in (so identical built-ins share one compiled AST,
/// while the source still comes from `builtin_script`). `None` if the object has
/// no script.
fn script_key(obj: &ObjectDef) -> Option<String> {
obj.script_name.clone()
}
@@ -226,9 +230,10 @@ impl ScriptHost {
let board = board_cell.borrow();
// Compile each referenced script once, keyed by `script_key` (pool name for
// named scripts, source text for embedded built-ins so identical ones share
// one AST).
// Compile each referenced script once, keyed by `script_key` (the object's
// `script_name`: a world-pool name for named scripts, or a synthetic
// `BUILTIN_*` name for built-ins so identical ones share one AST). The
// source for a built-in still comes from its embedded `builtin_script`.
let mut scripts: HashMap<String, CompiledScript> = HashMap::new();
let mut failed: HashSet<String> = HashSet::new();
for obj in board.objects.values() {