Table of Contents

Class CallStackUtil

Namespace
Hi.NcParsers.EvaluationSyntaxs
Assembly
HiMech.dll

Push / pop helpers for the per-block CallStack section. Both produce a fresh deep-cloned JsonObject ready to stamp onto an inlined piece (push site) or onto an M99 return block (pop site); the caller is responsible for deep-cloning again if it distributes the same stamp across multiple pieces of an L-repetition.

Every piece of an inlined call body carries the pushed stack from the moment it is inlined, so a return block pops its own section, and an M99 P{seq} first reads the top frame's CallerFilePath off it. ModalCarrySyntax copies the previous block's section, at the Logic stage, onto a block that has none: the main program's blocks after a return, blocks a jump re-segments and the pieces of a section repeat whose host has no stack (a Siemens REPEAT or Heidenhain CALL LBL REP propagates the host's stack onto its pieces, so a call made from inside the section pushes onto it). Each block is then self-contained for cache-dump readers, while an Evaluation-stage reader sees only the stamped sections.

public static class CallStackUtil
Inheritance
CallStackUtil
Inherited Members

Methods

BuildPoppedCallStack(JsonObject)

Builds the post-pop CallStack section to stamp onto a return block (M99; M17/RET, LBL 0, END PGM). Reads the stack the block carries (stamped when its body was inlined), deep-clones it, and drops the top frame. Returns null when there was no frame to pop (a return in the main file with no caller — the runner treats this as program-end via the implicit fall-through; no stamp is needed).

public static JsonObject BuildPoppedCallStack(JsonObject hostJson)

Parameters

hostJson JsonObject

The return block's JSON object, before this pop runs.

Returns

JsonObject

BuildPushedCallStack(JsonObject, string)

Builds the post-push CallStack section to stamp onto every inlined-body piece of a call. Reads the host block's current stack (defaulting to empty when absent — main-frame caller), deep-clones it, and appends a new CallFrame whose CallerFilePath records where the call originated. The returned JsonObject can be safely deep-cloned by the caller for each piece in an L-repetition.

public static JsonObject BuildPushedCallStack(JsonObject hostJson, string callerFilePath)

Parameters

hostJson JsonObject

The call-host block's JSON object.

callerFilePath string

Project-relative path of the host file (typically FilePath on the host piece).

Returns

JsonObject

GetTopCallerFilePath(JsonObject)

Returns the top frame's CallerFilePath from the given block's CallStack section, or null when the stack is empty or absent (block is in the main frame).

public static string GetTopCallerFilePath(JsonObject hostJson)

Parameters

hostJson JsonObject

Returns

string