diff options
author | Tristan Gingold | 2015-01-15 07:04:39 +0100 |
---|---|---|
committer | Tristan Gingold | 2015-01-15 07:04:39 +0100 |
commit | aaa66c97da7cc9fc5009f6cc599400cd55f14888 (patch) | |
tree | 27b34d9f752aedc87787f95f65aeace637a949cf | |
parent | 1171507e898db362faa6299bdc845073cd3beeae (diff) | |
download | ghdl-aaa66c97da7cc9fc5009f6cc599400cd55f14888.tar.gz ghdl-aaa66c97da7cc9fc5009f6cc599400cd55f14888.tar.bz2 ghdl-aaa66c97da7cc9fc5009f6cc599400cd55f14888.zip |
Create the Sem_Qualified_Expression function.
-rw-r--r-- | src/vhdl/sem_expr.adb | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index 0813a2e..5b4ed6b 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -3612,6 +3612,43 @@ package body Sem_Expr is end if; end Sem_Allocator; + function Sem_Qualified_Expression (Expr : Iir; A_Type : Iir) return Iir + is + N_Type: Iir; + Res: Iir; + begin + N_Type := Sem_Type_Mark (Get_Type_Mark (Expr)); + Set_Type_Mark (Expr, N_Type); + N_Type := Get_Type (N_Type); + Set_Type (Expr, N_Type); + if A_Type /= Null_Iir + and then not Are_Types_Compatible (A_Type, N_Type) + then + Not_Match (Expr, A_Type); + return Null_Iir; + end if; + Res := Sem_Expression (Get_Expression (Expr), N_Type); + if Res = Null_Iir then + return Null_Iir; + end if; + Check_Read (Res); + Set_Expression (Expr, Res); + + -- LRM93 7.4.1 Locally static primaries + -- h) A qualified expression whose operand is a locally static + -- expression. + -- + -- LRM08 9.4.2 Locally static primaries + -- i) A qualified expression whose type mark denotes a locally static + -- subtype and whose operand is a locally static expression. + -- + -- We always use the vhdl08, because it is weird to have locally + -- static expression with a non-locally static subtype. + Set_Expr_Staticness (Expr, Min (Get_Expr_Staticness (Res), + Get_Type_Staticness (N_Type))); + return Expr; + end Sem_Qualified_Expression; + procedure Check_Read_Aggregate (Aggr : Iir) is pragma Unreferenced (Aggr); @@ -3952,30 +3989,7 @@ package body Sem_Expr is end; when Iir_Kind_Qualified_Expression => - declare - N_Type: Iir; - Res: Iir; - begin - N_Type := Sem_Type_Mark (Get_Type_Mark (Expr)); - Set_Type_Mark (Expr, N_Type); - N_Type := Get_Type (N_Type); - Set_Type (Expr, N_Type); - if A_Type /= Null_Iir - and then not Are_Types_Compatible (A_Type, N_Type) - then - Not_Match (Expr, A_Type); - return Null_Iir; - end if; - Res := Sem_Expression (Get_Expression (Expr), N_Type); - if Res = Null_Iir then - return Null_Iir; - end if; - Check_Read (Res); - Set_Expression (Expr, Res); - Set_Expr_Staticness (Expr, Min (Get_Expr_Staticness (Res), - Get_Type_Staticness (N_Type))); - return Expr; - end; + return Sem_Qualified_Expression (Expr, A_Type); when Iir_Kind_Allocator_By_Expression | Iir_Kind_Allocator_By_Subtype => |