Class StepVariableCompiler
- Namespace
- Hi.MachiningProcs
- Assembly
- HiNc.dll
Internal Use Only.
Compiles the formulas of project StepVariables into
Func<MachiningStep, double?>s the way a session script is compiled — the
scripts' references and imports (ScriptOptions), with
ScriptRenameBridge applied — but with no script globals: a formula reads the
step it is given (and what the step reaches, such as the steps around it through
step.Host.ClStrip). Each formula has to parse on its own as one C# expression or one
block in braces, with no preprocessor directive, before it is compiled, so no formula reaches
outside its lambda and compiling a project's formulas runs none of them. Any number of formulas
compile in one compilation, each body mapped to a file of its own
(#line 1 "step-variable-<i>"), so an error is placed by line and column within its
formula. An outcome is kept for each script options and formula text: a compiled script cannot
be unloaded, so a text is compiled once for the options it is compiled with. An editor checks a
formula with Check(string, ScriptOptions), which loads and keeps nothing.
public static class StepVariableCompiler
- Inheritance
-
StepVariableCompiler
- Inherited Members
Fields
CompilerCannotRunErrorId
The id of the error a formula gets when the compiler itself could not run on it (an exception, not a diagnostic); such an outcome is not kept, so the next call tries again.
public const string CompilerCannotRunErrorId = "StepVariableCompiler"
Field Value
FormulaShapeErrorId
The id of an error found before the compiler sees the formula: it is empty, it is not one expression or one block, it holds a preprocessor directive, or it holds a character a project file cannot store.
public const string FormulaShapeErrorId = "StepVariable"
Field Value
SourceAfterFormula
The source after a formula in the script it compiles in; see SourceBeforeFormula.
public const string SourceAfterFormula = "\n),\n}"
Field Value
SourceBeforeFormula
The source before a formula in the script it compiles in, without the line mapping: what
an editor's completion puts before the formula (after the scripts' imports and
UsingAliasLines), so that it offers what compiles there —
step and what it reaches, no script globals. SourceAfterFormula follows
the formula.
public const string SourceBeforeFormula = "new System.Func<Hi.MachiningSteps.MachiningStep, double?>[]\n{\n((Hi.MachiningSteps.MachiningStep step) =>\n"
Field Value
Methods
Check(string, ScriptOptions)
The errors Compile(IReadOnlyList<string>, ScriptOptions) gives body for options,
found without loading or running anything: the outcome kept for the text when there is
one, otherwise the same shape check and the same compilation of the same source, emitted
to no stream, its script made with one loader shared by every check — so checking a text,
as an editor does on every change, loads no assembly and keeps nothing, not even an
assembly load context. Empty when the formula compiles.
public static IReadOnlyList<StepVariableCompiler.Error> Check(string body, ScriptOptions options)
Parameters
bodystringThe formula; null reads as empty.
optionsScriptOptionsThe script options to compile with; null reads as Default.
Returns
Compile(IReadOnlyList<string>, ScriptOptions)
Compiles bodies, each text once for options (an
outcome already kept is returned as it is): all in one compilation when they compile; when
that one has errors, the formulas the errors are placed in fail with them and the others are
compiled together again, down to one formula at a time when the compiler places an error on
no formula (one it puts on the lambda around a formula). One formula's error thus keeps no
other from compiling, and a list with one bad formula costs two compilations. A body that is
not one expression or one block is not compiled at all. The results are in the order of
bodies. When the compiler itself throws, the formulas still to compile
fail with CompilerCannotRunErrorId and the message, and are not kept; the
outcomes already kept stand.
public static IReadOnlyList<StepVariableCompiler.Result> Compile(IReadOnlyList<string> bodies, ScriptOptions options)
Parameters
bodiesIReadOnlyList<string>The formulas (Body); null reads as empty.
optionsScriptOptionsThe script options to compile with (references and imports); null reads as Default.