Class LocalVariableLookup
- Namespace
- Hi.NcParsers.EvaluationSyntaxs.Evaluation
- Assembly
- HiMech.dll
Reads Fanuc-style local macro variables (#1-#33) from
Vars.Local on the current SyntaxPiece JSON,
falling back to the immediately previous block when they share the
same MacroFrame id. Self-gates the id range
so the evaluator's
RuntimeVariableLookups chain can
fall through to the next lookup for out-of-range keys.
Two-step lookup (mirrors VolatileVariableLookup): the current block sees writes that FanucMacroCallSyntax stamped at inline time (the call-line argument bindings) and writes that FanucLocalVariableReadingSyntax applied on this block before the lookup runs; the previous block (frame-checked) supplies body-internal writes from the prior block in the same macro frame. Looking past the previous block is unnecessary because the reader carries forward block-by-block within a frame.
Frame isolation via MacroFrame: a previous block whose frame id differs from the current block's is skipped — a macro body's body-internal locals are invisible to the caller after return, and the caller's main-frame locals are invisible inside the macro. M98/M198 subprogram inlining (SubProgramCallSyntax) deliberately does not stamp MacroFrame on its inlined blocks, so the callee inherits the caller's frame and sees the caller's locals — matching real Fanuc M98 semantics.
Stateless and dependency-free — instances are interchangeable.
public class LocalVariableLookup : IRuntimeVariableLookup, IMakeXmlSource
- Inheritance
-
LocalVariableLookup
- Implements
- Inherited Members
- Extension Methods
Constructors
LocalVariableLookup()
Default constructor.
public LocalVariableLookup()
LocalVariableLookup(XElement)
Loads from an XML element produced by MakeXmlSource(string, string, bool). Stateless — no fields to deserialise.
public LocalVariableLookup(XElement src)
Parameters
srcXElement
Fields
LocalMax
Inclusive upper bound of the macro-local range (#33).
public const int LocalMax = 33
Field Value
LocalMin
Inclusive lower bound of the macro-local range (#1).
public const int LocalMin = 1
Field Value
Properties
XName
XML element name for Generators registration.
public static string XName { get; }
Property Value
Methods
Get(string, LazyLinkedListNode<SyntaxPiece>, IReadOnlyList<INcDependency>)
Returns the value of the variable identified by key
in the context of node and
dependencies, or null if the key is outside
this lookup's range or the value is vacant.
public double? Get(string key, LazyLinkedListNode<SyntaxPiece> node, IReadOnlyList<INcDependency> dependencies)
Parameters
keystringnodeLazyLinkedListNode<SyntaxPiece>dependenciesIReadOnlyList<INcDependency>
Returns
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
Reg(XFactory)
Registers this type's deserializer with the given XFactory
(or Default when factory is
null). Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory