summaryrefslogtreecommitdiff
path: root/src/grt/grt-images.adb
diff options
context:
space:
mode:
authorTristan Gingold2015-05-14 22:01:49 +0200
committerTristan Gingold2015-05-14 22:01:49 +0200
commit15c60251e6d7f3d7f3aaa0a379f24f076e6bc047 (patch)
tree4045a12c872dfaa388d8d38238c99d91800daa0f /src/grt/grt-images.adb
parentf1ee709724aff4a8c532cb20339c54cf142f4a02 (diff)
downloadghdl-15c60251e6d7f3d7f3aaa0a379f24f076e6bc047.tar.gz
ghdl-15c60251e6d7f3d7f3aaa0a379f24f076e6bc047.tar.bz2
ghdl-15c60251e6d7f3d7f3aaa0a379f24f076e6bc047.zip
Handle evaluation of to_string for enumeration and integer types.
Handled extended names for to_string. Fix ticket 61.
Diffstat (limited to 'src/grt/grt-images.adb')
-rw-r--r--src/grt/grt-images.adb36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/grt/grt-images.adb b/src/grt/grt-images.adb
index c085380..272c423 100644
--- a/src/grt/grt-images.adb
+++ b/src/grt/grt-images.adb
@@ -242,13 +242,47 @@ package body Grt.Images is
is
Enum_Rti : Ghdl_Rtin_Type_Enum_Acc;
Str : Ghdl_C_String;
+ Len : Natural;
begin
Enum_Rti := To_Ghdl_Rtin_Type_Enum_Acc (Rti);
Str := Enum_Rti.Names (Index);
if Str (1) = ''' then
Return_String (Res, Str (2 .. 2));
else
- Return_String (Res, Str (1 .. strlen (Str)));
+ Len := strlen (Str);
+ if Str (1) /= '\' then
+ Return_String (Res, Str (1 .. Len));
+ else
+ -- Extended string. Compute length.
+ declare
+ Skip : Boolean;
+ Elen : Ghdl_Index_Type;
+ Epos : Ghdl_Index_Type;
+ begin
+ Skip := False;
+ Elen := 0;
+ for I in 2 .. Len - 1 loop
+ if Skip then
+ Skip := False;
+ else
+ Elen := Elen + 1;
+ Skip := Str (I) = '\';
+ end if;
+ end loop;
+ Res.Base := To_Std_String_Basep (Ghdl_Stack2_Allocate (Elen));
+ Epos := 0;
+ for I in 2 .. Len - 1 loop
+ if Skip then
+ Skip := False;
+ else
+ Res.Base (Epos) := Str (I);
+ Epos := Epos + 1;
+ Skip := Str (I) = '\';
+ end if;
+ end loop;
+ Set_String_Bounds (Res, Elen);
+ end;
+ end if;
end if;
end To_String_Enum;