diff options
author | gingold | 2005-11-22 16:09:10 +0000 |
---|---|---|
committer | gingold | 2005-11-22 16:09:10 +0000 |
commit | 171548c9d708fc13f5b6d3edde30630ee04bd06e (patch) | |
tree | 181c2a4f230ec445277ec4ed6a25c73f25aab3e2 /translate/grt/grt-astdio.adb | |
parent | 20e31a50417e5452dcc5797d27dc1383253e3161 (diff) | |
download | ghdl-171548c9d708fc13f5b6d3edde30630ee04bd06e.tar.gz ghdl-171548c9d708fc13f5b6d3edde30630ee04bd06e.tar.bz2 ghdl-171548c9d708fc13f5b6d3edde30630ee04bd06e.zip |
more optimizations + bug fixes
Diffstat (limited to 'translate/grt/grt-astdio.adb')
-rw-r--r-- | translate/grt/grt-astdio.adb | 32 |
1 files changed, 29 insertions, 3 deletions
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; |