diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-10-17 06:53:50 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-10-17 06:53:50 +0200 |
commit | f7a7752f1e3bfe9ff164795bd94b39d74005bf3a (patch) | |
tree | d815e7d0291e09aadfe3ad78fc28d6162db1915b /src/dyn_interning.adb | |
parent | 2bcb1aba731ea647f9a8adcbd34ecef84aa68ec9 (diff) | |
download | ghdl-f7a7752f1e3bfe9ff164795bd94b39d74005bf3a.tar.gz ghdl-f7a7752f1e3bfe9ff164795bd94b39d74005bf3a.tar.bz2 ghdl-f7a7752f1e3bfe9ff164795bd94b39d74005bf3a.zip |
syn_interning: add get_index.
Diffstat (limited to 'src/dyn_interning.adb')
-rw-r--r-- | src/dyn_interning.adb | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/dyn_interning.adb b/src/dyn_interning.adb index adda22437..96f4edc04 100644 --- a/src/dyn_interning.adb +++ b/src/dyn_interning.adb @@ -68,12 +68,11 @@ package body Dyn_Interning is Deallocate (Old_Hash_Table); end Expand; - procedure Get - (Inst : in out Instance; Params : Params_Type; Res : out Object_Type) + procedure Get_Index + (Inst : in out Instance; Params : Params_Type; Idx : out Index_Type) is Hash_Value : Hash_Value_Type; Hash_Index : Hash_Value_Type; - Idx : Index_Type; begin -- Check if the package was initialized. pragma Assert (Inst.Hash_Table /= null); @@ -87,7 +86,6 @@ package body Dyn_Interning is E : Element_Wrapper renames Inst.Els.Table (Idx); begin if E.Hash = Hash_Value and then Equal (E.Obj, Params) then - Res := E.Obj; return; end if; Idx := E.Next; @@ -102,14 +100,29 @@ package body Dyn_Interning is Hash_Index := Hash_Value and (Inst.Size - 1); end if; - Res := Build (Params); + declare + Res : Object_Type; + begin + Res := Build (Params); + + -- Insert. + Wrapper_Tables.Append (Inst.Els, + (Hash => Hash_Value, + Next => Inst.Hash_Table (Hash_Index), + Obj => Res)); + Inst.Hash_Table (Hash_Index) := Wrapper_Tables.Last (Inst.Els); + end; + + Idx := Wrapper_Tables.Last (Inst.Els); + end Get_Index; - -- Insert. - Wrapper_Tables.Append (Inst.Els, - (Hash => Hash_Value, - Next => Inst.Hash_Table (Hash_Index), - Obj => Res)); - Inst.Hash_Table (Hash_Index) := Wrapper_Tables.Last (Inst.Els); + procedure Get + (Inst : in out Instance; Params : Params_Type; Res : out Object_Type) + is + Idx : Index_Type; + begin + Get_Index (Inst, Params, Idx); + Res := Get_By_Index (Inst, Idx); end Get; function Last_Index (Inst : Instance) return Index_Type is |