Dmn.Compiler.Unit (dmn v0.1.0)

Copy Markdown View Source

The unit of a DRG element: what is prepared of it, and what it reads.

FieldIs
key{kind, id}, or the name if the element has no id
kind:decision, :input, :knowledge (a business knowledge model) or :service (a decision service)
namethe name of the element, as the model has it
idthe id of the element, or its name, and, for an element of an imported model, the namespace of the model and U+0001 before it, which no id or name in a document can have, so that no element can take the key of another
namespacethe namespace of the model the element is in
expressionthe prepared Feel.Expression, or nil for an element that has none (an input) or whose logic could not be prepared
sourcethe virtual source of the expression and its parts (Dmn.Compiler.Source)
reads{canonical name, key} of the units whose values the expression reads, bound under that name when it runs. Those that are in the unit's group are bound to links instead (Feel.Recursion)
groupthe key of the recursion group the unit is in (the first of the keys that Dmn.Compiled.groups has for it), or nil: knowledge units that read each other, or themselves, when Dmn.compile/2 was told recursion: true
diagnosticswhat was found when it was prepared, Dmn.Diagnostics
faultsthe errors among them that make the value wrong, whatever the data: a text that could not be read and is null in the expression. Every run of the unit reports them
strict_faultsconfirmed unresolved-name diagnostics, including those inherited by a service from its decisions. Only strict runs reject these; lenient runs keep FEEL's warning behavior
callback_freetrue if what a worker is given of expression (its executable, linked peers and extensions, not its syntax tree, IR or scope) holds no function value, host callback or generated code that could bring a text of another element into a run, false if it may, nil if that was not looked at. Set once by the compiler (DD-44) so that a run in a worker need not walk the expression again; whoever changes expression sets it to nil

An input has no expression: its value is the one the caller gives, and is converted and verified in the units that read it.

Summary

Types

kind()

@type kind() :: :decision | :input | :knowledge | :service

t()

@type t() :: %Dmn.Compiler.Unit{
  callback_free: boolean() | nil,
  diagnostics: [Dmn.Diagnostic.t()],
  expression: Feel.Expression.t() | nil,
  faults: [Dmn.Diagnostic.t()],
  group: {kind(), String.t()} | nil,
  id: String.t(),
  key: {kind(), String.t()},
  kind: kind(),
  name: String.t(),
  namespace: String.t() | nil,
  reads: [{String.t(), {kind(), String.t()}}],
  source: Dmn.Compiler.Source.finished() | nil,
  strict_faults: [Dmn.Diagnostic.t()]
}