Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
13ce1261
Commit
13ce1261
authored
Nov 11, 2018
by
Maxime Perrotin
Browse files
Cleanup code
parent
2671e391
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/taste-backend-code_generators.adb
View file @
13ce1261
...
...
@@ -96,14 +96,14 @@ package body TASTE.Backend.Code_Generators is
end
Generate_Global_Makefile
;
-- Render a set (Tag) of interfaces by applying a template
function
Process_Interfaces
(
Interfaces
:
Interface
_Vector
s
.
Vector
;
function
Process_Interfaces
(
Interfaces
:
ST_
Interfaces
.
Vector
;
Path
:
String
)
return
Tag
is
Result
:
Tag
;
Tmplt_Sign
:
constant
String
:=
Path
&
"interface.tmplt"
;
begin
for
Each
of
Interfaces
loop
Result
:=
Result
&
String
'(
Parse
(
Tmplt_Sign
,
Each
.
Header
));
Result
:=
Result
&
String
'(
Parse
(
Tmplt_Sign
,
Each
));
end
loop
;
return
Result
;
end
Process_Interfaces
;
...
...
@@ -398,38 +398,10 @@ package body TASTE.Backend.Code_Generators is
&
Assoc
(
"Instance_Of"
,
F
.
Instance_Of
.
Value_Or
(
US
(
""
))));
function
Interface_Template
(
TI
:
Taste_Interface
)
return
Interface_As_Template
is
-- use Template_Vectors;
Result
:
Interface_As_Template
;
Param_Names
:
Vector_Tag
;
Param_Types
:
Vector_Tag
;
Param_Directions
:
Vector_Tag
;
Param_Encodings
:
Vector_Tag
;
begin
Result
.
Header
:=
+
Assoc
(
"Name"
,
TI
.
Name
)
&
Assoc
(
"Kind"
,
TI
.
RCM
'
Img
)
&
Assoc
(
"Parent_Function"
,
TI
.
Parent_Function
);
for
Each
of
TI
.
Params
loop
-- Result.Params := Result.Params & Parameter_Template (Each, TI);
Param_Names
:=
Param_Names
&
Each
.
Name
;
Param_Types
:=
Param_Types
&
Each
.
Sort
;
Param_Directions
:=
Param_Directions
&
Each
.
Direction
'
Img
;
Param_Encodings
:=
Param_Encodings
&
Each
.
Encoding
'
Img
;
end
loop
;
Result
.
Header
:=
Result
.
Header
&
Assoc
(
"Param_Names"
,
Param_Names
)
&
Assoc
(
"Param_Types"
,
Param_Types
)
&
Assoc
(
"Param_Encodings"
,
Param_Encodings
)
&
Assoc
(
"Param_Directions"
,
Param_Directions
);
return
Result
;
end
Interface_Template
;
function
Func_Template
(
F
:
Taste_Terminal_Function
)
return
Func_As_Template
is
use
Interface_Vectors
;
use
Ctxt_Params
;
use
ST_Interfaces
;
Result
:
Func_As_Template
;
List_Of_PIs
:
Tag
;
List_Of_RIs
:
Tag
;
...
...
@@ -444,7 +416,7 @@ package body TASTE.Backend.Code_Generators is
Property_Values
:
Vector_Tag
;
CP_Names
:
Vector_Tag
;
-- For Context Parameters
CP_Types
:
Vector_Tag
;
-- For Context Parameters
Interface_Tmplt
:
Interface_As_Template
;
Interface_Tmplt
:
Translate_Set
;
begin
Result
.
Header
:=
+
Assoc
(
"Name"
,
F
.
Name
)
&
Assoc
(
"Language"
,
Language_Spelling
(
F
))
...
...
@@ -456,7 +428,7 @@ package body TASTE.Backend.Code_Generators is
CP_Types
:=
CP_Types
&
Each
.
Sort
;
end
loop
;
-- Add all user-defined properties
-- Add all
function
user-defined properties
for
Each
of
F
.
User_Properties
loop
Property_Names
:=
Property_Names
&
Each
.
Name
;
Property_Values
:=
Property_Values
&
Each
.
Value
;
...
...
@@ -464,12 +436,16 @@ package body TASTE.Backend.Code_Generators is
-- Add list of all PI names (both synchronous and asynchronous)
for
Each
of
F
.
Provided
loop
Interface_Tmplt
:=
Interface_Template
(
Each
);
Interface_Tmplt
.
Header
:=
Interface_Tmplt
.
Header
&
Assoc
(
"Direction"
,
"PI"
)
&
Assoc
(
"Property_Names"
,
Property_Names
)
&
Assoc
(
"Property_Values"
,
Property_Values
)
&
Assoc
(
"Language"
,
Language_Spelling
(
F
));
-- Note: some backends need to have access to the function
-- user defined properties, and implementation language
-- They are added here. At the moment the user-defined properties
-- of the interfaces themselves are not part of the template
-- This could be be added later if needed.
Interface_Tmplt
:=
Each
.
To_Template
&
Assoc
(
"Direction"
,
"PI"
)
&
Assoc
(
"Property_Names"
,
Property_Names
)
&
Assoc
(
"Property_Values"
,
Property_Values
)
&
Assoc
(
"Language"
,
Language_Spelling
(
F
));
Result
.
Provided
:=
Result
.
Provided
&
Interface_Tmplt
;
List_Of_PIs
:=
List_Of_PIs
&
Each
.
Name
;
case
Each
.
RCM
is
...
...
@@ -482,12 +458,11 @@ package body TASTE.Backend.Code_Generators is
-- Add list of all RI names (both synchronous and asynchronous)
for
Each
of
F
.
Required
loop
Interface_Tmplt
:=
Interface_Template
(
Each
);
Interface_Tmplt
.
Header
:=
Interface_Tmplt
.
Header
&
Assoc
(
"Direction"
,
"RI"
)
&
Assoc
(
"Property_Names"
,
Property_Names
)
&
Assoc
(
"Property_Values"
,
Property_Values
)
&
Assoc
(
"Language"
,
Language_Spelling
(
F
));
Interface_Tmplt
:=
Each
.
To_Template
&
Assoc
(
"Direction"
,
"RI"
)
&
Assoc
(
"Property_Names"
,
Property_Names
)
&
Assoc
(
"Property_Values"
,
Property_Values
)
&
Assoc
(
"Language"
,
Language_Spelling
(
F
));
Result
.
Required
:=
Result
.
Required
&
Interface_Tmplt
;
List_Of_RIs
:=
List_Of_RIs
&
Each
.
Name
;
case
Each
.
RCM
is
...
...
src/taste-backend-code_generators.ads
View file @
13ce1261
...
...
@@ -13,20 +13,13 @@ package TASTE.Backend.Code_Generators is
private
package
Template_Vectors
is
new
Indefinite_Vectors
(
Natural
,
Translate_Set
);
type
Interface_As_Template
is
record
Header
:
Translate_Set
;
-- Params : Template_Vectors.Vector;
end
record
;
package
Interface_Vectors
is
new
Indefinite_Vectors
(
Natural
,
Interface_As_Template
);
package
ST_Interfaces
is
new
Indefinite_Vectors
(
Natural
,
Translate_Set
);
type
Func_As_Template
is
record
Header
:
Translate_set
;
Provided
:
Interface
_Vector
s
.
Vector
;
Required
:
Interface
_Vector
s
.
Vector
;
Provided
:
ST_
Interfaces
.
Vector
;
Required
:
ST_
Interfaces
.
Vector
;
end
record
;
package
Func_Maps
is
new
Indefinite_Ordered_Maps
(
String
,
Func_As_Template
);
...
...
@@ -37,8 +30,6 @@ private
end
record
;
-- Set of functions translating the AST into Templates_Parser mappings
function
Interface_Template
(
TI
:
Taste_Interface
)
return
Interface_As_Template
;
function
Func_Template
(
F
:
Taste_Terminal_Function
)
return
Func_As_Template
;
function
CP_Template
(
F
:
Taste_Terminal_Function
)
return
Translate_Set
;
...
...
src/taste-concurrency_view.adb
View file @
13ce1261
...
...
@@ -42,7 +42,7 @@ package body TASTE.Concurrency_View is
end
Debug_Dump
;
-- This function translates a protected block into a template
function
Pro_To_ST
(
B
:
Protected_Block
)
return
Translate_Set
is
function
To_Template
(
B
:
Protected_Block
)
return
Translate_Set
is
Calling_Threads
:
Tag
;
-- TODO: Provided and Required
begin
...
...
@@ -55,10 +55,10 @@ package body TASTE.Concurrency_View is
&
Assoc
(
"Calling_Threads"
,
Calling_Threads
)
&
Assoc
(
"Node_Name"
,
To_String
(
B
.
Node
.
Value_Or
(
Taste_Node
'(
Name
=>
US
(
""
),
others
=>
<>
)).
Name
)));
end
Pro_To_ST
;
end
To_Template
;
-- This function translates a thread definition into a template
function
T
hread_To_ST
(
T
:
AADL_Thread
)
return
Translate_Set
is
function
T
o_Template
(
T
:
AADL_Thread
)
return
Translate_Set
is
Remote_Thread
:
Vector_Tag
;
Remote_PI
:
Vector_Tag
;
Ports_Matrix
:
Matrix_Tag
;
...
...
@@ -77,7 +77,7 @@ package body TASTE.Concurrency_View is
&
Assoc
(
"Node_Name"
,
To_String
(
T
.
Node
.
Value_Or
(
Taste_Node
'(
Name
=>
US
(
""
),
others
=>
<>
)).
Name
))
&
Assoc
(
"Out_Ports"
,
Ports_Matrix
));
end
T
hread_To_ST
;
end
T
o_Template
;
function
Concurrency_View_Template
(
CV
:
Taste_Concurrency_View
)
return
CV_As_Template
...
...
@@ -85,10 +85,10 @@ package body TASTE.Concurrency_View is
Result
:
CV_As_Template
;
begin
for
Thread
of
CV
.
Threads
loop
Result
.
Threads
.
Append
(
Thread
_
To_
ST
(
Thread
)
);
Result
.
Threads
.
Append
(
Thread
.
To_
Template
);
end
loop
;
for
Pro
of
CV
.
Blocks
loop
Result
.
Blocks
.
Append
(
Pro
_
To_
ST
(
Pro
)
);
Result
.
Blocks
.
Append
(
Pro
.
To_
Template
);
end
loop
;
return
Result
;
end
Concurrency_View_Template
;
...
...
src/taste-concurrency_view.ads
View file @
13ce1261
...
...
@@ -35,7 +35,7 @@ package TASTE.Concurrency_View is
package
Protected_Block_PIs
is
new
Indefinite_Ordered_Maps
(
String
,
Protected_Block_PI
);
type
Protected_Block
is
type
Protected_Block
is
tagged
record
Name
:
Unbounded_String
;
Provided
:
Protected_Block_PIs
.
Map
;
...
...
@@ -44,6 +44,8 @@ package TASTE.Concurrency_View is
Node
:
Option_Node
.
Option
;
end
record
;
function
To_Template
(
B
:
Protected_Block
)
return
Translate_Set
;
package
Protected_Blocks
is
new
Indefinite_Ordered_Maps
(
String
,
Protected_Block
);
...
...
@@ -55,7 +57,7 @@ package TASTE.Concurrency_View is
package
Ports
is
new
Indefinite_Ordered_Maps
(
String
,
Port
);
type
AADL_Thread
is
type
AADL_Thread
is
tagged
record
Name
:
Unbounded_String
;
Entry_Port_Name
:
Unbounded_String
;
...
...
@@ -64,6 +66,8 @@ package TASTE.Concurrency_View is
Node
:
Option_Node
.
Option
;
end
record
;
function
To_Template
(
T
:
AADL_Thread
)
return
Translate_Set
;
package
AADL_Threads
is
new
Indefinite_Ordered_Maps
(
String
,
AADL_Thread
);
type
Taste_Concurrency_View
is
tagged
...
...
src/taste-interface_view.adb
View file @
13ce1261
...
...
@@ -958,4 +958,29 @@ package body TASTE.Interface_View is
New_Line
(
Output
);
end
loop
;
end
Debug_Dump
;
-- Create a Templates_Parser translate set for an interface (PI or RI)
function
To_Template
(
TI
:
Taste_Interface
)
return
Translate_Set
is
Result
:
Translate_Set
;
Param_Names
:
Vector_Tag
;
Param_Types
:
Vector_Tag
;
Param_Directions
:
Vector_Tag
;
Param_Encodings
:
Vector_Tag
;
begin
Result
:=
+
Assoc
(
"Name"
,
TI
.
Name
)
&
Assoc
(
"Kind"
,
TI
.
RCM
'
Img
)
&
Assoc
(
"Parent_Function"
,
TI
.
Parent_Function
);
for
Each
of
TI
.
Params
loop
Param_Names
:=
Param_Names
&
Each
.
Name
;
Param_Types
:=
Param_Types
&
Each
.
Sort
;
Param_Directions
:=
Param_Directions
&
Each
.
Direction
'
Img
;
Param_Encodings
:=
Param_Encodings
&
Each
.
Encoding
'
Img
;
end
loop
;
Result
:=
Result
&
Assoc
(
"Param_Names"
,
Param_Names
)
&
Assoc
(
"Param_Types"
,
Param_Types
)
&
Assoc
(
"Param_Encodings"
,
Param_Encodings
)
&
Assoc
(
"Param_Directions"
,
Param_Directions
);
return
Result
;
end
To_Template
;
end
TASTE
.
Interface_View
;
src/taste-interface_view.ads
View file @
13ce1261
...
...
@@ -10,6 +10,7 @@ with Ada.Containers.Indefinite_Ordered_Maps,
Ada
.
Strings
.
Equal_Case_Insensitive
,
Ada
.
Strings
.
Less_Case_Insensitive
,
Text_IO
,
Templates_Parser
,
Ocarina
,
Ocarina
.
Types
,
Option_Type
,
...
...
@@ -18,6 +19,7 @@ with Ada.Containers.Indefinite_Ordered_Maps,
use
Ada
.
Containers
,
Ada
.
Strings
.
Unbounded
,
Text_IO
,
Templates_Parser
,
Ocarina
,
Ocarina
.
Types
,
TASTE
.
Parser_Utils
;
...
...
@@ -99,7 +101,7 @@ package TASTE.Interface_View is
package
Remote_Entities
is
new
Indefinite_Vectors
(
Natural
,
Remote_Entity
);
type
Taste_Interface
is
type
Taste_Interface
is
tagged
record
Name
:
Unbounded_String
;
Parent_Function
:
Unbounded_String
;
...
...
@@ -112,6 +114,8 @@ package TASTE.Interface_View is
User_Properties
:
Property_Maps
.
Map
;
end
record
;
function
To_Template
(
TI
:
Taste_Interface
)
return
Translate_Set
;
package
Interfaces_Maps
is
new
Indefinite_Ordered_Maps
(
String
,
Taste_Interface
);
...
...
@@ -129,7 +133,7 @@ package TASTE.Interface_View is
type
Taste_Terminal_Function
is
record
Name
:
Unbounded_String
;
Context
:
Unbounded_String
:=
Null_Unbounded_String
;
Context
:
Unbounded_String
:=
Null_Unbounded_String
;
Full_Prefix
:
Option_UString
.
Option
:=
Option_UString
.
Nothing
;
-- Language : Supported_Source_Language;
Language
:
Unbounded_String
;
...
...
@@ -151,8 +155,7 @@ package TASTE.Interface_View is
function
"<"
(
Left
,
Right
:
Case_Insensitive_String
)
return
Boolean
renames
Ada
.
Strings
.
Less_Case_Insensitive
;
package
Function_Maps
is
new
Indefinite_Ordered_Maps
(
Case_Insensitive_String
,
Taste_Terminal_Function
);
(
Case_Insensitive_String
,
Taste_Terminal_Function
);
type
Connection
is
record
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment