"""
HX v1 Intermediate Representation

Dataclasses for the .hx language IR.
"""

from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class HXMemorySlot:
    """A named memory slot."""
    name: str


@dataclass
class HXVow:
    """A guardian vow/constraint."""
    name: str


@dataclass
class HXStep:
    """A ritual step."""
    name: str
    args: Optional[str] = None


@dataclass
class HXProgram:
    """Complete HX program representation."""
    soulfile_name: str = "unnamed"
    slots: List[HXMemorySlot] = field(default_factory=list)
    vows: List[HXVow] = field(default_factory=list)
    steps: List[HXStep] = field(default_factory=list)

    def to_dict(self) -> dict:
        """Convert to dictionary."""
        return {
            "soulfile_name": self.soulfile_name,
            "slots": [s.name for s in self.slots],
            "vows": [v.name for v in self.vows],
            "steps": [{"name": s.name, "args": s.args} for s in self.steps],
        }
