Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lustre-v6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
verimag
synchrone
lustre-v6
Commits
cda63b94
Commit
cda63b94
authored
10 years ago
by
Erwan Jahier
Browse files
Options
Downloads
Patches
Plain Diff
Soc2c: Print user typedef in the good order (wrt type dependencies)
nb: unexpected failures 133-> 131
parent
c1159ec0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/soc2c.ml
+41
-8
41 additions, 8 deletions
src/soc2c.ml
test/lus2lic.sum
+6
-6
6 additions, 6 deletions
test/lus2lic.sum
test/lus2lic.time
+1
-1
1 addition, 1 deletion
test/lus2lic.time
with
48 additions
and
15 deletions
src/soc2c.ml
+
41
−
8
View file @
cda63b94
(* Time-stamp: <modified the 24/06/2014 (at
09:44
) by Erwan Jahier> *)
(* Time-stamp: <modified the 24/06/2014 (at
14:26
) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
...
@@ -57,7 +57,7 @@ let rec (lic_type_to_c: Lic.type_ -> string -> string) =
...
@@ -57,7 +57,7 @@ let rec (lic_type_to_c: Lic.type_ -> string -> string) =
let
field_to_c
(
id
,
(
tf
,_
opt
))
=
let
field_to_c
(
id
,
(
tf
,_
opt
))
=
Printf
.
sprintf
"
\n
%s;"
(
type_to_string
(
Lic2soc
.
lic_to_data_type
tf
)
(
id2s
id
))
Printf
.
sprintf
"
\n
%s;"
(
type_to_string
(
Lic2soc
.
lic_to_data_type
tf
)
(
id2s
id
))
in
in
((
Printf
.
sprintf
"struct { %s }
"
((
Printf
.
sprintf
"struct { %s
\n
}"
(
String
.
concat
""
(
List
.
map
field_to_c
fl
)))
^
" "
^
n
)
(
String
.
concat
""
(
List
.
map
field_to_c
fl
)))
^
" "
^
n
)
|
Enum_type_eff
(
name
,
l
)
->
"_integer"
^
" "
^
n
|
Enum_type_eff
(
name
,
l
)
->
"_integer"
^
" "
^
n
|
_
->
type_to_string
(
Lic2soc
.
lic_to_data_type
t
)
n
|
_
->
type_to_string
(
Lic2soc
.
lic_to_data_type
t
)
n
...
@@ -137,6 +137,7 @@ let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) =
...
@@ -137,6 +137,7 @@ let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) =
let
gen_assign2
vi
vo
=
let
gen_assign2
vi
vo
=
Soc2cUtil
.
gen_assign
(
Soc
.
data_type_of_var_expr
vi
)
Soc2cUtil
.
gen_assign
(
Soc
.
data_type_of_var_expr
vi
)
(
string_of_var_expr
sp
.
soc
vi
)
(
string_of_var_expr
sp
.
soc
vo
)
(
string_of_var_expr
sp
.
soc
vi
)
(
string_of_var_expr
sp
.
soc
vo
)
(
Printf
.
sprintf
"sizeof(%s)"
(
string_of_var_expr
sp
.
soc
vo
))
in
in
let
l
=
List
.
map2
gen_assign2
vel_out
vel_in
in
let
l
=
List
.
map2
gen_assign2
vel_out
vel_in
in
String
.
concat
""
l
String
.
concat
""
l
...
@@ -284,6 +285,24 @@ let (typedef_of_soc : Soc.t -> string) =
...
@@ -284,6 +285,24 @@ let (typedef_of_soc : Soc.t -> string) =
str
str
module
KeySet
=
Set
.
Make
(
struct
type
t
=
Soc
.
key
let
compare
=
compare
end
)
module
KeySet
=
Set
.
Make
(
struct
type
t
=
Soc
.
key
let
compare
=
compare
end
)
module
ItemKeySet
=
Set
.
Make
(
struct
type
t
=
Lic
.
item_key
let
compare
=
compare
end
)
(* To perform the topological sort of typedef. nf stands for "no
fixpoint", that should be done by the caller. it is recursive just
to deal with array of arrays *)
let
(
find_typedep_nf
:
Lic
.
type_
->
Lic
.
item_key
list
)
=
fun
t
->
let
rec
aux
top
=
function
|
Lic
.
Bool_type_eff
|
Lic
.
Int_type_eff
|
Lic
.
Real_type_eff
|
Lic
.
External_type_eff
_
|
Lic
.
TypeVar
_
->
[]
|
Lic
.
Abstract_type_eff
(
name
,_
)
|
Lic
.
Enum_type_eff
(
name
,_
)
->
if
top
then
[]
(* avoid self dep *)
else
[
name
]
|
Lic
.
Array_type_eff
(
t
,_
)
->
aux
false
t
|
Lic
.
Struct_type_eff
(
name
,
fl
)
->
if
not
top
then
[
name
]
else
List
.
flatten
(
List
.
map
(
fun
(
_
,
(
t
,_
))
->
aux
false
t
)
fl
)
in
aux
true
t
let
(
typedef
:
LicPrg
.
t
->
Soc
.
tbl
->
Soc
.
t
->
string
)
=
let
(
typedef
:
LicPrg
.
t
->
Soc
.
tbl
->
Soc
.
t
->
string
)
=
fun
licprg
soc_tbl
main_soc
->
fun
licprg
soc_tbl
main_soc
->
...
@@ -321,13 +340,27 @@ let (typedef : LicPrg.t -> Soc.tbl -> Soc.t -> string) =
...
@@ -321,13 +340,27 @@ let (typedef : LicPrg.t -> Soc.tbl -> Soc.t -> string) =
in
in
List
.
fold_left
memless_soc_to_string
""
socs
List
.
fold_left
memless_soc_to_string
""
socs
in
in
(* There are also typedef that comes from user in Lustre V6 *)
let
to_c
k
t
=
let
user_typedef
=
Printf
.
sprintf
"typedef %s;
\n
"
(
lic_type_to_c
t
(
long2s
k
))
let
to_c
k
t
=
Printf
.
sprintf
"typedef %s;
\n
"
(
lic_type_to_c
t
(
long2s
k
))
in
LicPrg
.
fold_types
(
fun
k
t
acc
->
acc
^
(
to_c
k
t
))
licprg
""
in
in
let
rec
(
typedef_to_string
:
Lic
.
item_key
->
Lic
.
type_
->
string
*
ItemKeySet
.
t
->
string
*
ItemKeySet
.
t
)
=
fun
k
t
acc
->
(* topological sort according to type dep *)
if
ItemKeySet
.
mem
k
(
snd
acc
)
then
acc
else
let
type_list
=
find_typedep_nf
t
in
let
acc
=
List
.
fold_left
(
fun
acc
k
->
match
LicPrg
.
find_type
licprg
k
with
|
Some
t
->
typedef_to_string
k
t
acc
|
None
->
acc
(* occurs ? *)
)
acc
type_list
in
((
fst
acc
)
^
(
to_c
k
t
)
,
ItemKeySet
.
add
k
(
snd
acc
))
in
let
user_typedef
,_
=
LicPrg
.
fold_types
typedef_to_string
licprg
(
""
,
ItemKeySet
.
empty
)
in
"// User typedef
\n
"
^
user_typedef
"// User typedef
\n
"
^
user_typedef
^
"// Memoryless soc ctx typedef
\n
"
^
soc_ctx_typedef_without
^
"// Memoryless soc ctx typedef
\n
"
^
soc_ctx_typedef_without
^
"// Memoryfull soc ctx typedef
\n
"
^
soc_ctx_typedef_with
^
"// Memoryfull soc ctx typedef
\n
"
^
soc_ctx_typedef_with
...
...
This diff is collapsed.
Click to expand it.
test/lus2lic.sum
+
6
−
6
View file @
cda63b94
Test Run By jahier on Tue Jun 24
09:50:48
2014
Test Run By jahier on Tue Jun 24
15:01:05
2014
Native configuration is i686-pc-linux-gnu
Native configuration is i686-pc-linux-gnu
=== lus2lic tests ===
=== lus2lic tests ===
...
@@ -513,7 +513,7 @@ PASS: ./lus2lic {-ec -o /tmp/morel5.ec should_work/morel5.lus}
...
@@ -513,7 +513,7 @@ PASS: ./lus2lic {-ec -o /tmp/morel5.ec should_work/morel5.lus}
PASS: ./myec2c {-o /tmp/morel5.c /tmp/morel5.ec}
PASS: ./myec2c {-o /tmp/morel5.c /tmp/morel5.ec}
PASS: ../utils/test_lus2lic_no_node should_work/morel5.lus
PASS: ../utils/test_lus2lic_no_node should_work/morel5.lus
PASS: ./lus2lic {-2c should_work/morel5.lus -n morel5}
PASS: ./lus2lic {-2c should_work/morel5.lus -n morel5}
FAIL: Check that the generated C code compiles
: gcc morel5_morel5.c morel5_morel5_loop.c
PASS
: gcc morel5_morel5.c morel5_morel5_loop.c
PASS: ./lus2lic {-o /tmp/bred.lic should_work/bred.lus}
PASS: ./lus2lic {-o /tmp/bred.lic should_work/bred.lus}
PASS: ./lus2lic {-ec -o /tmp/bred.ec should_work/bred.lus}
PASS: ./lus2lic {-ec -o /tmp/bred.ec should_work/bred.lus}
PASS: ./myec2c {-o /tmp/bred.c /tmp/bred.ec}
PASS: ./myec2c {-o /tmp/bred.c /tmp/bred.ec}
...
@@ -1053,7 +1053,7 @@ PASS: ./lus2lic {-ec -o /tmp/Gyroscope.ec should_work/Gyroscope.lus}
...
@@ -1053,7 +1053,7 @@ PASS: ./lus2lic {-ec -o /tmp/Gyroscope.ec should_work/Gyroscope.lus}
PASS: ./myec2c {-o /tmp/Gyroscope.c /tmp/Gyroscope.ec}
PASS: ./myec2c {-o /tmp/Gyroscope.c /tmp/Gyroscope.ec}
FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
PASS: ./lus2lic {-2c should_work/Gyroscope.lus -n Gyroscope}
PASS: ./lus2lic {-2c should_work/Gyroscope.lus -n Gyroscope}
FAIL: Check that the generated C code compiles
: gcc Gyroscope_Gyroscope.c Gyroscope_Gyroscope_loop.c
PASS
: gcc Gyroscope_Gyroscope.c Gyroscope_Gyroscope_loop.c
PASS: ./lus2lic {-o /tmp/test_map.lic should_work/test_map.lus}
PASS: ./lus2lic {-o /tmp/test_map.lic should_work/test_map.lus}
PASS: ./lus2lic {-ec -o /tmp/test_map.ec should_work/test_map.lus}
PASS: ./lus2lic {-ec -o /tmp/test_map.ec should_work/test_map.lus}
PASS: ./myec2c {-o /tmp/test_map.c /tmp/test_map.ec}
PASS: ./myec2c {-o /tmp/test_map.c /tmp/test_map.ec}
...
@@ -1482,9 +1482,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman
...
@@ -1482,9 +1482,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman
=== lus2lic Summary ===
=== lus2lic Summary ===
# of expected passes 12
79
# of expected passes 12
81
# of unexpected failures 13
3
# of unexpected failures 13
1
# of unexpected successes 21
# of unexpected successes 21
# of expected failures 37
# of expected failures 37
testcase ./lus2lic.tests/non-reg.exp completed in 13
9
seconds
testcase ./lus2lic.tests/non-reg.exp completed in 13
7
seconds
testcase ./lus2lic.tests/progression.exp completed in 0 seconds
testcase ./lus2lic.tests/progression.exp completed in 0 seconds
This diff is collapsed.
Click to expand it.
test/lus2lic.time
+
1
−
1
View file @
cda63b94
testcase ./lus2lic.tests/non-reg.exp completed in 13
9
seconds
testcase ./lus2lic.tests/non-reg.exp completed in 13
7
seconds
testcase ./lus2lic.tests/progression.exp completed in 0 seconds
testcase ./lus2lic.tests/progression.exp completed in 0 seconds
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment