diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-11-16 20:09:18 +1300 |
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-11-16 20:09:18 +1300 |
| commit | 203222f4ffbdaf23a30ab390a7ad765cfef0c008 (patch) | |
| tree | 6d2ebaf8f538e836f5244238d130dc9d438fee3c /src/kompsos-pretty_print.adb | |
| parent | 2ccc4c52288ac7f0915c1a9da7cad0e957af2ebb (diff) | |
Variable counting handled properly on a per-State basis
Diffstat (limited to 'src/kompsos-pretty_print.adb')
| -rw-r--r-- | src/kompsos-pretty_print.adb | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/src/kompsos-pretty_print.adb b/src/kompsos-pretty_print.adb index 8739af8..772c0cd 100644 --- a/src/kompsos-pretty_print.adb +++ b/src/kompsos-pretty_print.adb @@ -45,7 +45,7 @@ package body Kompsos.Pretty_Print is (Item : in Variable) return String is begin - return "Var#" & Image (Item.Ident) & + return "Vargen#" & Image (ID_Number (Item.Ident)) & (if SU.Length (Item.Name) /= 0 then "/" & SU.To_String (Item.Name) else ""); @@ -95,16 +95,29 @@ package body Kompsos.Pretty_Print is return String is Result : SU.Unbounded_String; - My_Var : Variable; begin + SU.Append (Result, Latin.HT & "Generation:"); + if Item.Ident.Is_Empty then + SU.Append (Result, " N/A" & Latin.LF); + else + SU.Append (Result, Latin.LF); + for Iter in Item.Ident.Iterate loop + SU.Append (Result, Latin.HT & Latin.HT & "Vargen#" & + Image (ID_Number (ID_Number_Maps.Key (Iter))) & " => " & + Image (ID_Number (ID_Number_Maps.Element (Iter))) & Latin.LF); + end loop; + end if; SU.Append (Result, Latin.HT & "Variables:"); if Item.LVars.Is_Empty then SU.Append (Result, " N/A" & Latin.LF); else SU.Append (Result, Latin.LF); - for Iter in Item.LVars.Iterate loop - My_Var := (Ident => Name_Maps.Key (Iter), Name => Name_Maps.Element (Iter)); - SU.Append (Result, Latin.HT & Latin.HT & Image (My_Var) & Latin.LF); + for Index in Item.LVars.First_Index .. Item.LVars.Last_Index loop + SU.Append (Result, Latin.HT & Latin.HT & + "Var#" & Image (ID_Number (Index)) & + (if SU.Length (Item.LVars (Index)) /= 0 + then "/" & SU.To_String (Item.LVars (Index)) + else "") & Latin.LF); end loop; end if; SU.Append (Result, Latin.HT & "Substitution:"); @@ -114,7 +127,7 @@ package body Kompsos.Pretty_Print is SU.Append (Result, Latin.LF); for Iter in Item.Subst.Iterate loop SU.Append (Result, Latin.HT & Latin.HT & - Image (Binding_Maps.Key (Iter)) & " => " & + Image (ID_Number (Binding_Maps.Key (Iter))) & " => " & Image (Binding_Maps.Element (Iter)) & Latin.LF); end loop; end if; @@ -125,26 +138,35 @@ package body Kompsos.Pretty_Print is function Image - (Item : in World) + (Item : in out World) return String is Result : SU.Unbounded_String; - Scratch : World := Item; Counter : Positive := 1; begin - if not Scratch.Has_State (Counter) then + if not Item.Has_State (Counter) then return "States: N/A" & Latin.LF; end if; loop SU.Append (Result, "State#" & Image (Counter) & ":" & Latin.LF); - SU.Append (Result, Image (Scratch.Possibles.Constant_Reference (Counter))); + SU.Append (Result, Image (Item.Possibles.Constant_Reference (Counter))); Counter := Counter + 1; - exit when not Scratch.Has_State (Counter); + exit when not Item.Has_State (Counter); end loop; return SU.Slice (Result, 1, SU.Length (Result) - 1); end Image; + function Image_Constant + (Item : in World) + return String + is + Scratch : World := Item; + begin + return Image (Scratch); + end Image_Constant; + + end Kompsos.Pretty_Print; |
