From 171548c9d708fc13f5b6d3edde30630ee04bd06e Mon Sep 17 00:00:00 2001 From: gingold Date: Tue, 22 Nov 2005 16:09:10 +0000 Subject: more optimizations + bug fixes --- translate/grt/grt-astdio.adb | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'translate/grt/grt-astdio.adb') diff --git a/translate/grt/grt-astdio.adb b/translate/grt/grt-astdio.adb index de28094..ea1b471 100644 --- a/translate/grt/grt-astdio.adb +++ b/translate/grt/grt-astdio.adb @@ -95,7 +95,7 @@ package body Grt.Astdio is end if; end Put_Str_Len; - generic + generic type Ntype is range <>; Max_Len : Natural; procedure Put_Ntype (Stream : FILEs; N : Ntype); @@ -106,13 +106,14 @@ package body Grt.Astdio is P : Natural := Str'Last; V : Ntype; begin + -- V is negativ. if N > 0 then V := -N; else V := N; end if; loop - Str (P) := Character'Val (48 - (V rem 10)); + Str (P) := Character'Val (48 - (V rem 10)); -- V is <= 0. V := V / 10; exit when V = 0; P := P - 1; @@ -124,13 +125,38 @@ package body Grt.Astdio is Put (Stream, Str (P .. Max_Len)); end Put_Ntype; - procedure Put_I32_1 is new Put_Ntype (Ntype => Ghdl_I32, Max_Len => 11); + generic + type Utype is mod <>; + Max_Len : Natural; + procedure Put_Utype (Stream : FILEs; N : Utype); + + procedure Put_Utype (Stream : FILEs; N : Utype) + is + Str : String (1 .. Max_Len); + P : Natural := Str'Last; + V : Utype := N; + begin + loop + Str (P) := Character'Val (48 + (V rem 10)); + V := V / 10; + exit when V = 0; + P := P - 1; + end loop; + Put (Stream, Str (P .. Max_Len)); + end Put_Utype; + procedure Put_I32_1 is new Put_Ntype (Ntype => Ghdl_I32, Max_Len => 11); procedure Put_I32 (Stream : FILEs; I32 : Ghdl_I32) renames Put_I32_1; + procedure Put_U32_1 is new Put_Utype (Utype => Ghdl_U32, Max_Len => 11); + procedure Put_U32 (Stream : FILEs; U32 : Ghdl_U32) renames Put_U32_1; + procedure Put_I64_1 is new Put_Ntype (Ntype => Ghdl_I64, Max_Len => 20); procedure Put_I64 (Stream : FILEs; I64 : Ghdl_I64) renames Put_I64_1; + procedure Put_U64_1 is new Put_Utype (Utype => Ghdl_U64, Max_Len => 20); + procedure Put_U64 (Stream : FILEs; U64 : Ghdl_U64) renames Put_U64_1; + procedure Put_F64 (Stream : FILEs; F64 : Ghdl_F64) is procedure fprintf (Stream : FILEs; -- cgit