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
32784a64
Commit
32784a64
authored
16 years ago
by
Erwan Jahier
Browse files
Options
Downloads
Patches
Plain Diff
Centralize the ident name creation in the Name module.
parent
403368c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/inline.ml
+6
-11
6 additions, 11 deletions
src/inline.ml
src/licDump.ml
+4
-9
4 additions, 9 deletions
src/licDump.ml
src/name.ml
+29
-2
29 additions, 2 deletions
src/name.ml
src/name.mli
+13
-1
13 additions, 1 deletion
src/name.mli
src/split.ml
+4
-8
4 additions, 8 deletions
src/split.ml
with
56 additions
and
31 deletions
src/inline.ml
+
6
−
11
View file @
32784a64
(** Time-stamp: <modified the 2
1
/11/2008 (at
17:16
) by Erwan Jahier> *)
(** Time-stamp: <modified the 2
6
/11/2008 (at
09:39
) by Erwan Jahier> *)
open
Lxm
...
...
@@ -6,10 +6,8 @@ open Eff
(********************************************************************************)
(* stuff to create fresh var names. *)
let
var_cpt
=
ref
0
let
new_var
str
node_env
type_eff
clock_eff
=
incr
var_cpt
;
let
id
=
Ident
.
of_string
(
str
^
(
string_of_int
!
var_cpt
))
in
let
id
=
Ident
.
of_string
(
Name
.
new_local_var
str
)
in
let
var
=
{
var_name_eff
=
id
;
...
...
@@ -23,10 +21,6 @@ let new_var str node_env type_eff clock_eff =
Hashtbl
.
add
node_env
.
lenv_vars
id
var
;
var
let
init_var
()
=
var_cpt
:=
0
(********************************************************************************)
(* A small util function followed by a quick unit test. *)
let
rec
fill
i
size
=
if
i
>=
size
then
[]
else
i
::
(
fill
(
i
+
1
)
size
)
...
...
@@ -164,7 +158,7 @@ let rec (inline_eq: Eff.local_env ->
let
(
acc_vars
:
var_info
list
)
=
let
rec
f
i
acc
=
if
i
=
0
then
acc
else
f
(
i
-
1
)
((
new_var
"
_
acc"
node_env
type_exp
clock_exp
)
::
acc
)
f
(
i
-
1
)
((
new_var
"acc"
node_env
type_exp
clock_exp
)
::
acc
)
in
(* coquetry: reverse the list to have the name in a nice order *)
List
.
rev
(
f
(
c
-
1
)
[]
)
...
...
@@ -237,7 +231,7 @@ let rec (inline_eq: Eff.local_env ->
let
index_list
=
fill
0
k
in
let
lp
=
try
List
.
hd
lhs
with
Not_found
->
assert
false
in
let
res_clock
=
(
Eff
.
var_info_of_left
lp
)
.
var_clock_eff
in
let
cpt
=
new_var
"
_
cpt"
node_env
Int_type_eff
res_clock
in
let
cpt
=
new_var
"cpt"
node_env
Int_type_eff
res_clock
in
let
id_of_int
i
=
Predef
.
ICONST_n
(
Ident
.
of_string
(
string_of_int
i
))
in
let
rhs
=
(* i <= cpt && cpt <= j; *)
let
i_op
=
{
it
=
Predef
(
id_of_int
i
,
[]
)
;
src
=
lxm_ve
}
...
...
@@ -306,7 +300,8 @@ let (iterators : Eff.local_env -> Eff.id_solver -> Eff.node_exp -> Eff.node_exp)
|
ExternEff
|
AbstractEff
->
n
|
BodyEff
b
->
init_var
()
;
Name
.
reset_local_var_prefix
"acc"
;
Name
.
reset_local_var_prefix
"cpt"
;
let
loc
=
match
n
.
loclist_eff
with
None
->
[]
|
Some
l
->
l
in
let
(
neqs
,
nv
)
=
List
.
fold_left
(
inline_eq
node_env
id_solver
)
([]
,
loc
)
b
.
eqs_eff
...
...
This diff is collapsed.
Click to expand it.
src/licDump.ml
+
4
−
9
View file @
32784a64
(** Time-stamp: <modified the 2
5
/11/2008 (at
17:31
) by Erwan Jahier> *)
(** Time-stamp: <modified the 2
6
/11/2008 (at
09:57
) by Erwan Jahier> *)
open
Printf
open
Lxm
...
...
@@ -165,20 +165,15 @@ and string_of_type_eff = function
we want to print (via string_of_type_eff) a type that is not a named type.
Then, at the end, we will dump that table in the lic file.
This table is filled by [array_alias].
In order to avoid name clashes, we prefix all user name type by [prefix] (cf
at the top of this file).
This table is filled by [array_alias].
*)
and
(
array_alias
:
Eff
.
type_
->
int
->
string
)
=
fun
t
size
->
let
array_t
=
Array_type_eff
(
t
,
size
)
in
try
Hashtbl
.
find
type_alias_table
array_t
try
Hashtbl
.
find
type_alias_table
array_t
with
Not_found
->
let
alias_t
=
string_of_type_eff
t
in
let
res
=
"A_"
^
alias_t
^
"_"
^
(
string_of_int
size
)
in
let
res
=
Name
.
array_type
array_t
(
alias_t
^
"_"
^
(
string_of_int
size
)
)
in
Hashtbl
.
add
type_alias_table
array_t
res
;
res
...
...
This diff is collapsed.
Click to expand it.
src/name.ml
+
29
−
2
View file @
32784a64
(** Time-stamp: <modified the 2
5
/11/2008 (at
17
:5
4
) by Erwan Jahier> *)
(** Time-stamp: <modified the 2
6
/11/2008 (at
09
:5
6
) by Erwan Jahier> *)
...
...
@@ -42,4 +42,31 @@ let (node_key: Eff.node_key -> string -> string) =
Hashtbl
.
add
node_key_tbl
nk
fresh_name
;
fresh_name
(********************************************************************************)
(* Dealing with fresh local (to the node) variable idents *)
let
local_var_tbl
=
Hashtbl
.
create
0
(* exported *)
let
(
reset_local_var_prefix
:
string
->
unit
)
=
fun
str
->
Hashtbl
.
remove
local_var_tbl
str
(* exported *)
let
(
new_local_var
:
string
->
string
)
=
fun
prefix
->
try
let
cpt
=
Hashtbl
.
find
local_var_tbl
prefix
in
Hashtbl
.
replace
local_var_tbl
prefix
(
cpt
+
1
);
"_"
^
prefix
^
(
string_of_int
cpt
)
with
Not_found
->
Hashtbl
.
add
local_var_tbl
prefix
2
;
"_"
^
prefix
^
"1"
(********************************************************************************)
let
(
array_type
:
Eff
.
type_
->
string
->
string
)
=
fun
t
name
->
"A_"
^
name
This diff is collapsed.
Click to expand it.
src/name.mli
+
13
−
1
View file @
32784a64
(** Time-stamp: <modified the 2
5
/11/2008 (at
17:48
) by Erwan Jahier> *)
(** Time-stamp: <modified the 2
6
/11/2008 (at
09:56
) by Erwan Jahier> *)
(** All new identifier names ougth to be created via this module.
...
...
@@ -18,3 +18,15 @@
(which means that [name] migth be ignored).
*)
val
node_key
:
Eff
.
node_key
->
string
->
string
(** Dealing with fresh local (to the node) variable idents *)
(** Returns a fresh local var name *)
val
new_local_var
:
string
->
string
(** since those are local to the node, name can be re-used *)
val
reset_local_var_prefix
:
string
->
unit
(** *)
val
array_type
:
Eff
.
type_
->
string
->
string
This diff is collapsed.
Click to expand it.
src/split.ml
+
4
−
8
View file @
32784a64
(** Time-stamp: <modified the 2
5
/11/2008 (at
14:47
) by Erwan Jahier> *)
(** Time-stamp: <modified the 2
6
/11/2008 (at
09:39
) by Erwan Jahier> *)
open
Lxm
...
...
@@ -6,10 +6,8 @@ open Eff
(********************************************************************************)
(* stuff to create fresh var names. *)
let
var_cpt
=
ref
0
let
new_var
node_env
type_eff
clock_eff
=
incr
var_cpt
;
let
id
=
Ident
.
of_string
(
"_v"
^
(
string_of_int
!
var_cpt
))
in
let
id
=
Ident
.
of_string
(
Name
.
new_local_var
"v"
)
in
let
var
=
{
var_name_eff
=
id
;
...
...
@@ -22,8 +20,6 @@ let new_var node_env type_eff clock_eff =
in
Hashtbl
.
add
node_env
.
lenv_vars
id
var
;
var
let
init_var
()
=
var_cpt
:=
0
(********************************************************************************)
...
...
@@ -257,12 +253,12 @@ let (node : Eff.local_env -> Eff.node_exp -> Eff.node_exp) =
|
ExternEff
|
AbstractEff
->
n
|
BodyEff
b
->
init_var
()
;
Name
.
reset_local_var_prefix
"v"
;
let
loc
=
match
n
.
loclist_eff
with
None
->
[]
|
Some
l
->
l
in
let
(
neqs
,
nv
)
=
List
.
fold_left
(
split_eq_acc
n_env
)
([]
,
loc
)
b
.
eqs_eff
in
let
asserts
=
List
.
map
(
fun
x
->
x
.
it
)
b
.
asserts_eff
in
let
lxm_asserts
=
List
.
map
(
fun
x
->
x
.
src
)
b
.
asserts_eff
in
let
nasserts
,
(
neqs_asserts
,
nv_asserts
)
=
let
nasserts
,
(
neqs_asserts
,
nv_asserts
)
=
split_val_exp_list
true
n_env
asserts
in
let
nasserts
=
List
.
map2
Lxm
.
flagit
nasserts
lxm_asserts
in
...
...
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