Unity.GnuUnitsImporter.Resolver (Unity v0.7.0)

Copy Markdown View Source

Pass 2: resolves parsed GNU unit expressions into numeric factors and dimension maps relative to SI primitives.

Each resolved unit becomes {factor, dimensions} where dimensions is a map of GNU primitive name to integer power. For example:

  • foot{0.3048, %{"m" => 1}}
  • newton{1.0, %{"kg" => 1, "m" => 1, "s" => -2}}

Resolution is recursive with memoization via the process dictionary to keep stack frames small during deep chains.

Summary

Functions

Resolves all definitions in the parsed data to {factor, dimensions} pairs.

Types

dimensions()

@type dimensions() :: %{required(String.t()) => integer()}

resolved()

@type resolved() :: {float(), dimensions()}

Functions

resolve_all(parsed)

@spec resolve_all(Unity.GnuUnitsImporter.Parser.parsed()) ::
  {:ok, %{required(String.t()) => resolved()}}

Resolves all definitions in the parsed data to {factor, dimensions} pairs.