Commit 3fa81987 authored by yoogx's avatar yoogx

* Default value are marked constant if a default value can be

          computed
parent 7c60fea5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. -- -- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify under -- -- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -896,28 +896,38 @@ package body Ocarina.Backends.PO_HI_Ada.Types is ...@@ -896,28 +896,38 @@ package body Ocarina.Backends.PO_HI_Ada.Types is
(Identifier (E), (Identifier (E),
Get_Handling (E, By_Name, H_Ada_Type_Spec)); Get_Handling (E, By_Name, H_Ada_Type_Spec));
-- Declare the "default value" of a type. This value is not -- Declare the "default value" of a type.
-- declared as a 'constant' so that the user can modify it.
-- Note: If a default value can be computed, then this value
-- is declared as a 'constant' so that the user cannot
-- modify it.
if No (Get_Handling (E, By_Name, H_Ada_Type_Default_Value)) then if No (Get_Handling (E, By_Name, H_Ada_Type_Default_Value)) then
Data_Representation := Get_Data_Representation (E); Data_Representation := Get_Data_Representation (E);
-- We generate default values for all types except -- We generate default values for all types except
-- protected types. -- protected types.
if Data_Representation /= Data_With_Accessors then if Data_Representation /= Data_With_Accessors then
N := declare
Make_Object_Declaration Default_Value : constant Node_Id :=
(Defining_Identifier => Get_Ada_Default_Value (E);
Map_Ada_Default_Value_Identifier (E), begin
Object_Definition => Map_Ada_Defining_Identifier (E), N :=
Expression => Get_Ada_Default_Value (E)); Make_Object_Declaration
(Defining_Identifier =>
Set_Handling (E, By_Name, H_Ada_Type_Default_Value, N); Map_Ada_Default_Value_Identifier (E),
Append_Node_To_List (N, ADN.Visible_Part (Current_Package)); Constant_Present => Present (Default_Value),
else Object_Definition => Map_Ada_Defining_Identifier (E),
N := No_Node; Expression => Default_Value);
end if;
Set_Handling (E, By_Name, H_Ada_Type_Default_Value, N);
Append_Node_To_List
(N, ADN.Visible_Part (Current_Package));
end;
else
N := No_Node;
end if;
end if; end if;
-- Bind the type to its default value if a default value has -- Bind the type to its default value if a default value has
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment