Statifier.Machine.Data (Statifier v2.0.0)

Copy Markdown View Source

One compiled <data> element - the interned counterpart to Statifier.Document.Data, dense from d_index 0 across the whole machine (ADR-0012 item 3), read via Statifier.Machine.data/2.

value selects among the value-source precedence spec 5.3.2 gives <data> (expr, src, child content, or none), decided once at Machine-build time by Statifier.Compiler:

  • expr compiles through Statifier.Compiler.Expressions.compile/3 like any other expression - except a compile failure is captured as {:invalid, error} on this struct rather than failing Statifier.Compiler.compile/1: spec 5.9.4 permits either load-time rejection or a runtime error.execution, and data_invalid_test.exs in the corpus needs the latter.
  • src never resolves in this pure core (ADR-0003) - it is carried as {:src, uri} and always fails at binding time (spec 5.3.2's "empty data element" clause).
  • non-blank child text is folded to {:static, _} at compile time (Decision 8, Statifier.Compiler.Expressions.inline_value/1) - it is never a {:compiled, ...} read of the datamodel.
  • no value source at all is {:static, nil}.

value_location is the diagnostic span, following cond_location and expr_location's "caller's choice" contract (lib/statifier/compiler/expressions.ex:36-45): the written attribute's value span when written, the <data> node's own location otherwise.

Summary

Types

t()

@type t() :: %Statifier.Machine.Data{
  d_index: non_neg_integer(),
  id: String.t(),
  location: Statifier.Parser.Location.t(),
  value: value(),
  value_location: Statifier.Parser.Location.t() | nil
}

value()

@type value() ::
  Statifier.Machine.expr()
  | {:invalid, Statifier.Compiler.Error.t()}
  | {:src, uri :: String.t()}