diff options
Diffstat (limited to 'src/grt/grt-values.ads')
-rw-r--r-- | src/grt/grt-values.ads | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/grt/grt-values.ads b/src/grt/grt-values.ads index 1269d194f..c88e1dfc3 100644 --- a/src/grt/grt-values.ads +++ b/src/grt/grt-values.ads @@ -50,15 +50,41 @@ package Grt.Values is function Ghdl_Value_P32 (Str : Std_String_Ptr; Rti : Ghdl_Rti_Access) return Ghdl_I32; - -- Convert S (INIT_POS .. LEN) to a signed integer. - function Value_I64 - (S : Std_String_Basep; Len : Ghdl_Index_Type; Init_Pos : Ghdl_Index_Type) - return Ghdl_I64; - -- Return the value of STR for enumerated type RTI. function Value_Enum (S : Std_String_Basep; Len : Ghdl_Index_Type; Rti : Ghdl_Rti_Access) return Ghdl_Index_Type; + + type Value_Status is + ( + Value_Ok, + Value_Err_No_Digit, -- After sign, at start, after exponent... + Value_Err_Bad_Digit, + Value_Err_Underscore, + Value_Err_Bad_Base, + Value_Err_Bad_End_Sign, -- Missing or mismatch + Value_Err_Bad_Exponent, + Value_Err_Trailing_Chars + ); + + type Value_I64_Result (Status : Value_Status := Value_Ok) is record + case Status is + when Value_Ok => + Val : Ghdl_I64; + when others => + Pos : Ghdl_Index_Type; + end case; + end record; + + -- Convert S (INIT_POS .. LEN) to a signed integer. + function Value_I64 (S : Std_String_Basep; + Len : Ghdl_Index_Type; + Init_Pos : Ghdl_Index_Type) return Value_I64_Result; + + -- Likewise but report any error. + function Value_I64 + (S : Std_String_Basep; Len : Ghdl_Index_Type; Init_Pos : Ghdl_Index_Type) + return Ghdl_I64; private pragma Export (Ada, Ghdl_Value_B1, "__ghdl_value_b1"); pragma Export (C, Ghdl_Value_E8, "__ghdl_value_e8"); |