java.lang.Object
com.darkcollective.relix.semantic.internal.SolveEquations

public final class SolveEquations extends Object
Expands the user-defined scalar functions in a SOLVE equation into the arithmetic they stand for, so that SOLVE length = predicted(L0, k, temp) is solved exactly as the equation the def body spells.

Expansion substitutes each call's arguments for the parameters of the function's body, and expands the result again, so a def calling another is followed through. It is the same choice of function evaluation makes: a function a library supplies takes precedence over a def of the same name, and stays a call — one the equation then cannot be solved through. A call is also left as written when nothing can be substituted for it faithfully: no def of that arity, a body that names something other than its parameters, or a def that reaches itself again.

Validation and planning both expand, so what is checked is what is solved.

  • Method Details

    • expand

      public static SolveEquation expand(SolveEquation equation, FunctionCatalog functions, SymbolTable symbols)
      Expands every user-defined scalar function call in equation.
      Parameters:
      equation - the equation as written; must not be null
      functions - the installed function libraries; must not be null
      symbols - the symbol table holding the script's defs; must not be null
      Returns:
      the expanded equation
    • expandAll

      public static List<SolveEquation> expandAll(List<SolveEquation> equations, FunctionCatalog functions, SymbolTable symbols)
      Expands every equation of a list.
      Parameters:
      equations - the equations as written; must not be null
      functions - the installed function libraries; must not be null
      symbols - the symbol table holding the script's defs; must not be null
      Returns:
      the expanded equations, in the same order