@@ -743,7 +743,9 @@ package body Tree_Walk is
743
743
744
744
Result_Type : constant Irep := New_Irep (I_Bounded_Signedbv_Type);
745
745
begin
746
- if not (Kind (Resolved_Underlying) in Class_Bitvector_Type) then
746
+ if not (Kind (Resolved_Underlying) in Class_Bitvector_Type or
747
+ Kind (Resolved_Underlying) = I_C_Enum_Type)
748
+ then
747
749
return Report_Unhandled_Node_Type (Range_Expr,
748
750
" Do_Base_Range_Constraint" ,
749
751
" range expression not bitvector type" );
@@ -754,6 +756,9 @@ package body Tree_Walk is
754
756
Store_Nat_Bound (Bound_Type_Nat (Intval (Lower_Bound)));
755
757
when N_Attribute_Reference => Lower_Bound_Value :=
756
758
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Lower_Bound));
759
+ when N_Identifier =>
760
+ Lower_Bound_Value :=
761
+ Store_Symbol_Bound (Bound_Type_Symbol (Lower_Bound));
757
762
when others =>
758
763
Report_Unhandled_Node_Empty (Lower_Bound,
759
764
" Do_Base_Range_Constraint" ,
@@ -765,13 +770,21 @@ package body Tree_Walk is
765
770
Store_Nat_Bound (Bound_Type_Nat (Intval (Upper_Bound)));
766
771
when N_Attribute_Reference => Upper_Bound_Value :=
767
772
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Upper_Bound));
773
+ when N_Identifier =>
774
+ Upper_Bound_Value :=
775
+ Store_Symbol_Bound (Bound_Type_Symbol (Upper_Bound));
768
776
when others =>
769
777
Report_Unhandled_Node_Empty (Upper_Bound,
770
778
" Do_Base_Range_Constraint" ,
771
779
" unsupported upper range kind" );
772
780
end case ;
773
781
774
- Set_Width (Result_Type, Get_Width (Resolved_Underlying));
782
+ if Kind (Resolved_Underlying) = I_C_Enum_Type then
783
+ Set_Width (Result_Type,
784
+ Get_Width (Get_Subtype (Resolved_Underlying)));
785
+ else
786
+ Set_Width (Result_Type, Get_Width (Resolved_Underlying));
787
+ end if ;
775
788
Set_Lower_Bound (Result_Type, Lower_Bound_Value);
776
789
Set_Upper_Bound (Result_Type, Upper_Bound_Value);
777
790
return Result_Type;
@@ -792,23 +805,44 @@ package body Tree_Walk is
792
805
793
806
procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id);
794
807
808
+ function Handle_Enum_Symbol_Members (Mem : Irep) return Irep;
809
+ function Handle_Enum_Symbol_Members (Mem : Irep) return Irep is
810
+ Followed_Type_Symbol : constant Irep :=
811
+ Follow_Symbol_Type (Get_Type (Mem), Global_Symbol_Table);
812
+ begin
813
+ if Kind (Followed_Type_Symbol) = I_C_Enum_Type then
814
+ declare
815
+ Val : constant Irep := Global_Symbol_Table
816
+ (Intern
817
+ (Get_Identifier
818
+ (Mem)))
819
+ .Value;
820
+ begin
821
+ return Val;
822
+ end ;
823
+ else
824
+ return Mem;
825
+ end if ;
826
+ end Handle_Enum_Symbol_Members ;
827
+
795
828
-- --------------------
796
829
-- Handle_Parameter --
797
830
-- --------------------
798
831
799
832
procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id) is
800
833
Is_Out : constant Boolean := Out_Present (Parent (Formal));
801
834
Actual_Irep : Irep;
802
-
835
+ Expression : constant Irep := Do_Expression (Actual);
803
836
begin
804
837
if Is_Out and then
805
- not (Kind (Get_Type (Do_Expression (Actual) )) in Class_Type)
838
+ not (Kind (Get_Type (Expression )) in Class_Type)
806
839
then
807
840
Report_Unhandled_Node_Empty (Actual, " Handle_Parameter" ,
808
841
" Kind of actual not in class type" );
809
842
return ;
810
843
end if ;
811
- Actual_Irep := Wrap_Argument (Do_Expression (Actual), Is_Out);
844
+ Actual_Irep := Wrap_Argument (
845
+ Handle_Enum_Symbol_Members (Expression), Is_Out);
812
846
Append_Argument (Args, Actual_Irep);
813
847
end Handle_Parameter ;
814
848
@@ -2882,6 +2916,24 @@ package body Tree_Walk is
2882
2916
2883
2917
-- Begin processing for Do_Object_Declaration_Full_Declaration
2884
2918
2919
+ procedure Register_Identifier_In_Symbol_Table (N : Irep; Val : Irep)
2920
+ with Pre => Kind (N) = I_Symbol_Expr;
2921
+ procedure Register_Identifier_In_Symbol_Table (N : Irep; Val : Irep) is
2922
+ Identifier_Name : constant Symbol_Id :=
2923
+ Intern (Get_Identifier (N));
2924
+ Identifier_Symbol : Symbol;
2925
+ begin
2926
+ Identifier_Symbol.Name := Identifier_Name;
2927
+ Identifier_Symbol.BaseName := Identifier_Name;
2928
+ Identifier_Symbol.PrettyName := Identifier_Name;
2929
+ Identifier_Symbol.SymType := Get_Type (N);
2930
+ Identifier_Symbol.Mode := Intern (" C" );
2931
+ Identifier_Symbol.Value := Val;
2932
+ Global_Symbol_Table.Insert (Identifier_Name, Identifier_Symbol);
2933
+ end Register_Identifier_In_Symbol_Table ;
2934
+
2935
+ Is_In_Symtab : constant Boolean :=
2936
+ Global_Symbol_Table.Contains (Intern (Get_Identifier (Id)));
2885
2937
begin
2886
2938
Set_Source_Location (Decl, (Sloc (N)));
2887
2939
Set_Symbol (Decl, Id);
@@ -2907,6 +2959,11 @@ package body Tree_Walk is
2907
2959
Rhs => Init_Expr,
2908
2960
Source_Location => Sloc (N)));
2909
2961
end if ;
2962
+
2963
+ if not Is_In_Symtab then
2964
+ Register_Identifier_In_Symbol_Table (Id, Init_Expr);
2965
+ end if ;
2966
+
2910
2967
end Do_Object_Declaration_Full ;
2911
2968
2912
2969
-- -----------------------
0 commit comments