Class MacroInlineUtil
- Namespace
- Hi.NcParsers.EvaluationSyntaxs
- Assembly
- HiMech.dll
Shared inline mechanism for Fanuc Custom Macro B body expansion —
used by both FanucMacroCallSyntax (one-shot) and
FanucModalMacroSyntax's expansion phase (modal trigger). Both
callers do the same four things on every produced
SyntaxPiece: stamp a FanucMacroCall
clone, a fresh MacroFrame id, the argument bindings
into Vars.Local, and the pushed CallStack.
Centralising lets the two call sites stay in lock-step — frame
allocation, file-index allocation, and the inline-piece JSON shape are
guaranteed identical.
Frame ids share the same FileIndexCounterDependency counter as file indices — both just need within-session uniqueness and the counter is rewound on session start in lock-step with the pipeline. The main NC file is allocated index 0 first, so all inline frame ids land at > 0 and never collide with main.
public static class MacroInlineUtil
- Inheritance
-
MacroInlineUtil
- Inherited Members
Methods
ApplyLocalBindings(JsonObject, IReadOnlyDictionary<string, double>)
Writes the resolved #N → value bindings into
Vars.Local on the given block. No-op when
bindings is empty. Always overwrites any
pre-existing Vars.Local on the block — for inlined macro
bodies this is a fresh stamp.
public static void ApplyLocalBindings(JsonObject json, IReadOnlyDictionary<string, double> bindings)
Parameters
jsonJsonObjectbindingsIReadOnlyDictionary<string, double>
BuildInlinedPieces(ResolvedFile, int, IReadOnlyDictionary<string, double>, JsonObject, JsonObject, FileIndexCounterDependency, ISegmenter, List<INcDependency>, int, NcDiagnosticProgress)
Yields L repetitions of the macro body as inline-ready
SyntaxPiece entries. Each repetition gets its own
freshly-allocated FileIndex and MacroFrame
id; every yielded piece is stamped with a deep clone of
callRecord, the frame id, the resolved
#N → value bindings, and a deep clone of
pushedCallStack when one is given. The caller passes
the result to PrependSource(IEnumerable<T>) on
the source layer. SentenceIndex allocation happens inside
GetSyntaxPieces(ISegmenter, List<INcDependency>, IEnumerable<IndexedFileLine>, int, NcDiagnosticProgress, CancellationToken) via the session's
FileIndexCounterDependency sibling
SentenceIndexCounterDependency;
sentenceIndexBegin is only the legacy fallback
numbering for counter-less presets. This overload runs the body on the
default (never cancelled) token; the call syntaxes use the overload that
takes the run's token.
public static IEnumerable<SyntaxPiece> BuildInlinedPieces(MacroFileResolver.ResolvedFile resolvedFile, int l, IReadOnlyDictionary<string, double> bindings, JsonObject callRecord, JsonObject pushedCallStack, FileIndexCounterDependency counterDep, ISegmenter segmenter, List<INcDependency> ncDependencyList, int sentenceIndexBegin, NcDiagnosticProgress ncDiagnosticProgress)
Parameters
resolvedFileMacroFileResolver.ResolvedFilelintbindingsIReadOnlyDictionary<string, double>callRecordJsonObjectpushedCallStackJsonObjectcounterDepFileIndexCounterDependencysegmenterISegmenterncDependencyListList<INcDependency>sentenceIndexBeginintncDiagnosticProgressNcDiagnosticProgress
Returns
BuildInlinedPieces(ResolvedFile, int, IReadOnlyDictionary<string, double>, JsonObject, JsonObject, FileIndexCounterDependency, ISegmenter, List<INcDependency>, int, NcDiagnosticProgress, CancellationToken)
Yields L repetitions of the macro body as inline-ready
SyntaxPiece entries for the run in progress, as the
overload without a token does (each repetition its own
FileIndex and MacroFrame id; every piece stamped
with the call record, the frame id, the bindings and the pushed
CallStack). cancellationToken is the
run's token, read by the calling syntax when it builds the call
(TokenOf(List<INcDependency>)): cancelled, the body
ends before its next piece and no further repetition takes a file index
or opens the file.
public static IEnumerable<SyntaxPiece> BuildInlinedPieces(MacroFileResolver.ResolvedFile resolvedFile, int l, IReadOnlyDictionary<string, double> bindings, JsonObject callRecord, JsonObject pushedCallStack, FileIndexCounterDependency counterDep, ISegmenter segmenter, List<INcDependency> ncDependencyList, int sentenceIndexBegin, NcDiagnosticProgress ncDiagnosticProgress, CancellationToken cancellationToken)
Parameters
resolvedFileMacroFileResolver.ResolvedFilelintbindingsIReadOnlyDictionary<string, double>callRecordJsonObjectpushedCallStackJsonObjectcounterDepFileIndexCounterDependencysegmenterISegmenterncDependencyListList<INcDependency>sentenceIndexBeginintncDiagnosticProgressNcDiagnosticProgresscancellationTokenCancellationToken
Returns
BuildLocalBindings(JsonObject)
Translates the argument-letter map captured by the host call
({ “A”: 1.5, “B”: 2.0, ... }) into the #N → value
bindings the macro body's expression evaluator will read off
Vars.Local. Skips non-numeric (string) args — variable
references or expressions VariableEvaluatorSyntax
could not resolve; writing a string into Vars.Local would
just propagate the residue, so the local stays vacant. Silent by
itself: nothing downstream sees the skipped arg (the host's
Parsing sub-object is consumed with the call), so the call
site reports it through ReportUnevaluatedArgs(JsonObject, string, ISentenceCarrier, NcDiagnosticProgress) — once
per call line, not once per modal expansion.
public static Dictionary<string, double> BuildLocalBindings(JsonObject args)
Parameters
argsJsonObject
Returns
ReportUnevaluatedArgs(JsonObject, string, ISentenceCarrier, NcDiagnosticProgress)
Reports every argument letter of a macro call line whose value is
still a string — a variable reference or bracket expression the
evaluator could not resolve (H[#999] with #999
vacant). BuildLocalBindings(JsonObject) leaves the matching local
vacant, so the macro body would otherwise run on a missing argument
with no message naming the call line. Called on the call line
itself: the G65 host block, or the G66 setup block
(whose stored args every later expansion reuses verbatim).
The message also names the one cause that is not in the NC program: a controller saved while the call syntaxes still ran ahead of VariableEvaluatorSyntax evaluates no call word at all — a reordering no legacy patch carries — so every variable-driven argument lands here until the controller is re-created from its brand preset.
public static void ReportUnevaluatedArgs(JsonObject args, string term, ISentenceCarrier sentenceCarrier, NcDiagnosticProgress ncDiagnosticProgress)
Parameters
argsJsonObjectArgument-letter map of the call line.
termstringCall code for the message (
G65/G66).sentenceCarrierISentenceCarrierThe call line.
ncDiagnosticProgressNcDiagnosticProgressDiagnostic sink.