Commit 7c6abef4 authored by yoogx's avatar yoogx

* Implement partial resolution for record property types

        For issue #17
parent 86503bb9
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2014 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -69,12 +69,13 @@ package body Ocarina.Analyzer.AADL.Finder is
function Filter_Declarations_According_To_Modes
(Declaration_Node : Node_Id;
In_Modes : Node_Id) return Node_Id;
-- Given a chained list of homonyms 'Declaration_Node', if
-- In_Modes is not nul, return the node coprresponding to the
-- declaration that matches these modes or else the declaration
-- that has no "in modes" clause or else No_Node. If In_Modes is
-- nul, return the node coprresponding to the declaration with no
-- "in modes" clause or else No_Node.
-- Given a chained list of homonyms 'Declaration_Node',
--
-- * if In_Modes is not null, return the node coprresponding to
-- the declaration that matches these modes or else the
-- declaration that has no "in modes" clause or else No_Node.
-- * if In_Modes is nul, return the node coprresponding to the
-- declaration with no "in modes" clause or else No_Node.
--------------------------------------------
-- Filter_Declarations_According_To_Modes --
......@@ -449,7 +450,8 @@ package body Ocarina.Analyzer.AADL.Finder is
or else Kind (Property_Container) = K_Constant_Property_Declaration
or else Kind (Property_Container) = K_Property_Type
or else Kind (Property_Container) = K_Property_Definition_Declaration
or else Kind (Property_Container) = K_Property_Type_Declaration);
or else Kind (Property_Container) = K_Property_Type_Declaration
or else Kind (Property_Container) = K_Record_Term_Element);
List_Node : Node_Id := No_Node;
Property_Type : Node_Id;
......@@ -475,25 +477,58 @@ package body Ocarina.Analyzer.AADL.Finder is
Property_Type := Property_Name_Type (Pointed_Node);
end if;
if Kind (Property_Type) /= K_Enumeration_Type then
if Kind (Property_Type) /= K_Enumeration_Type
and then Kind (Property_Type) /= K_Record_Type
then
return No_Node;
elsif not Is_Empty (Identifiers (Property_Type)) then
List_Node := First_Node (Identifiers (Property_Type));
end if;
while Present (List_Node) loop
if Ocarina.ME_AADL.AADL_Tree.Nodes.Name (List_Node) =
Name (Identifier (Default_Value))
then
Resolve_Term_In_Property
(Property_Container,
Default_Value,
K_Enumeration_Term);
return Pointed_Node;
end if;
if Kind (Property_Type) = K_Enumeration_Type
and then not Is_Empty (Identifiers (Property_Type))
then
List_Node := First_Node (Identifiers (Property_Type));
List_Node := Next_Node (List_Node);
end loop;
while Present (List_Node) loop
if Ocarina.ME_AADL.AADL_Tree.Nodes.Name (List_Node) =
Name (Identifier (Default_Value))
then
Resolve_Term_In_Property
(Property_Container,
Default_Value,
K_Enumeration_Term);
return Pointed_Node;
end if;
List_Node := Next_Node (List_Node);
end loop;
elsif Kind (Property_Type) = K_Record_Type then
-- When processing a Record_Type, we iterate over
-- the property container that holds the record
-- term element (i.e. foo => bar) and check that
--
List_Node := First_Node (List_Items (Property_Type));
while Present (List_Node) loop
-- A property type is a list of record_type element
-- XXX should use case insensitive match ?
if Ocarina.ME_AADL.AADL_Tree.Nodes.Display_Name
(Identifier (List_Node)) =
Display_Name (Identifier (Property_Container))
then
Resolve_Term_In_Property
(List_Node, -- Property_Container,
Default_Value,
K_Enumeration_Term);
return Pointed_Node;
end if;
List_Node := Next_Node (List_Node);
end loop;
end if;
end if;
when K_Enumeration_Type =>
......@@ -521,7 +556,6 @@ package body Ocarina.Analyzer.AADL.Finder is
end case;
return No_Node;
end Find_Property_Enumeration;
-------------------------------------------------------
......
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . P R O C E S S O R . P R O P E R T I E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2015 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. Ocarina is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
......@@ -431,21 +464,23 @@ package body Ocarina.Processor.Properties is
use Ocarina.Analyzer.Messages;
use Ocarina.ME_AADL.AADL_Tree.Nutils;
pragma Assert (Reference_Property /= No_Node);
pragma Assert
(Property = No_Node
or else Kind (Property) = K_Property_Association
or else Kind (Property) = K_Constant_Property_Declaration
or else Kind (Property) = K_Property_Definition_Declaration
or else Kind (Property) = K_Property_Type_Declaration
or else Kind (Property) = K_Record_Term_Element
or else DNKE (Property));
pragma Assert (Reference_Property /= No_Node);
Value, List_Node, Expanded_List_Node, Computed_Value : Node_Id;
Expanded_List : List_Id;
Undefined_Values : Boolean;
begin
if Property = No_Node then
if Property = No_Node
or else Kind (Property) = K_Record_Term_Element
then
return No_Node;
end if;
......@@ -557,7 +592,6 @@ package body Ocarina.Processor.Properties is
or else Kind (Property_Value) = K_Number_Range_Term
or else Kind (Property_Value) = K_Reference_Term
or else Kind (Property_Value) = K_Enumeration_Term
or else Kind (Property_Value) = K_Property_Term
or else Kind (Property_Value) = K_Minus_Numeric_Term
or else Kind (Property_Value) = K_Signed_AADLNumber
or else Kind (Property_Value) = K_Not_Boolean_Term
......@@ -1074,7 +1108,34 @@ package body Ocarina.Processor.Properties is
Component_Cat (Property_Value));
when K_Record_Term =>
null; -- XXX
Evaluated_Value :=
New_Node (Kind (Property_Value), Loc (Property_Value));
declare
Record_Terms_List : constant List_Id :=
New_List (K_List_Id, Loc (Property_Value));
J : Node_Id := First_Node (List_Items (Property_Value));
List_Node : Node_Id;
Record_Term_Element_Node : Node_Id;
begin
while Present (J) loop
Record_Term_Element_Node := New_Node
(K_Record_Term_Element, Loc (Property_Value));
List_Node := Evaluate_Property_Value
(Property_Expression (J), Reference_Property);
-- Put_Line (Kind (List_Node)'Img);
Set_Identifier (Record_Term_Element_Node, Identifier (J));
Set_Property_Expression
(Record_Term_Element_Node, List_Node);
Append_Node_To_List
(Record_Term_Element_Node, Record_Terms_List);
J := Next_Node (J);
end loop;
Set_List_Items (Evaluated_Value, Record_Terms_List);
end;
when others =>
raise Program_Error;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2014 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -272,6 +272,7 @@ package body Ocarina.ME_AADL.AADL_Tree.Entities.Properties is
or else Kind (Property_Value) = K_Or_Boolean_Term
or else Kind (Property_Value) = K_Parenthesis_Boolean_Term
or else Kind (Property_Value) = K_Reference_Term
or else Kind (Property_Value) = K_Record_Term
or else Kind (Property_Value) = K_Property_Term
or else Kind (Property_Value) = K_Enumeration_Term
or else Kind (Property_Value) = K_Component_Classifier_Term);
......@@ -662,7 +663,9 @@ package body Ocarina.ME_AADL.AADL_Tree.Entities.Properties is
pragma Assert
(Kind (Property) = K_Property_Association
or else Kind (Property) = K_Constant_Property_Declaration
or else Kind (Property) = K_Property_Definition_Declaration);
or else Kind (Property) = K_Property_Definition_Declaration
or else Kind (Property) = K_Record_Term_Element
or else Kind (Property) = K_Record_Type_Element);
pragma Assert
(Kind_Node = K_Enumeration_Term or else Kind_Node = K_Unit_Term);
......
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