diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-09-26 09:11:33 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-09-26 09:11:33 +0200 |
commit | c389c4fc8b65357e8075731323f4ba188817c134 (patch) | |
tree | 58457b56b7bac1da744c5f4ea6c4930ee6032e67 /src | |
parent | 8269262a63906c16f4fc2fd3c17fc91216eb7f09 (diff) | |
download | ghdl-c389c4fc8b65357e8075731323f4ba188817c134.tar.gz ghdl-c389c4fc8b65357e8075731323f4ba188817c134.tar.bz2 ghdl-c389c4fc8b65357e8075731323f4ba188817c134.zip |
synth: minor refactoring. Move In_Bounds/In_Range to synth-objtypes.
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-expr.adb | 10 | ||||
-rw-r--r-- | src/synth/synth-objtypes.adb | 20 | ||||
-rw-r--r-- | src/synth/synth-objtypes.ads | 3 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 10 | ||||
-rw-r--r-- | src/synth/synth-stmts.ads | 1 |
5 files changed, 23 insertions, 21 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 8d48eb86c..42621d3ec 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1072,16 +1072,6 @@ package body Synth.Expr is end case; end Synth_Name; - function In_Bounds (Bnd : Bound_Type; V : Int32) return Boolean is - begin - case Bnd.Dir is - when Dir_To => - return V >= Bnd.Left and then V <= Bnd.Right; - when Dir_Downto => - return V <= Bnd.Left and then V >= Bnd.Right; - end case; - end In_Bounds; - -- Convert index IDX in PFX to an offset. -- SYN_INST and LOC are used in case of error. function Index_To_Offset diff --git a/src/synth/synth-objtypes.adb b/src/synth/synth-objtypes.adb index 585605190..25857f065 100644 --- a/src/synth/synth-objtypes.adb +++ b/src/synth/synth-objtypes.adb @@ -156,6 +156,26 @@ package body Synth.Objtypes is return W; end Discrete_Range_Width; + function In_Bounds (Bnd : Bound_Type; V : Int32) return Boolean is + begin + case Bnd.Dir is + when Dir_To => + return V >= Bnd.Left and then V <= Bnd.Right; + when Dir_Downto => + return V <= Bnd.Left and then V >= Bnd.Right; + end case; + end In_Bounds; + + function In_Range (Rng : Discrete_Range_Type; V : Int64) return Boolean is + begin + case Rng.Dir is + when Dir_To => + return V >= Rng.Left and then V <= Rng.Right; + when Dir_Downto => + return V <= Rng.Left and then V >= Rng.Right; + end case; + end In_Range; + function Create_Bit_Type return Type_Acc is subtype Bit_Type_Type is Type_Type (Type_Bit); diff --git a/src/synth/synth-objtypes.ads b/src/synth/synth-objtypes.ads index 36a1b64cb..dfc0f732b 100644 --- a/src/synth/synth-objtypes.ads +++ b/src/synth/synth-objtypes.ads @@ -224,6 +224,9 @@ package Synth.Objtypes is function Create_Protected_Type return Type_Acc; + function In_Bounds (Bnd : Bound_Type; V : Int32) return Boolean; + function In_Range (Rng : Discrete_Range_Type; V : Int64) return Boolean; + -- Return the bounds of dimension DIM of a vector/array. For a vector, -- DIM must be 1. function Get_Array_Bound (Typ : Type_Acc; Dim : Dim_Type) diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index b5d10b084..cdb52a66c 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -2195,16 +2195,6 @@ package body Synth.Stmts is end case; end Synth_Procedure_Call; - function In_Range (Rng : Discrete_Range_Type; V : Int64) return Boolean is - begin - case Rng.Dir is - when Dir_To => - return V >= Rng.Left and then V <= Rng.Right; - when Dir_Downto => - return V <= Rng.Left and then V >= Rng.Right; - end case; - end In_Range; - procedure Update_Index (Rng : Discrete_Range_Type; V : in out Valtyp) is T : Int64; diff --git a/src/synth/synth-stmts.ads b/src/synth/synth-stmts.ads index db536e02d..2fd01c17b 100644 --- a/src/synth/synth-stmts.ads +++ b/src/synth/synth-stmts.ads @@ -92,7 +92,6 @@ package Synth.Stmts is (Syn_Inst : Synth_Instance_Acc; Unit : Node); -- For iterators. - function In_Range (Rng : Discrete_Range_Type; V : Int64) return Boolean; procedure Update_Index (Rng : Discrete_Range_Type; V : in out Valtyp); private |