Commit 462a3d50 authored by julien.delange's avatar julien.delange
Browse files

begin to generate message content


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@688 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent e1a73dc0
...@@ -39,6 +39,8 @@ with Ocarina.ME_AADL.AADL_Instances.Nutils; ...@@ -39,6 +39,8 @@ with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities; with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with Ocarina.Backends.Properties;
with Ocarina.Backends.ASN1_Values;
with Ocarina.Backends.ASN1_Tree.Nutils; with Ocarina.Backends.ASN1_Tree.Nutils;
with Ocarina.Backends.ASN1_Tree.Nodes; with Ocarina.Backends.ASN1_Tree.Nodes;
...@@ -49,8 +51,10 @@ package body Ocarina.Backends.ASN1.Deployment is ...@@ -49,8 +51,10 @@ package body Ocarina.Backends.ASN1.Deployment is
use Ocarina.ME_AADL.AADL_Instances.Entities; use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.Utils; use Ocarina.Backends.Utils;
use Ocarina.Backends.Properties;
use Ocarina.Backends.ASN1_Tree.Nutils; use Ocarina.Backends.ASN1_Tree.Nutils;
package ASN1V renames Ocarina.Backends.ASN1_Values;
package ASN1N renames Ocarina.Backends.ASN1_Tree.Nodes; package ASN1N renames Ocarina.Backends.ASN1_Tree.Nodes;
package ASN1U renames Ocarina.Backends.ASN1_Tree.Nutils; package ASN1U renames Ocarina.Backends.ASN1_Tree.Nutils;
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils; package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
...@@ -273,6 +277,9 @@ package body Ocarina.Backends.ASN1.Deployment is ...@@ -273,6 +277,9 @@ package body Ocarina.Backends.ASN1.Deployment is
Port_Name : Name_Id; Port_Name : Name_Id;
Parent_Name : Name_Id; Parent_Name : Name_Id;
-- Name of the containing process. -- Name of the containing process.
Msg_Choice : Node_Id;
Msg_Name : Name_Id;
Msg_Constraints : Node_Id;
begin begin
Set_Str_To_Name_Buffer ("thread-"); Set_Str_To_Name_Buffer ("thread-");
...@@ -344,7 +351,8 @@ package body Ocarina.Backends.ASN1.Deployment is ...@@ -344,7 +351,8 @@ package body Ocarina.Backends.ASN1.Deployment is
F := First_Node (Features (E)); F := First_Node (Features (E));
while Present (F) loop while Present (F) loop
if Kind (F) = K_Port_Spec_Instance then if Kind (F) = K_Port_Spec_Instance and then
Is_Data (F) then
Set_Str_To_Name_Buffer ("port-"); Set_Str_To_Name_Buffer ("port-");
Get_Name_String_And_Append (Thread_Name); Get_Name_String_And_Append (Thread_Name);
Add_Str_To_Name_Buffer ("-"); Add_Str_To_Name_Buffer ("-");
...@@ -368,6 +376,26 @@ package body Ocarina.Backends.ASN1.Deployment is ...@@ -368,6 +376,26 @@ package body Ocarina.Backends.ASN1.Deployment is
-- it to the Port_Enumeration list that contains all -- it to the Port_Enumeration list that contains all
-- port identifiers. -- port identifiers.
Msg_Name := Port_Name;
Msg_Constraints := Make_Type_Constraints
(Size_Down => ASN1V.New_Int_Value
(To_Bytes
(Get_Data_Size
(Corresponding_Instance (F))), 1, 10),
Size_Up => ASN1V.New_Int_Value
(To_Bytes
(Get_Data_Size
(Corresponding_Instance (F))), 1, 10));
Msg_Choice := Make_Choice_Member
(Msg_Name,
Make_Type_Designator
(Type_Name =>
Make_Defining_Identifier
(Get_String_Name ("OCTET STRING")),
Type_Constraints => Msg_Constraints));
Append_Node_To_List (Msg_Choice, Msg_Choices);
end if; end if;
F := Next_Node (F); F := Next_Node (F);
end loop; end loop;
......
...@@ -63,6 +63,7 @@ package body Ocarina.Backends.ASN1_Tree.Generator is ...@@ -63,6 +63,7 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
procedure Generate_Choice (N : Node_Id); procedure Generate_Choice (N : Node_Id);
procedure Generate_Choice_Member (N : Node_Id); procedure Generate_Choice_Member (N : Node_Id);
procedure Generate_Defining_Identifier (N : Node_Id); procedure Generate_Defining_Identifier (N : Node_Id);
procedure Generate_Type_Designator (N : Node_Id);
----------- -----------
-- Write -- -- Write --
...@@ -120,6 +121,9 @@ package body Ocarina.Backends.ASN1_Tree.Generator is ...@@ -120,6 +121,9 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
when K_Defining_Identifier => when K_Defining_Identifier =>
Generate_Defining_Identifier (N); Generate_Defining_Identifier (N);
when K_Type_Designator =>
Generate_Type_Designator (N);
when others => when others =>
Display_Error ("other element in generator", Fatal => False); Display_Error ("other element in generator", Fatal => False);
null; null;
...@@ -269,16 +273,15 @@ package body Ocarina.Backends.ASN1_Tree.Generator is ...@@ -269,16 +273,15 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
begin begin
Write_Line (" CHOICE {"); Write_Line (" CHOICE {");
Increment_Indentation; Increment_Indentation;
Write_Indentation (-1);
if not Is_Empty (Values (N)) then if not Is_Empty (Values (N)) then
P := First_Node (Values (N)); P := First_Node (Values (N));
while Present (P) loop while Present (P) loop
Write_Indentation;
Generate (P); Generate (P);
P := Next_Node (P); P := Next_Node (P);
if P /= No_Node then if P /= No_Node then
Write_Char (','); Write_Char (',');
Write_Eol; Write_Eol;
Write_Indentation;
end if; end if;
end loop; end loop;
end if; end if;
...@@ -307,4 +310,24 @@ package body Ocarina.Backends.ASN1_Tree.Generator is ...@@ -307,4 +310,24 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
Write_Name (Name (N)); Write_Name (Name (N));
end Generate_Defining_Identifier; end Generate_Defining_Identifier;
------------------------------
-- Generate_Type_Designator --
------------------------------
procedure Generate_Type_Designator (N : Node_Id) is
Cons : constant Node_Id := Constraints (N);
begin
Generate (Type_Name (N));
if Cons /= No_Node then
if Size_Down (Cons) /= No_Value and then
Size_Up (Cons) /= No_Value then
Write_Str (" (");
Write_Str (Image (Size_Down (Cons)));
Write_Str (" .. ");
Write_Str (Image (Size_Up (Cons)));
Write_Str (" )");
end if;
end if;
end Generate_Type_Designator;
end Ocarina.Backends.ASN1_Tree.Generator; end Ocarina.Backends.ASN1_Tree.Generator;
...@@ -90,7 +90,7 @@ module Ocarina::Backends::ASN1_Tree::Nodes { ...@@ -90,7 +90,7 @@ module Ocarina::Backends::ASN1_Tree::Nodes {
List_Id Values; List_Id Values;
}; };
interface Choice_Member : Node_Id interface Choice_Member : Node_Id
{ {
Name_Id Member_Name; Name_Id Member_Name;
Node_Id Member_Type; Node_Id Member_Type;
...@@ -100,6 +100,16 @@ module Ocarina::Backends::ASN1_Tree::Nodes { ...@@ -100,6 +100,16 @@ module Ocarina::Backends::ASN1_Tree::Nodes {
Value_Id Value; Value_Id Value;
}; };
interface Type_Designator : Node_Id {
Node_Id Type_Name;
Node_Id Constraints;
};
interface Type_Constraints : Node_Id {
Value_Id Size_Down;
Value_Id Size_Up;
};
interface _Float : Base_Type {}; interface _Float : Base_Type {};
interface _Int : Base_Type {}; interface _Int : Base_Type {};
......
...@@ -38,11 +38,9 @@ with Charset; use Charset; ...@@ -38,11 +38,9 @@ with Charset; use Charset;
with Locations; use Locations; with Locations; use Locations;
with Ocarina.Backends.ASN1_Tree.Nodes; with Ocarina.Backends.ASN1_Tree.Nodes;
with Ocarina.Backends.ASN1_Values;
with Ocarina.ME_AADL.AADL_Instances.Nodes; with Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.Backends.ASN1_Tree.Nodes; use Ocarina.Backends.ASN1_Tree.Nodes;
use Ocarina.Backends.ASN1_Values;
package body Ocarina.Backends.ASN1_Tree.Nutils is package body Ocarina.Backends.ASN1_Tree.Nutils is
...@@ -604,4 +602,36 @@ package body Ocarina.Backends.ASN1_Tree.Nutils is ...@@ -604,4 +602,36 @@ package body Ocarina.Backends.ASN1_Tree.Nutils is
return N; return N;
end Make_Literal; end Make_Literal;
---------------------------
-- Make_Type_Constraints --
---------------------------
function Make_Type_Constraints
(Size_Up : Value_Id := No_Value;
Size_Down : Value_Id := No_Value)
return Node_Id is
N : Node_Id;
begin
N := New_Node (K_Type_Constraints);
ASN1_Nodes.Set_Size_Up (N, Size_Up);
ASN1_Nodes.Set_Size_Down (N, Size_Down);
return N;
end Make_Type_Constraints;
--------------------------
-- Make_Type_Designator --
--------------------------
function Make_Type_Designator (Type_Name : Node_Id;
Type_Constraints : Node_Id := No_Node)
return Node_Id
is
N : Node_Id;
begin
N := New_Node (K_Type_Designator);
ASN1_Nodes.Set_Type_Name (N, Type_Name);
ASN1_Nodes.Set_Constraints (N, Type_Constraints);
return N;
end Make_Type_Designator;
end Ocarina.Backends.ASN1_Tree.Nutils; end Ocarina.Backends.ASN1_Tree.Nutils;
...@@ -32,11 +32,14 @@ ...@@ -32,11 +32,14 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ocarina.Backends.ASN1_Tree.Nodes; with Ocarina.Backends.ASN1_Tree.Nodes;
with Ocarina.Backends.ASN1_Values;
package Ocarina.Backends.ASN1_Tree.Nutils is package Ocarina.Backends.ASN1_Tree.Nutils is
package ASN1_Nodes renames Ocarina.Backends.ASN1_Tree.Nodes; package ASN1_Nodes renames Ocarina.Backends.ASN1_Tree.Nodes;
use Ocarina.Backends.ASN1_Values;
type Token_Type is type Token_Type is
( (
-- Token name Token type -- Token name Token type
...@@ -211,4 +214,22 @@ package Ocarina.Backends.ASN1_Tree.Nutils is ...@@ -211,4 +214,22 @@ package Ocarina.Backends.ASN1_Tree.Nutils is
-- Make a choice member identified by Member_Name which has the -- Make a choice member identified by Member_Name which has the
-- type Member_Type. -- type Member_Type.
function Make_Type_Designator (Type_Name : Node_Id;
Type_Constraints : Node_Id := No_Node)
return Node_Id;
-- Make a node that points to a type. The type name is either a reference
-- to a type node, either a defining_identifier node that contains
-- the name of the pointed type. The second parameter is optional
-- and defines the constraints associated with the type designation.
-- You can look at the Make_Type_Constraints function for more
-- information.
function Make_Type_Constraints
(Size_Up : Value_Id := No_Value;
Size_Down : Value_Id := No_Value)
return Node_Id;
-- Make the Type_Constraints node. This node contains all potential
-- constraints that a type designator can contain. So, all parameters
-- are not mandatory and have a default value.
end Ocarina.Backends.ASN1_Tree.Nutils; end Ocarina.Backends.ASN1_Tree.Nutils;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2008-2010, GET-Telecom Paris. -- -- Copyright (C) 2008-2010, European Space Agency (ESA). --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify -- -- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the -- -- it under terms of the GNU General Public License as published by the --
...@@ -511,7 +511,7 @@ package body Ocarina.Backends.Properties is ...@@ -511,7 +511,7 @@ package body Ocarina.Backends.Properties is
return ((0, Bit)); return ((0, Bit));
end if; end if;
else else
return ((0, Bit)); return Null_Size;
end if; end if;
end Get_Size_Property_Value; end Get_Size_Property_Value;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2008-2010, GET-Telecom Paris. -- -- Copyright (C) 2008-2010, European Space Agency (ESA). --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify -- -- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the -- -- it under terms of the GNU General Public License as published by the --
...@@ -317,7 +317,7 @@ package Ocarina.Backends.Properties is ...@@ -317,7 +317,7 @@ package Ocarina.Backends.Properties is
-- component. -- component.
function Get_Data_Size (D : Node_Id) return Size_Type; function Get_Data_Size (D : Node_Id) return Size_Type;
-- Return the size of the data -- Return the size of the data. Returns Null_Size if not defined.
function Get_Provided_Data_Access function Get_Provided_Data_Access
(D : Node_Id) (D : Node_Id)
......
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