Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
55863184
Commit
55863184
authored
Jan 21, 2018
by
Maxime Perrotin
Browse files
Prepare for code generation
parent
6e3fa960
Changes
12
Hide whitespace changes
Inline
Side-by-side
aadl_parser.gpr
View file @
55863184
with
"ocarina/ocarina"
;
with
"ocarina/ocarina"
;
with
"templates_parser"
;
with
"templates
-parser/templates
_parser"
;
project
AADL_Parser
is
project
AADL_Parser
is
...
...
src/taste-aadl_parser.adb
View file @
55863184
...
@@ -13,7 +13,8 @@ with System.Assertions,
...
@@ -13,7 +13,8 @@ with System.Assertions,
Ocarina
.
Configuration
,
Ocarina
.
Configuration
,
Ocarina
.
Files
,
Ocarina
.
Files
,
Ocarina
.
Parser
,
Ocarina
.
Parser
,
TASTE
.
Backend
.
Build_Script
;
TASTE
.
Backend
.
Build_Script
,
TASTE
.
Backend
.
Skeletons
;
use
Ada
.
Text_IO
,
use
Ada
.
Text_IO
,
Ada
.
Exceptions
,
Ada
.
Exceptions
,
...
@@ -205,4 +206,9 @@ package body TASTE.AADL_Parser is
...
@@ -205,4 +206,9 @@ package body TASTE.AADL_Parser is
TASTE
.
Backend
.
Build_Script
.
Generate
(
Model
);
TASTE
.
Backend
.
Build_Script
.
Generate
(
Model
);
end
Generate_Build_Script
;
end
Generate_Build_Script
;
procedure
Generate_Skeletons
(
Model
:
TASTE_Model
)
is
begin
TASTE
.
Backend
.
Skeletons
.
Generate
(
Model
);
end
Generate_Skeletons
;
end
TASTE
.
AADL_Parser
;
end
TASTE
.
AADL_Parser
;
src/taste-aadl_parser.ads
View file @
55863184
...
@@ -32,6 +32,7 @@ package TASTE.AADL_Parser is
...
@@ -32,6 +32,7 @@ package TASTE.AADL_Parser is
procedure
Dump
(
Model
:
TASTE_Model
);
procedure
Dump
(
Model
:
TASTE_Model
);
procedure
Generate_Build_Script
(
Model
:
TASTE_Model
);
procedure
Generate_Build_Script
(
Model
:
TASTE_Model
);
procedure
Generate_Skeletons
(
Model
:
TASTE_Model
);
private
private
function
Initialize
return
Taste_Configuration
;
function
Initialize
return
Taste_Configuration
;
...
...
src/taste-backend-skeletons-c.adb
0 → 100644
View file @
55863184
with
Text_IO
,
Templates_Parser
;
use
Text_IO
,
Templates_Parser
;
package
body
TASTE
.
Backend
.
Skeletons
.
C
is
procedure
Generate
(
Config
:
Taste_Configuration
;
Template
:
Translate_Set
)
is
dummy_Prefix
:
constant
String
:=
Config
.
Binary_Path
.
all
&
"templates/skeletons/c"
;
begin
null
;
end
Generate
;
end
TASTE
.
Backend
.
Skeletons
.
C
;
src/taste-backend-skeletons-c.ads
0 → 100644
View file @
55863184
with
TASTE
.
Interface_View
,
TASTE
.
Parser_Utils
;
use
TASTE
.
Interface_View
,
TASTE
.
Parser_Utils
;
package
TASTE
.
Backend
.
Skeletons
.
C
is
procedure
Generate
(
Config
:
Taste_Configuration
;
Func
:
Taste_Terminal_Function
);
pragma
Unreferenced
(
Generate
);
end
TASTE
.
Backend
.
Skeletons
.
C
;
src/taste-backend-skeletons.adb
0 → 100644
View file @
55863184
with
Text_IO
;
use
Text_IO
;
-- with TASTE.Backend.Skeletons.C;
package
body
TASTE
.
Backend
.
Skeletons
is
procedure
Generate
(
Model
:
TASTE_Model
)
is
dummy_Template
:
constant
IV_As_Template
:=
Interface_View_Template
(
Model
.
Interface_View
);
begin
Put_Line
(
"=== Generate skeletons ==="
);
-- case Each.Language is
-- when Language_C =>
-- TASTE.Backend.Skeletons.C.Generate (Model.Configuration,
-- Template);
-- when others =>
-- Put_Line (Each.Language'Img & "Not supported yet");
-- end case;
-- end;
-- end loop;
end
Generate
;
function
Parameter_Template
(
Param
:
ASN1_Parameter
)
return
Translate_Set
is
(
+
Assoc
(
"Type"
,
Param
.
Sort
)
&
Assoc
(
"Name"
,
Param
.
Name
)
&
Assoc
(
"Direction"
,
Param
.
Direction
'
Img
));
function
Interface_Template
(
TI
:
Taste_Interface
)
return
Interface_As_Template
is
use
Template_Vectors
;
Result
:
Interface_As_Template
;
begin
Result
.
Header
:=
+
Assoc
(
"Name"
,
TI
.
Name
)
&
Assoc
(
"Parent_Function"
,
TI
.
Parent_Function
);
for
Each
of
TI
.
Params
loop
Result
.
Params
:=
Result
.
Params
&
Parameter_Template
(
Each
);
end
loop
;
return
Result
;
end
Interface_Template
;
function
Func_Template
(
F
:
Taste_Terminal_Function
)
return
Func_As_Template
is
use
Interface_Vectors
;
Result
:
Func_As_Template
;
begin
Result
.
Header
:=
+
Assoc
(
"Name"
,
F
.
Name
)
&
Assoc
(
"Language"
,
F
.
Language
'
Img
);
for
Each
of
F
.
Provided
loop
Result
.
Provided
:=
Result
.
Provided
&
Interface_Template
(
Each
);
end
loop
;
for
Each
of
F
.
Required
loop
Result
.
Required
:=
Result
.
Required
&
Interface_Template
(
Each
);
end
loop
;
return
Result
;
end
Func_Template
;
function
Interface_View_Template
(
IV
:
Complete_Interface_View
)
return
IV_As_Template
is
use
Func_Vectors
;
Result
:
IV_As_Template
;
begin
for
Each
of
IV
.
Flat_Functions
loop
Result
.
Funcs
:=
Result
.
Funcs
&
Func_Template
(
Each
);
end
loop
;
return
Result
;
end
Interface_View_Template
;
end
TASTe
.
Backend
.
Skeletons
;
src/taste-backend-skeletons.ads
0 → 100644
View file @
55863184
with
Ada
.
Containers
.
Indefinite_Vectors
,
Templates_Parser
,
TASTE
.
AADL_Parser
;
use
Ada
.
Containers
,
Templates_Parser
,
TASTE
.
AADL_Parser
;
package
TASTE
.
Backend
.
Skeletons
is
procedure
Generate
(
Model
:
TASTE_Model
);
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
);
type
Func_As_Template
is
record
Header
:
Translate_set
;
Provided
:
Interface_Vectors
.
Vector
;
Required
:
Interface_Vectors
.
Vector
;
end
record
;
package
Func_Vectors
is
new
Indefinite_Vectors
(
Natural
,
Func_As_Template
);
type
IV_As_Template
is
record
Funcs
:
Func_Vectors
.
Vector
;
end
record
;
-- Set of functions translating the AST into Templates_Parser mappings
function
Parameter_Template
(
Param
:
ASN1_Parameter
)
return
Translate_Set
;
function
Interface_Template
(
TI
:
Taste_Interface
)
return
Interface_As_Template
;
function
Func_Template
(
F
:
Taste_Terminal_Function
)
return
Func_As_Template
;
function
Interface_View_Template
(
IV
:
Complete_Interface_View
)
return
IV_As_Template
;
end
TASTE
.
Backend
.
Skeletons
;
src/taste-parser_version.ads
View file @
55863184
package
TASTE
.
Parser_Version
is
package
TASTE
.
Parser_Version
is
Parser_Release
:
constant
String
:=
Parser_Release
:
constant
String
:=
"
b207577
; Commit Date:
Tue
Jan 1
6
1
5:55:38
2018 "
;
"
6e3fa96
; Commit Date:
Fri
Jan 1
9
1
7:21:22
2018 "
;
Ocarina_Version
:
constant
String
:=
Ocarina_Version
:
constant
String
:=
"Ocarina 2017.x (Working Copy from r0b92ed3)"
;
"Ocarina 2017.x (Working Copy from r0b92ed3)"
;
end
TASTE
.
Parser_Version
;
end
TASTE
.
Parser_Version
;
\ No newline at end of file
templates/skeletons/c/c-body.tmplt
0 → 100644
View file @
55863184
/* Body file for function @_Name_@
* Generated by TASTE on @_Now_@
* You can edit this file, it will not be overwritten
*/
#include "@_LOWER:Name_@.h"
@@IF@@ @_Has_Context_@
/* Include Context Parameters (constants defined in the Interface View) */
#include "Context-@_REPLACE((_)/(-)):LOWER:Name_@.h"
@@END_IF@@
void @_LOWER:Name_@_startup()
{
// Write your initialisation code, but DO NOT CALL REQUIRED INTERFACES
// puts ("[@_Name_@] Startup");
}
@@TABLE@@
void @_LOWER:Name_@_PI_@_Provided_Interfaces_@
{
/* Write your code here */
}
@@END_TABLE@@
@@TABLE@@
void @_LOWER:Name_@_PI_@_Timers_@
{
/* This function is called when the timer expires */
}
@@END_TABLE@@
templates/skeletons/c/c-header.tmplt
0 → 100644
View file @
55863184
/* Header file for function @_Name_@
* Generated by TASTE on @_Now_@
* DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN DURING THE BUILD
*/
#ifndef __USER_CODE_H_@_UPPER:Name_@
#define __USER_CODE_H_@_UPPER:Name_@
#include "C_ASN1_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
void @_LOWER:Name_@_startup();
@@TABLE@@
void @_LOWER:Name_@_PI_@_Provided_Interfaces_@;
@@END_TABLE@@
@@TABLE@@
void @_LOWER:Name_@_RI_@_Required_Interfaces_@;
@@END_TABLE@@
@@TABLE@@
@_Timers_@
@@END_TABLE@@
#ifdef __cplusplus
extern "C" {
#endif
#endif /* __USER_CODE_H_@_UPPER:Name_@
templates/skeletons/c/c-interface-body-in-parameter.tmplt
0 → 100644
View file @
55863184
const asn1Scc@_Type_@ *IN_@_LOWER:Name_@
templates/skeletons/c/c-interface-header.tmplt
0 → 100644
View file @
55863184
@_LOWER:Name_@(@@TABLE['TERSE]@@
@_Parameters_@,
@@END_TABLE@@
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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