namespace ScadaLink.Commons.Types.Scripts;

/// <summary>
/// Where a compiled script sits in the composition tree. Computed at
/// flattening time and seeded into the script's globals at execution time
/// so <c>Attributes["X"]</c> / <c>Parent.X</c> can prepend the right
/// path-prefix when delegating to the existing flat
/// <c>Instance.GetAttribute</c> / <c>Instance.SetAttribute</c> /
/// <c>Instance.CallScript</c> APIs.
/// </summary>
public sealed record ScriptScope(string SelfPath, string? ParentPath)
{
    /// <summary>Scope for a script directly on the root template (no compositions).</summary>
    public static readonly ScriptScope Root = new("", null);

    public bool HasParent => ParentPath != null;
}
