diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-07 18:43:16 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-09 06:40:14 +0100 |
commit | a502b334527a8b6823878b2354b9db279e912964 (patch) | |
tree | 5dc28b2fffec379e60c110be59af8cdf24f2503b /src/synth | |
parent | dec65fa49d9e5255521fcdd01ba4e57c43b8c4c0 (diff) | |
download | ghdl-a502b334527a8b6823878b2354b9db279e912964.tar.gz ghdl-a502b334527a8b6823878b2354b9db279e912964.tar.bz2 ghdl-a502b334527a8b6823878b2354b9db279e912964.zip |
synth: handle subtype attribute in type prefixes.
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/elab-vhdl_types.adb | 8 | ||||
-rw-r--r-- | src/synth/elab-vhdl_types.ads | 4 | ||||
-rw-r--r-- | src/synth/synth-vhdl_expr.adb | 21 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/synth/elab-vhdl_types.adb b/src/synth/elab-vhdl_types.adb index 782de6b5e..a7657ceac 100644 --- a/src/synth/elab-vhdl_types.adb +++ b/src/synth/elab-vhdl_types.adb @@ -108,14 +108,6 @@ package body Elab.Vhdl_Types is return Get_Array_Bound (Typ); end Synth_Array_Attribute; - function Synth_Type_Attribute (Syn_Inst : Synth_Instance_Acc; Attr : Node) - return Type_Acc is - begin - return Get_Subtype_Object - (Syn_Inst, - Get_Subtype_Indication (Get_Named_Entity (Get_Prefix (Attr)))); - end Synth_Type_Attribute; - procedure Synth_Discrete_Range (Syn_Inst : Synth_Instance_Acc; Bound : Node; Rng : out Discrete_Range_Type) is diff --git a/src/synth/elab-vhdl_types.ads b/src/synth/elab-vhdl_types.ads index 9f03f14e8..4a7baffb3 100644 --- a/src/synth/elab-vhdl_types.ads +++ b/src/synth/elab-vhdl_types.ads @@ -37,10 +37,6 @@ package Elab.Vhdl_Types is function Synth_Array_Attribute (Syn_Inst : Synth_Instance_Acc; Attr : Node) return Bound_Type; - -- Return the type for 'left/'right/... attributes. - function Synth_Type_Attribute (Syn_Inst : Synth_Instance_Acc; Attr : Node) - return Type_Acc; - procedure Synth_Discrete_Range (Syn_Inst : Synth_Instance_Acc; Bound : Node; Rng : out Discrete_Range_Type); diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb index d644b5bfe..c756bb857 100644 --- a/src/synth/synth-vhdl_expr.adb +++ b/src/synth/synth-vhdl_expr.adb @@ -1981,6 +1981,27 @@ package body Synth.Vhdl_Expr is return Create_Value_Net (N, Typ); end Synth_Short_Circuit; + -- Return the type for 'left/'right/... attributes. + function Synth_Type_Attribute (Syn_Inst : Synth_Instance_Acc; Attr : Node) + return Type_Acc + is + Pfx : constant Node := Get_Prefix (Attr); + begin + if Get_Kind (Pfx) = Iir_Kind_Subtype_Attribute then + -- Prefix is an object. + declare + V : Valtyp; + begin + V := Get_Value (Syn_Inst, Get_Named_Entity (Get_Prefix (Pfx))); + return V.Typ; + end; + else + -- The prefix is a type. + return Get_Subtype_Object + (Syn_Inst, Get_Subtype_Indication (Get_Named_Entity (Pfx))); + end if; + end Synth_Type_Attribute; + function Synth_Expression_With_Type (Syn_Inst : Synth_Instance_Acc; Expr : Node; Expr_Type : Type_Acc) return Valtyp is |