Commit 9e7f00ce authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Use Sets and not vectors when more relevant

parent 0b460d62
-- *************************** taste aadl parser *********************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- (c) 2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Deployment View parser
......@@ -380,14 +380,18 @@ package body TASTE.Deployment_View is
if Ref = CI then
begin
Result.Bound_Functions.Append (Get_Name_String (ATN.Name
Result.Bound_Functions.Insert (Get_Name_String (ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (P_CI)))));
exception
when Assert_Failure =>
Put_Info ("Detected DV from TASTE version 1.2");
Result.Bound_Functions.Append
Result.Bound_Functions.Insert
(Get_Name_String (Name (Identifier (Processes))));
when Constraint_Error =>
-- If the call to Insert in the set failed
Put_Info ("Duplicate bounded function in partition: "
& To_String (Result.Name));
end;
end if;
end if;
......
......@@ -24,9 +24,10 @@ use Ada.Containers,
package TASTE.Deployment_View is
use Option_UString;
use Option_ULL;
use String_Vectors;
use Option_UString,
Option_ULL,
String_Vectors,
String_Sets;
-- Exceptions specific to the deployment view
Deployment_View_Error : exception;
......@@ -102,7 +103,7 @@ package TASTE.Deployment_View is
CPU_Name : Unbounded_String;
CPU_Platform : Supported_Execution_Platform;
CPU_Classifier : Unbounded_String;
Bound_Functions : String_Vectors.Vector;
Bound_Functions : String_Sets.Set;
end record;
package Option_Partition is new Option_Type (Taste_Partition);
......
......@@ -172,6 +172,26 @@ package body TASTE.Model_Transformations is
end loop;
end;
end loop;
end loop;
-- Add the function to the deployment view
for Node of Result.Deployment_View.Nodes loop
Put_Info ("Node " & To_String (Node.Name));
for Partition of Node.Partitions loop
if Partition.Bound_Functions.Contains (To_String (F.Context))
then
begin
Partition.Bound_Functions.Insert (To_String (F.Name));
exception
when Constraint_Error =>
-- Insert error, value already exists in the set
Put_Error ("Vertical Transformation Error: generated "
& "name conflicts with user function "
& To_String (F.Name));
end;
end if;
end loop;
end loop;
-- Finally, add all newly-created functions to the new model
......
......@@ -4,6 +4,7 @@
-- Set of helper functions for the parser
with Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Ordered_Sets,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded,
Ada.Strings.Equal_Case_Insensitive,
......@@ -86,6 +87,11 @@ package TASTE.Parser_Utils is
use Property_Maps;
package String_Vectors is new Indefinite_Vectors (Natural, String,
Ada.Strings.Equal_Case_Insensitive);
package String_Sets is new Indefinite_Ordered_Sets
(Element_Type => String,
"<" => Ada.Strings.Less_Case_Insensitive,
"=" => Ada.Strings.Equal_Case_Insensitive);
function Get_Properties_Map (D : Node_Id) return Property_Maps.Map;
-- Shortcut to read an identifier from the parser, in lowercase
......
......@@ -87,8 +87,8 @@ package body TASTE.Semantic_Check is
or PI.RCM = Unprotected_Operation)
then
for Remote of PI.Remote_Interfaces loop
if Opt_Part.Unsafe_Just.Bound_Functions.Find
(To_String (Remote.Function_Name)) = String_Vectors.No_Element
if not Opt_Part.Unsafe_Just.Bound_Functions.Contains
(To_String (Remote.Function_Name))
then
raise Semantic_Error with "Function "
& To_String (Each.Name) & " and function "
......
......@@ -12,7 +12,17 @@ test-parse: clean
-d DataView.aadl \
../common/ocarina_components.aadl && cd output && time make dataviews
gdb: clean
gdb --args $(AADL_PARSER) --gw \
-o output \
--glue \
--debug \
-i InterfaceView.aadl \
-c DeploymentView.aadl \
-d DataView.aadl \
../common/ocarina_components.aadl && cd output && time make dataviews
clean:
rm -rf output
.PHONY: clean test-parse
.PHONY: clean test-parse gdb
Supports Markdown
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