aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-07-19 07:32:39 +0200
committerTristan Gingold <tgingold@free.fr>2014-07-19 07:32:39 +0200
commit4168dec01d69b644c59858be3af8d56b055fbbc2 (patch)
treeb620bd83cc41629d391ba54d98013a7b1f5b513c
parent415befa3bfe945bc069fd1ce73d8efd91e3b459f (diff)
downloadghdl-4168dec01d69b644c59858be3af8d56b055fbbc2.tar.gz
ghdl-4168dec01d69b644c59858be3af8d56b055fbbc2.tar.bz2
ghdl-4168dec01d69b644c59858be3af8d56b055fbbc2.zip
Handle character literals like simple names.
-rw-r--r--evaluation.adb15
-rw-r--r--iirs.adb7
-rw-r--r--iirs.ads6
-rw-r--r--sem_expr.adb61
-rw-r--r--sem_names.adb4
-rw-r--r--simulate/execution.adb1
-rw-r--r--translate/translation.adb1
7 files changed, 24 insertions, 71 deletions
diff --git a/evaluation.adb b/evaluation.adb
index 1815c2b7c..d6ce74555 100644
--- a/evaluation.adb
+++ b/evaluation.adb
@@ -1717,15 +1717,11 @@ package body Evaluation is
Val : Iir;
begin
case Get_Kind (Expr) is
- when Iir_Kind_Integer_Literal =>
- return Expr;
- when Iir_Kind_Enumeration_Literal =>
- return Expr;
- when Iir_Kind_Floating_Point_Literal =>
- return Expr;
- when Iir_Kind_String_Literal =>
- return Expr;
- when Iir_Kind_Bit_String_Literal =>
+ when Iir_Kind_Integer_Literal
+ | Iir_Kind_Enumeration_Literal
+ | Iir_Kind_Floating_Point_Literal
+ | Iir_Kind_String_Literal
+ | Iir_Kind_Bit_String_Literal =>
return Expr;
when Iir_Kind_Physical_Int_Literal =>
if Get_Unit_Name (Expr)
@@ -2049,6 +2045,7 @@ package body Evaluation is
end;
when Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Selected_Name =>
declare
Res : Iir;
diff --git a/iirs.adb b/iirs.adb
index 73f2da911..b28392fb6 100644
--- a/iirs.adb
+++ b/iirs.adb
@@ -2548,7 +2548,8 @@ package body Iirs is
procedure Check_Kind_For_Base_Name (Target : Iir) is
begin
case Get_Kind (Target) is
- when Iir_Kind_Attribute_Value
+ when Iir_Kind_Character_Literal
+ | Iir_Kind_Attribute_Value
| Iir_Kind_Operator_Symbol
| Iir_Kind_Free_Quantity_Declaration
| Iir_Kind_Across_Quantity_Declaration
@@ -5794,7 +5795,8 @@ package body Iirs is
procedure Check_Kind_For_Named_Entity (Target : Iir) is
begin
case Get_Kind (Target) is
- when Iir_Kind_Operator_Symbol
+ when Iir_Kind_Character_Literal
+ | Iir_Kind_Operator_Symbol
| Iir_Kind_Simple_Name
| Iir_Kind_Selected_Name
| Iir_Kind_Selected_By_All_Name
@@ -5822,6 +5824,7 @@ package body Iirs is
begin
case Get_Kind (Target) is
when Iir_Kind_Error
+ | Iir_Kind_Character_Literal
| Iir_Kind_Integer_Literal
| Iir_Kind_Floating_Point_Literal
| Iir_Kind_Null_Literal
diff --git a/iirs.ads b/iirs.ads
index 03cde7747..1f30135f7 100644
--- a/iirs.ads
+++ b/iirs.ads
@@ -203,6 +203,12 @@ package Iirs is
-- Get/Set_Identifier (Field3)
--
-- Get/Set_Type (Field1)
+ --
+ -- Get/Set_Named_Entity (Field4)
+ --
+ -- Get/Set_Base_Name (Field5)
+ --
+ -- Get/Set_Expr_Staticness (State1)
-- Iir_Kind_String_Literal (Short)
-- Iir_Kind_Bit_String_Literal (Medium)
diff --git a/sem_expr.adb b/sem_expr.adb
index 2bf2fd51e..ce8d7f2f6 100644
--- a/sem_expr.adb
+++ b/sem_expr.adb
@@ -31,12 +31,6 @@ with Sem_Assocs; use Sem_Assocs;
with Xrefs; use Xrefs;
package body Sem_Expr is
- procedure Undeclared (Expr: Iir) is
- begin
- Error_Msg_Sem ("identifier '" & Iirs_Utils.Image_Identifier (Expr)
- & "' not declared", Expr);
- end Undeclared;
-
procedure Not_Match (Expr: Iir; A_Type: Iir)
is
pragma Inline (Not_Match);
@@ -3564,6 +3558,7 @@ package body Sem_Expr is
| Iir_Kind_Physical_Fp_Literal
| Iir_Kind_String_Literal
| Iir_Kind_Bit_String_Literal
+ | Iir_Kind_Character_Literal
| Iir_Kind_Integer_Literal
| Iir_Kind_Floating_Point_Literal
| Iir_Kind_Null_Literal
@@ -3689,61 +3684,9 @@ package body Sem_Expr is
end if;
case Get_Kind (Expr) is
- when Iir_Kind_Character_Literal =>
- declare
- Interpretation: Name_Interpretation_Type;
- Decl: Iir;
- List: Iir_List;
- begin
- Interpretation := Get_Interpretation (Get_Identifier (Expr));
-
- -- Check the identifier was declared.
- if not Valid_Interpretation (Interpretation) then
- Undeclared (Expr);
- return Null_Iir;
- end if;
-
- if not Valid_Interpretation
- (Get_Next_Interpretation (Interpretation))
- then
- Decl := Get_Non_Alias_Declaration (Interpretation);
- if A_Type /= Null_Iir and then A_Type = Get_Type (Decl) then
- -- Free overload list of expr (if any), and expr.
- Replace_Type (Expr, Null_Iir);
- Iirs_Utils.Free_Name (Expr);
- return Decl;
- end if;
- end if;
-
- -- Character literal can only be an enumeration literal.
- if A_Type /= Null_Iir then
- while Valid_Interpretation (Interpretation) loop
- Decl := Get_Non_Alias_Declaration (Interpretation);
- if Get_Type (Decl) = A_Type then
- Replace_Type (Expr, Null_Iir);
- Iirs_Utils.Free_Name (Expr);
- return Decl;
- end if;
- Interpretation :=
- Get_Next_Interpretation (Interpretation);
- end loop;
- Not_Match (Expr, A_Type);
- return Null_Iir;
- end if;
-
- -- Store overloaded interpretation.
- List := Create_Iir_List;
- while Valid_Interpretation (Interpretation) loop
- Decl := Get_Non_Alias_Declaration (Interpretation);
- Append_Element (List, Get_Type (Decl));
- Interpretation := Get_Next_Interpretation (Interpretation);
- end loop;
- Set_Type (Expr, Create_Overload_List (List));
- return Expr;
- end;
-
when Iir_Kind_Selected_Name
| Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Parenthesis_Name
| Iir_Kind_Selected_By_All_Name
| Iir_Kind_Attribute_Name =>
diff --git a/sem_names.adb b/sem_names.adb
index ac62bef14..960868f4f 100644
--- a/sem_names.adb
+++ b/sem_names.adb
@@ -1328,7 +1328,7 @@ package body Sem_Names is
-- The evaluation of a simple name has no other effect than to determine
-- the named entity denoted by the name.
--
- -- NAME may be a string literal too.
+ -- NAME may be a simple name, a strig literal or a character literal.
-- GHDL: set interpretation of NAME (possibly an overload list) or
-- error_mark for unknown names.
-- If SOFT is TRUE, then no error message is reported in case of failure.
@@ -3067,6 +3067,7 @@ package body Sem_Names is
case Get_Kind (Name) is
when Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Operator_Symbol =>
-- String_Literal may be a symbol_operator.
Sem_Simple_Name (Name, Keep_Alias, False);
@@ -3367,6 +3368,7 @@ package body Sem_Names is
Xref_Name (Name);
case Get_Kind (Name) is
when Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Selected_Name =>
--Set_Base_Name (Name, Get_Base_Name (Expr));
Set_Type (Name, Get_Type (Expr));
diff --git a/simulate/execution.adb b/simulate/execution.adb
index a3a29d485..18407ed2a 100644
--- a/simulate/execution.adb
+++ b/simulate/execution.adb
@@ -2854,6 +2854,7 @@ package body Execution is
return Execute_Name (Block, Expr);
when Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Selected_Name =>
return Execute_Expression (Block, Get_Named_Entity (Expr));
diff --git a/translate/translation.adb b/translate/translation.adb
index 8836281f6..a949692ca 100644
--- a/translate/translation.adb
+++ b/translate/translation.adb
@@ -16884,6 +16884,7 @@ package body Translation is
Res := Chap14.Translate_Path_Instance_Name_Attribute (Expr);
when Iir_Kind_Simple_Name
+ | Iir_Kind_Character_Literal
| Iir_Kind_Selected_Name =>
return Translate_Expression (Get_Named_Entity (Expr), Rtype);