diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-25 18:43:13 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-25 18:43:13 +0100 |
commit | 4030f025b21a9570f03137f5342b12aa2d200c4d (patch) | |
tree | f9fbdf39cc762692c2e0615bea8091b805ba3e14 /src | |
parent | 7c7695812a7488dfb463ec1f0d4244550e5998c8 (diff) | |
download | ghdl-4030f025b21a9570f03137f5342b12aa2d200c4d.tar.gz ghdl-4030f025b21a9570f03137f5342b12aa2d200c4d.tar.bz2 ghdl-4030f025b21a9570f03137f5342b12aa2d200c4d.zip |
synth: introduce value_to_string.
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-expr.adb | 5 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 10 | ||||
-rw-r--r-- | src/synth/synth-values.ads | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 1a55372e5..6a3408844 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1075,13 +1075,10 @@ package body Synth.Expr is end if; declare - Str : String (1 .. Natural (V.Arr.Len)); + Str : constant String := Value_To_String (V); Res_N : Node; Val : Int64; begin - for I in V.Arr.V'Range loop - Str (Natural (I)) := Character'Val (V.Arr.V (I).Scal); - end loop; case Get_Kind (Btype) is when Iir_Kind_Enumeration_Type_Definition => Res_N := Eval_Value_Attribute (Str, Etype, Attr); diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index 3d4459be3..f2a9d7033 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -943,6 +943,16 @@ package body Synth.Values is end case; end Create_Value_Default; + function Value_To_String (Val : Value_Acc) return String + is + Str : String (1 .. Natural (Val.Arr.Len)); + begin + for I in Val.Arr.V'Range loop + Str (Natural (I)) := Character'Val (Val.Arr.V (I).Scal); + end loop; + return Str; + end Value_To_String; + procedure Init is begin Instance_Pool := Global_Pool'Access; diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index 7c4ec8b7c..2bbf70810 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -357,6 +357,10 @@ package Synth.Values is -- Create a default initial value for TYP. function Create_Value_Default (Typ : Type_Acc) return Value_Acc; + -- Convert a value to a string. The value must be a const_array of scalar, + -- which represent characters. + function Value_To_String (Val : Value_Acc) return String; + procedure Init; -- Set by Init. |