diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-05-28 06:36:57 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-05-28 06:36:57 +0200 |
commit | c24ef07771e91f11206f88d3c912941f942f4e4b (patch) | |
tree | 0e06e2872d12d830609a18368c86cf3e5ee5aac1 /src/vhdl/vhdl-evaluation.adb | |
parent | 67422d11f9c5f4d8c97c10daf1a5e0d58d2b2df8 (diff) | |
download | ghdl-c24ef07771e91f11206f88d3c912941f942f4e4b.tar.gz ghdl-c24ef07771e91f11206f88d3c912941f942f4e4b.tar.bz2 ghdl-c24ef07771e91f11206f88d3c912941f942f4e4b.zip |
vhdl: get rid of Get/Set_Physical_Unit.
Use integer_literal for evaluated physical literals.
Diffstat (limited to 'src/vhdl/vhdl-evaluation.adb')
-rw-r--r-- | src/vhdl/vhdl-evaluation.adb | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb index 71ee3b0d7..52b489816 100644 --- a/src/vhdl/vhdl-evaluation.adb +++ b/src/vhdl/vhdl-evaluation.adb @@ -48,9 +48,9 @@ package body Vhdl.Evaluation is when Iir_Kind_Physical_Int_Literal | Iir_Kind_Physical_Fp_Literal => -- Extract Unit. - Unit := Get_Physical_Literal (Get_Physical_Unit (Expr)); - pragma Assert (Get_Physical_Unit (Unit) - = Get_Primary_Unit (Get_Type (Unit))); + Unit := Get_Physical_Literal + (Get_Named_Entity (Get_Unit_Name (Expr))); + pragma Assert (Get_Kind (Unit) = Iir_Kind_Integer_Literal); case Kind is when Iir_Kind_Physical_Int_Literal => return Get_Value (Expr) * Get_Value (Unit); @@ -59,6 +59,8 @@ package body Vhdl.Evaluation is when others => raise Program_Error; end case; + when Iir_Kind_Integer_Literal => + return Get_Value (Expr); when Iir_Kind_Unit_Declaration => return Get_Value (Get_Physical_Literal (Expr)); when others => @@ -81,7 +83,7 @@ package body Vhdl.Evaluation is end Build_Integer; function Build_Floating (Val : Fp64; Origin : Iir) - return Iir_Floating_Point_Literal + return Iir_Floating_Point_Literal is Res : Iir_Floating_Point_Literal; begin @@ -111,15 +113,12 @@ package body Vhdl.Evaluation is end Build_Enumeration_Constant; function Build_Physical (Val : Int64; Origin : Iir) - return Iir_Physical_Int_Literal + return Iir_Integer_Literal is - Res : Iir_Physical_Int_Literal; - Unit_Name : Iir; + Res : Iir_Integer_Literal; begin - Res := Create_Iir (Iir_Kind_Physical_Int_Literal); + Res := Create_Iir (Iir_Kind_Integer_Literal); Location_Copy (Res, Origin); - Unit_Name := Get_Primary_Unit (Get_Base_Type (Get_Type (Origin))); - Set_Physical_Unit (Res, Unit_Name); Set_Value (Res, Val); Set_Type (Res, Get_Type (Origin)); Set_Literal_Origin (Res, Origin); @@ -214,16 +213,10 @@ package body Vhdl.Evaluation is (Iir_Index32 (Get_Enum_Pos (Val)), Origin); when Iir_Kind_Physical_Int_Literal - | Iir_Kind_Physical_Fp_Literal => - Res := Create_Iir (Iir_Kind_Physical_Int_Literal); - Set_Physical_Unit (Res, Get_Primary_Unit - (Get_Base_Type (Get_Type (Origin)))); - Set_Value (Res, Get_Physical_Value (Val)); - - when Iir_Kind_Unit_Declaration => - Res := Create_Iir (Iir_Kind_Physical_Int_Literal); + | Iir_Kind_Physical_Fp_Literal + | Iir_Kind_Unit_Declaration => + Res := Create_Iir (Iir_Kind_Integer_Literal); Set_Value (Res, Get_Physical_Value (Val)); - Set_Physical_Unit (Res, Get_Primary_Unit (Get_Type (Val))); when Iir_Kind_String_Literal8 => Res := Create_Iir (Iir_Kind_String_Literal8); |