# `Statifier.Machine.Content.Assign`
[🔗](https://github.com/riddler/statifier-ex/blob/v2.0.0/lib/statifier/machine/content/assign.ex#L1)

A compiled `<assign>` executable-content node (spec 5.4, 5.9.2) - the
interned counterpart to `Statifier.Document.Assign`.

`location` is the raw, uncompiled SCXML `location` attribute (a path
expression such as `"foo.bar.baz"` or `"items[0]"`) - it cannot be resolved
any earlier than `execute/2` even in principle, since a bracket key such as
`items[i]` reads `i` against the *pre-assignment* datamodel. `node_location`
is this node's own `Statifier.Parser.Location` span - named apart from
`location` for exactly the reason `Statifier.Document.Assign`'s moduledoc
gives, so the raw path string and the element's own span are never
confused. `location_location` is `attribute_locations[:location]`'s value
span (the `location` attribute's own span, `nil` only if somehow never
written - spec 5.4.2 requires it), following `expr_location`'s "caller's
choice" convention every other compiled node uses.

`value` is the value-source ladder's compiled result: `{:static, nil}` when
`<assign>` writes no `expr` (Phase 3 adds the child-content rungs),
otherwise `Machine.expr()` or - Decision 6's deferral, the same mechanism
`Statifier.Machine.Data.value` already uses for `<data expr>` - `{:invalid,
Compiler.Error.t()}` when `expr` failed to compile. `expr_location` is
`nil` exactly when `expr` was never written.

Its `Statifier.ExecutableContent` implementation lives right below the
struct: this file is the whole node, top to bottom, with no dispatcher
anywhere else in the tree. The location-resolution, system-variable,
root-existence, and write mechanics (spec 5.4.2/5.9.2/5.10) live in
`Statifier.Interpreter.Datamodel.write_location/4` - extracted so
`idlocation` (6.4.1) and the empty-`<finalize>` auto-assign (6.5) can call
the same mechanics without duplicating them here. A successful write also
produces one `{:datamodel_change, _}` core effect - the one place a
`<assign>`'s written location and value reach a consumer.

# `t`

```elixir
@type t() :: %Statifier.Machine.Content.Assign{
  c_index: non_neg_integer(),
  expr_location: Statifier.Parser.Location.t() | nil,
  location: String.t(),
  location_location: Statifier.Parser.Location.t() | nil,
  node_location: Statifier.Parser.Location.t(),
  value: value()
}
```

# `value`

```elixir
@type value() :: Statifier.Machine.expr() | {:invalid, Statifier.Compiler.Error.t()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
