diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-12-29 08:47:37 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-12-29 09:07:52 +0100 |
commit | c4061a67ec6fcd7495b56c29ca416ea044ff9c78 (patch) | |
tree | 1ba0d5f2eaa59b16872fbb277a5913c3331aad8f /src/vhdl/translate | |
parent | 0861fa6cc62bd4b7e27ad865b50d26f1a53beb47 (diff) | |
download | ghdl-c4061a67ec6fcd7495b56c29ca416ea044ff9c78.tar.gz ghdl-c4061a67ec6fcd7495b56c29ca416ea044ff9c78.tar.bz2 ghdl-c4061a67ec6fcd7495b56c29ca416ea044ff9c78.zip |
trans: reformatting, add predicate for unbounded types.
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 23 | ||||
-rw-r--r-- | src/vhdl/translate/trans.adb | 7 | ||||
-rw-r--r-- | src/vhdl/translate/trans.ads | 15 |
3 files changed, 31 insertions, 14 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 976e263ae..00546dc02 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -998,6 +998,8 @@ package body Trans.Chap3 is is Info : constant Type_Info_Acc := Get_Info (Def); List : constant Iir_List := Get_Elements_Declaration_List (Def); + Is_Unbounded : constant Boolean := + Get_Constraint_State (Def) /= Fully_Constrained; El_List : O_Element_List; El : Iir_Element_Declaration; Field_Info : Ortho_Info_Acc; @@ -1038,7 +1040,9 @@ package body Trans.Chap3 is exit when El = Null_Iir; Field_Info := Get_Info (El); El_Tinfo := Get_Info (Get_Type (El)); - if Is_Complex_Type (El_Tinfo) then + if Is_Complex_Type (El_Tinfo) + or else Is_Unbounded_Type (El_Tinfo) + then -- Always use an offset for a complex type. El_Tnode := Ghdl_Index_Type; else @@ -1051,7 +1055,11 @@ package body Trans.Chap3 is end loop; Finish_Record_Type (El_List, Info.Ortho_Type (Kind)); end loop; - Info.Type_Mode := Type_Mode_Record; + if Is_Unbounded then + Info.Type_Mode := Type_Mode_Unbounded_Record; + else + Info.Type_Mode := Type_Mode_Record; + end if; Finish_Type_Definition (Info); if Need_Size then @@ -1242,9 +1250,8 @@ package body Trans.Chap3 is pragma Assert (Get_Kind (Atype) = Iir_Kind_Access_Type_Definition); Def_Info := Get_Info (Atype); - Finish_Access_Type - (Def_Info.Ortho_Type (Mode_Value), - Get_Ortho_Designated_Type (Atype)); + Finish_Access_Type (Def_Info.Ortho_Type (Mode_Value), + Get_Ortho_Designated_Type (Atype)); Atype := Get_Incomplete_Type_Ref_Chain (Atype); end loop; @@ -2211,14 +2218,12 @@ package body Trans.Chap3 is end if; end Elab_Object_Subtype; - procedure Elab_Type_Declaration (Decl : Iir) - is + procedure Elab_Type_Declaration (Decl : Iir) is begin Elab_Type_Definition (Get_Type_Definition (Decl)); end Elab_Type_Declaration; - procedure Elab_Subtype_Declaration (Decl : Iir_Subtype_Declaration) - is + procedure Elab_Subtype_Declaration (Decl : Iir_Subtype_Declaration) is begin Elab_Type_Definition (Get_Type (Decl)); end Elab_Subtype_Declaration; diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb index 8382e19d3..d6fdbe9d4 100644 --- a/src/vhdl/translate/trans.adb +++ b/src/vhdl/translate/trans.adb @@ -1370,7 +1370,7 @@ package body Trans is function Is_Composite (Info : Type_Info_Acc) return Boolean is begin - return Info.Type_Mode in Type_Mode_Fat; + return Info.Type_Mode in Type_Mode_Composite; end Is_Composite; function Is_Complex_Type (Tinfo : Type_Info_Acc) return Boolean is @@ -1378,6 +1378,11 @@ package body Trans is return Tinfo.C /= null; end Is_Complex_Type; + function Is_Unbounded_Type (Tinfo : Type_Info_Acc) return Boolean is + begin + return Tinfo.Type_Mode in Type_Mode_Unbounded; + end Is_Unbounded_Type; + procedure Free_Node_Infos is Info : Ortho_Info_Acc; diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index 9ca2b9f02..3a3d0b960 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -888,6 +888,9 @@ package Trans is subtype Type_Mode_Fat is Type_Mode_Type range Type_Mode_Record .. Type_Mode_Protected; + subtype Type_Mode_Unbounded is Type_Mode_Type range + Type_Mode_Unbounded_Record .. Type_Mode_Unbounded_Array; + -- Subprogram call argument mechanism. -- In VHDL, the evaluation is strict: actual parameters are evaluated -- before the call. This is the usual strategy of most compiled languages @@ -1160,6 +1163,10 @@ package Trans is -- Field declaration for array dimension. Index_Field : O_Fnode; + when Kind_Field => + -- Node for a record element declaration. + Field_Node : O_Fnode_Array := (O_Fnode_Null, O_Fnode_Null); + when Kind_Expr => -- Ortho tree which represents the expression, used for -- enumeration literals. @@ -1441,10 +1448,6 @@ package Trans is Config_Subprg : O_Dnode; Config_Instance : O_Dnode; - when Kind_Field => - -- Node for a record element declaration. - Field_Node : O_Fnode_Array := (O_Fnode_Null, O_Fnode_Null); - when Kind_Package => -- Subprogram which elaborate the package spec/body. -- External units should call the body elaborator. @@ -1571,6 +1574,10 @@ package Trans is function Is_Complex_Type (Tinfo : Type_Info_Acc) return Boolean; pragma Inline (Is_Complex_Type); + -- True iff TINFO is base + bounds. + function Is_Unbounded_Type (Tinfo : Type_Info_Acc) return Boolean; + pragma Inline (Is_Unbounded_Type); + type Hexstr_Type is array (Integer range 0 .. 15) of Character; N2hex : constant Hexstr_Type := "0123456789abcdef"; |