diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-26 18:56:00 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-26 21:56:37 +0100 |
commit | 91951f084348ce259de838e7a42cad8621136b81 (patch) | |
tree | ee324aea8e3dd6c8df7c64d864572c11ee46b98f | |
parent | 5d31b22337d176a7ff6d2df2adde742bc57a80f1 (diff) | |
download | ghdl-91951f084348ce259de838e7a42cad8621136b81.tar.gz ghdl-91951f084348ce259de838e7a42cad8621136b81.tar.bz2 ghdl-91951f084348ce259de838e7a42cad8621136b81.zip |
vhdl-evaluation: abstraction
-rw-r--r-- | src/vhdl/vhdl-evaluation.adb | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb index bf46ee9b9..d92e859b3 100644 --- a/src/vhdl/vhdl-evaluation.adb +++ b/src/vhdl/vhdl-evaluation.adb @@ -4194,6 +4194,17 @@ package body Vhdl.Evaluation is end if; end Eval_Expr_Check_If_Static; + function Null_Int_Range + (Dir : Direction_Type; L, R : Int64) return Boolean is + begin + case Dir is + when Dir_To => + return L > R; + when Dir_Downto => + return L < R; + end case; + end Null_Int_Range; + function Int_In_Range (Val : Int64; Dir : Direction_Type; L, R : Int64) return Boolean is begin @@ -4476,18 +4487,7 @@ package body Vhdl.Evaluation is when Iir_Kinds_Discrete_Type_Definition | Iir_Kind_Physical_Type_Definition | Iir_Kind_Physical_Subtype_Definition => - declare - L, R : Int64; - begin - L := Eval_Pos (L_Expr); - R := Eval_Pos (R_Expr); - case Dir is - when Dir_To => - return L > R; - when Dir_Downto => - return L < R; - end case; - end; + return Null_Int_Range (Dir, Eval_Pos (L_Expr), Eval_Pos (R_Expr)); when Iir_Kind_Floating_Subtype_Definition | Iir_Kind_Floating_Type_Definition => declare @@ -4657,12 +4657,7 @@ package body Vhdl.Evaluation is begin Left := Eval_Pos (Get_Left_Limit (Rng)); Right := Eval_Pos (Get_Right_Limit (Rng)); - case Get_Direction (Rng) is - when Dir_To => - return Right < Left; - when Dir_Downto => - return Left < Right; - end case; + return Null_Int_Range (Get_Direction (Rng), Left, Right); end Eval_Is_Null_Discrete_Range; function Eval_Pos (Expr : Iir) return Int64 is |