Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
buildsupport
Commits
a4728995
Commit
a4728995
authored
Sep 01, 2016
by
Maxime Perrotin
Browse files
Improve VDM backend
parent
9c93d745
Pipeline
#1186
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
c/build_vdm_skeletons.c
View file @
a4728995
...
@@ -36,13 +36,30 @@ void vdm_gw_preamble(FV * fv)
...
@@ -36,13 +36,30 @@ void vdm_gw_preamble(FV * fv)
CheckForAsn1Params
(
i
,
&
hasparam
);
CheckForAsn1Params
(
i
,
&
hasparam
);
});
});
if
(
hasparam
)
{
if
(
hasparam
)
{
fprintf
(
c_bridge
,
"#include
\"
Vdm_ASN1_Types.h
\"\n
\n
"
);
fprintf
(
c_bridge
,
"#include
\"
Vdm_ASN1_Types.h
\"\n
"
);
}
}
fprintf
(
c_bridge
,
"void %s_startup()
\n
"
/* Initialize the VDM class and call the startup function */
fprintf
(
c_bridge
,
"#include
\"
%s.h
\"\n\n
"
"static TVP %s;
\n\n
"
"void %s_startup()
\n
"
"{
\n
"
"{
\n
"
" // TODO: Call VDM Startup function
\n
"
" //%s_const_init();
\n
"
" //%s_static_init();
\n
"
" %s = _Z%d%sEV(NULL);
\n
"
" CALL_FUNC(%s, %s, %s, CLASS_%s__Z7StartupEV);
\n
"
"}
\n\n
"
,
"}
\n\n
"
,
fv
->
name
,
fv
->
name
,
fv
->
name
,
fv
->
name
,
fv
->
name
,
fv
->
name
,
strlen
(
fv
->
name
),
fv
->
name
,
fv
->
name
,
fv
->
name
,
fv
->
name
,
fv
->
name
);
fv
->
name
);
fprintf
(
interface
,
fprintf
(
interface
,
...
@@ -85,7 +102,7 @@ void Init_VDM_GW_Backend(FV *fv)
...
@@ -85,7 +102,7 @@ void Init_VDM_GW_Backend(FV *fv)
}
}
free
(
filename
);
free
(
filename
);
filename
=
make_string
(
"%s.c"
,
fv
->
name
);
filename
=
make_string
(
"%s
_bridge
.c"
,
fv
->
name
);
create_file
(
path
,
filename
,
&
c_bridge
);
create_file
(
path
,
filename
,
&
c_bridge
);
free
(
filename
);
free
(
filename
);
...
@@ -99,7 +116,7 @@ void Init_VDM_GW_Backend(FV *fv)
...
@@ -99,7 +116,7 @@ void Init_VDM_GW_Backend(FV *fv)
* Write in user_code.h the declaration of the user functions
* Write in user_code.h the declaration of the user functions
* and if user_code.c is new, copy these declarations there too.
* and if user_code.c is new, copy these declarations there too.
*/
*/
void
add_pi_to_vdm_gw
(
Interface
*
i
)
void
add_pi_to_vdm_gw
(
Interface
*
i
,
int
idx
)
{
{
if
(
NULL
==
interface
)
if
(
NULL
==
interface
)
return
;
return
;
...
@@ -195,8 +212,8 @@ void add_pi_to_vdm_gw(Interface * i)
...
@@ -195,8 +212,8 @@ void add_pi_to_vdm_gw(Interface * i)
FOREACH
(
param
,
Parameter
,
i
->
in
,
{
FOREACH
(
param
,
Parameter
,
i
->
in
,
{
fprintf
(
c_bridge
,
fprintf
(
c_bridge
,
" TVP
*
ptr
VDM
_%s = NULL;
\n
"
" TVP ptr_%s = NULL;
\n
"
" Convert_%s_from_ASN1SCC_to_VDM(ptr
VDM
_%s, IN_%s);
\n
"
,
" Convert_%s_from_ASN1SCC_to_VDM(ptr_%s, IN_%s);
\n
"
,
param
->
name
,
param
->
name
,
param
->
type
,
param
->
type
,
param
->
name
,
param
->
name
,
...
@@ -206,26 +223,26 @@ void add_pi_to_vdm_gw(Interface * i)
...
@@ -206,26 +223,26 @@ void add_pi_to_vdm_gw(Interface * i)
if
(
i
->
out
)
{
if
(
i
->
out
)
{
fprintf
(
c_bridge
,
fprintf
(
c_bridge
,
"
\n
TVP vdm_OUT_%s;
\n
"
"
\n
TVP vdm_OUT_%s;
\n
"
"
//
vdm_OUT_%s = "
,
" vdm_OUT_%s = "
,
i
->
out
->
value
->
name
,
i
->
out
->
value
->
name
,
i
->
out
->
value
->
name
);
i
->
out
->
value
->
name
);
}
}
else
{
else
{
fprintf
(
c_bridge
,
fprintf
(
c_bridge
,
"
\n
//
"
);
// remove the comment when name is known
"
\n
"
);
}
}
fprintf
(
c_bridge
,
fprintf
(
c_bridge
,
"Call_VDM_%s("
,
"CALL_FUNC(%s, %s, %s, %d"
,
i
->
name
);
i
->
parent_fv
->
name
,
i
->
parent_fv
->
name
,
i
->
parent_fv
->
name
,
idx
);
comma
=
false
;
FOREACH
(
param
,
Parameter
,
i
->
in
,
{
FOREACH
(
param
,
Parameter
,
i
->
in
,
{
fprintf
(
c_bridge
,
fprintf
(
c_bridge
,
"%sptrVDM_%s"
,
", ptr_%s"
,
comma
?
sep2
:
""
,
param
->
name
);
param
->
name
);
comma
=
true
;
});
});
fprintf
(
c_bridge
,
");
\n
"
);
fprintf
(
c_bridge
,
");
\n
"
);
...
@@ -263,11 +280,11 @@ void End_VDM_GW_Backend(FV *fv)
...
@@ -263,11 +280,11 @@ void End_VDM_GW_Backend(FV *fv)
}
}
/* Function to process one interface of the FV */
/* Function to process one interface of the FV */
void
GW_VDM_Interface
(
Interface
*
i
)
void
GW_VDM_Interface
(
Interface
*
i
,
int
idx
)
{
{
switch
(
i
->
direction
)
{
switch
(
i
->
direction
)
{
case
PI
:
case
PI
:
add_pi_to_vdm_gw
(
i
);
add_pi_to_vdm_gw
(
i
,
idx
);
break
;
break
;
case
RI
:
case
RI
:
...
@@ -297,12 +314,16 @@ void GW_VDM_Interface(Interface * i)
...
@@ -297,12 +314,16 @@ void GW_VDM_Interface(Interface * i)
/* External interface (the one and unique) */
/* External interface (the one and unique) */
void
GW_VDM_Backend
(
FV
*
fv
)
void
GW_VDM_Backend
(
FV
*
fv
)
{
{
int
count
=
1
;
if
(
fv
->
system_ast
->
context
->
onlycv
)
if
(
fv
->
system_ast
->
context
->
onlycv
)
return
;
return
;
if
(
vdm
==
fv
->
language
)
{
if
(
vdm
==
fv
->
language
)
{
Init_VDM_GW_Backend
(
fv
);
Init_VDM_GW_Backend
(
fv
);
FOREACH
(
i
,
Interface
,
fv
->
interfaces
,
{
FOREACH
(
i
,
Interface
,
fv
->
interfaces
,
{
GW_VDM_Interface
(
i
);
GW_VDM_Interface
(
i
,
count
);
if
(
PI
==
i
->
direction
)
{
count
++
;
}
});
});
End_VDM_GW_Backend
(
fv
);
End_VDM_GW_Backend
(
fv
);
}
}
...
...
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