Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
verimag
synchrone
lutin
Commits
31ca0228
Commit
31ca0228
authored
Mar 02, 2015
by
Erwan Jahier
Browse files
Update the lus2lic plugin.
parent
e971e520
Changes
61
Hide whitespace changes
Inline
Side-by-side
source/Lurettetop/Makefile.comon
View file @
31ca0228
...
...
@@ -70,8 +70,8 @@ LUSTRE_SOURCES = \
$(OBJDIR)
/lv6MainArgs.mli
\
$(OBJDIR)
/filenameExtras.mli
\
$(OBJDIR)
/filenameExtras.ml
\
$(OBJDIR)
/
ident
.mli
\
$(OBJDIR)
/
ident
.ml
\
$(OBJDIR)
/
lv6Id
.mli
\
$(OBJDIR)
/
lv6Id
.ml
\
$(OBJDIR)
/lxm.mli
\
$(OBJDIR)
/lxm.ml
\
$(OBJDIR)
/lv6errors.ml
\
...
...
source/Lurettetop/ltopArg.ml
View file @
31ca0228
...
...
@@ -403,7 +403,7 @@ let (parse_rp_string : string -> unit) =
*)
|
"v6"
::
prog
::
node
::
opts
->
let
args
=
(
"lus2lic"
::
prog
::
"-node"
::
node
::
opts
)
in
let
args
=
(
"lus2lic"
::
prog
::
"-node"
::
node
::
"--expand-io-type"
::
opts
)
in
LustreV6
(
Array
.
of_list
args
)
|
[
"ec_exe"
;
prog
]
->
LustreEcExe
(
prog
)
|
[
"ec"
;
prog
]
->
LustreEc
(
prog
)
...
...
source/Lurettetop/lus2licRun.ml
deleted
100644 → 0
View file @
e971e520
(* Time-stamp: <modified the 16/06/2014 (at 16:05) by Erwan Jahier> *)
(*-----------------------------------------------------------------------
** Copyright (C) - Verimag.
*)
type
vars
=
(
string
*
Data
.
t
)
list
open
Lv6MainArgs
open
Soc
open
SocExecValue
open
RdbgPlugin
let
make
argv
=
let
opt
=
Lv6MainArgs
.
parse
argv
in
if
(
opt
.
infiles
=
[]
)
then
(
Lv6MainArgs
.
usage
stderr
opt
;
exit
1
);
let
new_dft_pack
=
Filename
.
basename
(
Filename
.
chop_extension
(
List
.
hd
opt
.
infiles
))
in
Ident
.
set_dft_pack_name
new_dft_pack
;
let
main_node
=
if
opt
.
main_node
=
""
then
None
else
Some
(
Ident
.
idref_of_string
opt
.
main_node
)
in
if
opt
.
outfile
<>
""
then
opt
.
oc
<-
open_out
opt
.
outfile
;
opt
.
precision
<-
Some
!
Util
.
precision
;
let
nsl
=
Compile
.
get_source_list
opt
opt
.
infiles
in
let
lic_prg
=
Compile
.
doit
opt
nsl
main_node
in
let
nk
=
(
Lic
.
node_key_of_idref
(
Ident
.
to_idref
opt
.
main_node
))
in
let
sk
,
soc_tbl
=
if
LicPrg
.
node_exists
lic_prg
nk
then
(
Lic2soc
.
f
lic_prg
nk
)
else
(
print_string
(
"Error: cannot find node "
^
opt
.
main_node
^
" in "
^
(
String
.
concat
","
opt
.
infiles
)
^
".
\n
"
);
flush
stdout
;
exit
1
)
in
let
soc
=
try
Soc
.
SocMap
.
find
sk
soc_tbl
with
Not_found
->
assert
false
in
let
soc_inputs
=
(
SocVar
.
expand_profile
true
false
(
fst
soc
.
profile
))
in
let
soc_outputs
=
(
SocVar
.
expand_profile
true
false
(
snd
soc
.
profile
))
in
let
(
vntl_i
:
Data
.
vntl
)
=
soc_inputs
in
let
(
vntl_o
:
Data
.
vntl
)
=
soc_outputs
in
(* Lv6util.dump_entete oc; *)
(* RifIO.write_interface oc vntl_i vntl_o None None; *)
(* RifIO.flush oc; *)
let
(
to_soc_subst
:
SocExecValue
.
ctx
->
Soc
.
var
list
->
Data
.
subst
list
)
=
fun
ctx
vl
->
(* let sl = List.map (fun var -> fst var, SocExecValue.get_value ctx (Var var)) vl in *)
let
sl
=
SocExecValue
.
filter_top_subst
ctx
.
s
in
let
sl
=
List
.
flatten
(
List
.
map
SocVar
.
expand_subst
sl
)
in
(* If the order ever matters, I could try the following. :
try List.map (fun v -> fst v,
List.assoc (fst v) sl) vl with Not_found -> assert false
*)
sl
in
let
(
add_subst
:
Data
.
subst
list
->
SocExecValue
.
substs
->
SocExecValue
.
substs
)
=
fun
s
ctx_s
->
let
s
=
SocVar
.
unexpand_profile
s
(
fst
soc
.
profile
)
in
List
.
fold_left
(
fun
acc
(
id
,
v
)
->
SocExecValue
.
sadd
acc
[
id
]
v
)
ctx_s
s
in
let
ctx_ref
=
ref
(
SocExecValue
.
create_ctx
soc_tbl
soc
)
in
let
step
sl_in
=
let
ctx
=
{
!
ctx_ref
with
s
=
add_subst
sl_in
!
ctx_ref
.
s
}
in
let
ctx
=
SocExec
.
do_step
soc_tbl
soc
ctx
in
let
sl_out
=
to_soc_subst
ctx
soc_outputs
in
ctx_ref
:=
ctx
;
(* RifIO.write_outputs oc Util.my_string_of_float vntl_o sl_out; *)
(* RifIO.flush oc; *)
sl_out
in
let
step_dbg
sl_in
ectx
cont
=
let
cont2
ctx
=
let
sl_out
=
to_soc_subst
ctx
soc_outputs
in
ctx_ref
:=
ctx
;
cont
sl_out
ectx
in
ctx_ref
:=
{
!
ctx_ref
with
s
=
add_subst
sl_in
!
ctx_ref
.
s
};
SocExec
.
do_step_dbg
soc_tbl
soc
ectx
!
ctx_ref
cont2
in
let
(
mems_in
:
Data
.
subst
list
)
=
[]
in
(* XXX todo *)
let
(
mems_out
:
Data
.
subst
list
)
=
[]
in
(* XXX todo *)
{
inputs
=
vntl_i
;
outputs
=
vntl_o
;
kill
=
(
fun
_
->
()
);
init_inputs
=
mems_in
;
init_outputs
=
mems_out
;
step
=
step
;
step_dbg
=
step_dbg
;
}
source/Lurettetop/lus2licRun.mli
deleted
100644 → 0
View file @
e971e520
(* Time-stamp: <modified the 26/03/2014 (at 17:56) by Erwan Jahier> *)
val
make
:
string
array
->
RdbgPlugin
.
t
source/lus2lic/ast2lic.ml
View file @
31ca0228
(* Time-stamp: <modified the 2
1
/0
1
/2015 (at 1
7:00
) by Erwan Jahier> *)
(* Time-stamp: <modified the 2
6
/0
2
/2015 (at 1
1:19
) by Erwan Jahier> *)
open
Lxm
...
...
@@ -8,7 +8,7 @@ open AstCore
open
Lic
open
IdSolver
open
Lv6errors
open
Ident
open
Lv6Id
(** debug flag: on prend le meme que LicTab ... *)
let
dbg
=
(
Verbose
.
get_flag
"lazyc"
)
...
...
@@ -35,17 +35,17 @@ let rec (of_type: IdSolver.t -> AstCore.type_exp -> Lic.type_) =
let
(
add_pack_name
:
IdSolver
.
t
->
Lxm
.
t
->
Ident
.
idref
->
Ident
.
idref
)
=
let
(
add_pack_name
:
IdSolver
.
t
->
Lxm
.
t
->
Lv6Id
.
idref
->
Lv6Id
.
idref
)
=
fun
id_solver
lxm
cc
->
try
match
Ident
.
pack_of_idref
cc
with
match
Lv6Id
.
pack_of_idref
cc
with
|
Some
_
->
cc
|
None
->
let
id
=
Ident
.
of_idref
cc
in
let
id
=
Lv6Id
.
of_idref
cc
in
let
pn
=
AstTabSymbol
.
find_pack_of_const
id_solver
.
global_symbols
id
lxm
in
Ident
.
make_idref
pn
id
Lv6Id
.
make_idref
pn
id
with
_
->
cc
(* raise en error? *)
...
...
@@ -116,9 +116,9 @@ TRAITER LES MACROS PREDEF :
(* pour abstraire la nature des params statiques *)
type
abstract_static_param
=
|
ASP_const
of
Ident
.
t
|
ASP_type
of
Ident
.
t
|
ASP_node
of
Ident
.
t
|
ASP_const
of
Lv6Id
.
t
|
ASP_type
of
Lv6Id
.
t
|
ASP_node
of
Lv6Id
.
t
let
do_abstract_static_param
x
=
match
x
.
it
with
...
...
@@ -130,12 +130,12 @@ match x.it with
let
get_abstract_static_params
(
symbols
:
AstTabSymbol
.
t
)
(
lxm
:
Lxm
.
t
)
(
idref
:
Ident
.
idref
)
(
idref
:
Lv6Id
.
idref
)
:
abstract_static_param
list
=
Verbose
.
exe
~
flag
:
dbg
(
fun
()
->
Printf
.
fprintf
stderr
"#DBG: Ast2lic.get_abstract_static %s
\n
"
(
Ident
.
raw_string_of_idref
idref
)
(
Lv6Id
.
raw_string_of_idref
idref
)
)
;
match
(
idref
.
id_pack
,
idref
.
id_id
)
with
|
(
Some
"Lustre"
,
"map"
)
...
...
@@ -146,7 +146,7 @@ let get_abstract_static_params
|
(
Some
"Lustre"
,
"condact"
)
->
[
ASP_node
"oper"
;
ASP_const
"dflt"
]
|
_
->
(
try
let
spl
=
match
AstTabSymbol
.
find_node
symbols
(
Ident
.
name_of_idref
idref
)
lxm
with
let
spl
=
match
AstTabSymbol
.
find_node
symbols
(
Lv6Id
.
name_of_idref
idref
)
lxm
with
|
AstTabSymbol
.
Local
ni
->
ni
.
it
.
static_params
|
AstTabSymbol
.
Imported
(
imported_node
,
params
)
->
params
in
List
.
map
do_abstract_static_param
spl
...
...
@@ -250,7 +250,7 @@ and check_static_arg
in
let
res
=
match
(
sa
.
it
,
asp
)
with
(* ident vs type *)
|
(
StaticArg
Ident
idref
,
ASP_type
id
)
->
|
(
StaticArg
Lv6Id
idref
,
ASP_type
id
)
->
let
teff
=
node_id_solver
.
id2type
idref
sa
.
src
in
TypeStaticArgLic
(
id
,
teff
)
(* type_exp vs type *)
...
...
@@ -258,7 +258,7 @@ and check_static_arg
let
teff
=
of_type
node_id_solver
te
in
TypeStaticArgLic
(
id
,
teff
)
(* ident vs const *)
|
(
StaticArg
Ident
idref
,
ASP_const
id
)
->
|
(
StaticArg
Lv6Id
idref
,
ASP_const
id
)
->
let
ceff
=
node_id_solver
.
id2const
idref
sa
.
src
in
ConstStaticArgLic
(
id
,
ceff
)
(* val_exp vs const *)
...
...
@@ -269,7 +269,7 @@ and check_static_arg
|
_
->
ConstStaticArgLic
(
id
,
Tuple_const_eff
ceff
)
)
(* id vs node *)
|
(
StaticArg
Ident
idref
,
ASP_node
id
)
->
|
(
StaticArg
Lv6Id
idref
,
ASP_node
id
)
->
let
sargs
=
[]
in
let
neff
=
node_id_solver
.
id2node
idref
sargs
sa
.
src
in
NodeStaticArgLic
(
id
,
neff
.
node_key_eff
)
...
...
@@ -533,12 +533,12 @@ and (translate_val_exp : IdSolver.t -> UnifyClock.subst -> AstCore.val_exp
and
translate_by_name_op
id_solver
op
s
=
let
to_long
idref
=
match
Ident
.
pack_of_idref
idref
with
match
Lv6Id
.
pack_of_idref
idref
with
|
None
->
(* If no pack name is provided, we lookup it in the symbol table *)
let
id
=
Ident
.
of_idref
idref
in
let
id
=
Lv6Id
.
of_idref
idref
in
let
pn
=
AstTabSymbol
.
find_pack_of_type
id_solver
.
global_symbols
id
op
.
src
in
Ident
.
make_long
pn
idref
.
id_id
|
Some
pn
->
Ident
.
make_long
pn
idref
.
id_id
Lv6Id
.
make_long
pn
idref
.
id_id
|
Some
pn
->
Lv6Id
.
make_long
pn
idref
.
id_id
in
let
s
,
nop
=
match
op
.
it
with
...
...
@@ -570,7 +570,7 @@ and const_of_static_arg id_solver const_or_const_ident lxm =
(* EvalConst.f ne fabrique PAS de tuple, on le fait ici *)
Tuple_const_eff
xl
)
|
StaticArg
Ident
(
id
)
->
id_solver
.
id2const
id
lxm
|
StaticArg
Lv6Id
(
id
)
->
id_solver
.
id2const
id
lxm
|
StaticArgType
_
|
StaticArgNode
_
->
raise
(
Compile_error
(
lxm
,
"a constant was expected"
))
...
...
@@ -578,7 +578,7 @@ and const_of_static_arg id_solver const_or_const_ident lxm =
and
node_of_static_arg
id_solver
node_or_node_ident
lxm
=
match
node_or_node_ident
with
|
StaticArg
Ident
(
id
)
->
|
StaticArg
Lv6Id
(
id
)
->
let
sargs
=
[]
in
(* it is an alias: no static arg *)
id_solver
.
id2node
id
sargs
lxm
...
...
source/lus2lic/astCore.ml
View file @
31ca0228
(* Time-stamp: <modified the 2
1
/0
1
/2015 (at 1
6:5
9) by Erwan Jahier> *)
(* Time-stamp: <modified the 2
6
/0
2
/2015 (at 1
1:1
9) by Erwan Jahier> *)
(** (Raw) Abstract syntax tree of source Lustre Core programs. *)
...
...
@@ -9,7 +9,7 @@ open Lxm
(**********************************************************************************)
type
clock_exp
=
|
Base
|
NamedClock
of
Ident
.
clk
srcflagged
|
NamedClock
of
Lv6Id
.
clk
srcflagged
(**********************************************************************************)
(** [type_exp] is used to type flow, parameters, constants. *)
...
...
@@ -19,12 +19,12 @@ and
|
Bool_type_exp
|
Int_type_exp
|
Real_type_exp
|
Named_type_exp
of
Ident
.
idref
|
Named_type_exp
of
Lv6Id
.
idref
|
Array_type_exp
of
(
type_exp
*
val_exp
)
and
node_info
=
{
name
:
Ident
.
t
;
name
:
Lv6Id
.
t
;
static_params
:
static_param
srcflagged
list
;
vars
:
node_vars
option
;
(* aliased node may have no i/o decl *)
(* consts : ICI A FAIRE *)
...
...
@@ -35,21 +35,21 @@ and node_info = {
}
and
static_param
=
|
StaticParamType
of
Ident
.
t
|
StaticParamConst
of
Ident
.
t
*
type_exp
|
StaticParamType
of
Lv6Id
.
t
|
StaticParamConst
of
Lv6Id
.
t
*
type_exp
|
StaticParamNode
of
(
Ident
.
t
*
var_info
srcflagged
list
*
var_info
srcflagged
list
*
has_mem_flag
*
is_safe_flag
)
(
Lv6Id
.
t
*
var_info
srcflagged
list
*
var_info
srcflagged
list
*
has_mem_flag
*
is_safe_flag
)
and
node_vars
=
{
inlist
:
Ident
.
t
list
;
outlist
:
Ident
.
t
list
;
loclist
:
Ident
.
t
list
option
;
(* abstract/ext node have no body *)
inlist
:
Lv6Id
.
t
list
;
outlist
:
Lv6Id
.
t
list
;
loclist
:
Lv6Id
.
t
list
option
;
(* abstract/ext node have no body *)
vartable
:
var_info_table
;
}
and
var_info_table
=
(
Ident
.
t
,
var_info
srcflagged
)
Hashtbl
.
t
and
var_info_table
=
(
Lv6Id
.
t
,
var_info
srcflagged
)
Hashtbl
.
t
and
var_info
=
{
var_nature
:
var_nature
;
var_name
:
Ident
.
t
;
var_name
:
Lv6Id
.
t
;
var_number
:
int
;
var_type
:
type_exp
;
var_clock
:
clock_exp
...
...
@@ -76,8 +76,8 @@ and is_safe_flag = bool
and
eq_info
=
(
left_part
list
*
val_exp
)
and
left_part
=
|
LeftVar
of
(
Ident
.
t
srcflagged
)
|
LeftField
of
(
left_part
*
(
Ident
.
t
srcflagged
))
|
LeftVar
of
(
Lv6Id
.
t
srcflagged
)
|
LeftField
of
(
left_part
*
(
Lv6Id
.
t
srcflagged
))
|
LeftArray
of
(
left_part
*
(
val_exp
srcflagged
))
|
LeftSlice
of
(
left_part
*
(
slice_info
srcflagged
))
...
...
@@ -91,7 +91,7 @@ and by_pos_op =
(* zeroaire *)
|
Predef_n
of
AstPredef
.
op
srcflagged
|
CALL_n
of
node_exp
srcflagged
(* e.g., a_node<<xx>> *)
|
IDENT_n
of
Ident
.
idref
(* constant or variable *)
|
IDENT_n
of
Lv6Id
.
idref
(* constant or variable *)
|
PRE_n
|
ARROW_n
...
...
@@ -105,7 +105,7 @@ and by_pos_op =
|
CONCAT_n
|
HAT_n
|
ARRAY_n
|
STRUCT_ACCESS_n
of
Ident
.
t
|
STRUCT_ACCESS_n
of
Lv6Id
.
t
|
ARRAY_ACCES_n
of
val_exp
|
ARRAY_SLICE_n
of
slice_info
...
...
@@ -118,27 +118,27 @@ and by_pos_op =
(* - avec passage par position, auquel cas les *)
(* oprandes sont des val_exp *)
(* - avec passage par nom, auquel cas les *)
(* opérandes sont des
Ident
.t * val_exp *)
(* oprandes sont des L
v6Id.
t * val_exp *)
(************************************************)
(* and val_exp = by_pos_op srcflagged * operands *)
and
val_exp
=
|
CallByPos
of
(
by_pos_op
srcflagged
*
operands
)
|
CallByName
of
(
by_name_op
srcflagged
*
(
Ident
.
t
srcflagged
*
val_exp
)
list
)
|
Merge_n
of
val_exp
srcflagged
*
(
Ident
.
idref
srcflagged
*
val_exp
)
list
|
CallByName
of
(
by_name_op
srcflagged
*
(
Lv6Id
.
t
srcflagged
*
val_exp
)
list
)
|
Merge_n
of
val_exp
srcflagged
*
(
Lv6Id
.
idref
srcflagged
*
val_exp
)
list
|
Merge_bool_n
of
val_exp
srcflagged
*
val_exp
*
val_exp
and
operands
=
Oper
of
val_exp
list
(* Virer cet Oper ? Non, sinon ca boucle... *)
and
by_name_op
=
|
STRUCT_n
of
Ident
.
idref
|
STRUCT_WITH_n
of
Ident
.
idref
*
Ident
.
idref
|
STRUCT_n
of
Lv6Id
.
idref
|
STRUCT_WITH_n
of
Lv6Id
.
idref
*
Lv6Id
.
idref
|
STRUCT_anonymous_n
(* for backward compatibility with lv4 *)
and
node_exp
=
(
Ident
.
idref
*
(
static_arg
srcflagged
list
))
(
Lv6Id
.
idref
*
(
static_arg
srcflagged
list
))
(** Params statiques effectifs :
- val_exp (pour les constantes)
...
...
@@ -147,7 +147,7 @@ and node_exp =
- ident : a rsoudre, peut etre const, type ou node
*)
and
static_arg
=
|
StaticArg
Ident
of
Ident
.
idref
|
StaticArg
Lv6Id
of
Lv6Id
.
idref
|
StaticArgConst
of
val_exp
|
StaticArgType
of
type_exp
...
...
@@ -160,35 +160,35 @@ and static_arg =
(** constant *)
and
const_info
=
|
ExternalConst
of
(
Ident
.
t
*
type_exp
*
val_exp
option
)
|
EnumConst
of
(
Ident
.
t
*
type_exp
)
|
DefinedConst
of
(
Ident
.
t
*
type_exp
option
*
val_exp
)
|
ExternalConst
of
(
Lv6Id
.
t
*
type_exp
*
val_exp
option
)
|
EnumConst
of
(
Lv6Id
.
t
*
type_exp
)
|
DefinedConst
of
(
Lv6Id
.
t
*
type_exp
option
*
val_exp
)
(** Type *)
type
field_info
=
{
fd_name
:
Ident
.
t
;
fd_name
:
Lv6Id
.
t
;
fd_type
:
type_exp
;
fd_value
:
val_exp
option
}
type
struct_type_info
=
{
st_name
:
Ident
.
t
;
st_flist
:
Ident
.
t
list
;
(* field name list *)
st_ftable
:
(
Ident
.
t
,
field_info
srcflagged
)
Hashtbl
.
t
st_name
:
Lv6Id
.
t
;
st_flist
:
Lv6Id
.
t
list
;
(* field name list *)
st_ftable
:
(
Lv6Id
.
t
,
field_info
srcflagged
)
Hashtbl
.
t
}
type
type_info
=
|
ExternalType
of
(
Ident
.
t
)
|
AliasedType
of
(
Ident
.
t
*
type_exp
)
|
EnumType
of
(
Ident
.
t
*
Ident
.
t
srcflagged
list
)
|
ExternalType
of
(
Lv6Id
.
t
)
|
AliasedType
of
(
Lv6Id
.
t
*
type_exp
)
|
EnumType
of
(
Lv6Id
.
t
*
Lv6Id
.
t
srcflagged
list
)
|
StructType
of
struct_type_info
|
ArrayType
of
(
Ident
.
t
*
type_exp
*
val_exp
)
|
ArrayType
of
(
Lv6Id
.
t
*
type_exp
*
val_exp
)
(** Operator *)
type
item_ident
=
|
ConstItem
of
Ident
.
t
|
TypeItem
of
Ident
.
t
|
NodeItem
of
Ident
.
t
*
static_param
srcflagged
list
|
ConstItem
of
Lv6Id
.
t
|
TypeItem
of
Lv6Id
.
t
|
NodeItem
of
Lv6Id
.
t
*
static_param
srcflagged
list
type
item_info
=
ConstInfo
of
const_info
...
...
@@ -201,7 +201,7 @@ let rec string_of_type_exp x =
|
Bool_type_exp
->
"bool"
|
Int_type_exp
->
"int"
|
Real_type_exp
->
"real"
|
Named_type_exp
id
->
(
Ident
.
string_of_idref
id
)
|
Named_type_exp
id
->
(
Lv6Id
.
string_of_idref
id
)
|
Array_type_exp
(
te
,
sz
)
->
(
string_of_type_exp
te
)
^
"^ ..."
...
...
source/lus2lic/astInstanciateModel.ml
View file @
31ca0228
(* Time-stamp: <modified the 2
1
/0
1
/2015 (at 1
6:47
) by Erwan Jahier> *)
(* Time-stamp: <modified the 2
6
/0
2
/2015 (at 1
1:19
) by Erwan Jahier> *)
open
Lxm
open
AstV6
...
...
@@ -23,9 +23,9 @@ let instance_error lxm =
*)
type
check_arg_acc
=
item_ident
list
*
item_info
srcflagged
list
type
tables
=
(
Ident
.
t
,
const_info
Lxm
.
srcflagged
)
Hashtbl
.
t
*
(
Ident
.
t
,
type_info
Lxm
.
srcflagged
)
Hashtbl
.
t
*
(
Ident
.
t
,
node_info
Lxm
.
srcflagged
)
Hashtbl
.
t
(
Lv6Id
.
t
,
const_info
Lxm
.
srcflagged
)
Hashtbl
.
t
*
(
Lv6Id
.
t
,
type_info
Lxm
.
srcflagged
)
Hashtbl
.
t
*
(
Lv6Id
.
t
,
node_info
Lxm
.
srcflagged
)
Hashtbl
.
t
(** Insert an item in the lexeme table. Raise [Compile_error] if already defined. *)
...
...
@@ -46,7 +46,7 @@ let put_in_tab
let
(
check_arg
:
tables
->
(
Ident
.
t
*
static_arg
srcflagged
)
list
->
check_arg_acc
->
tables
->
(
Lv6Id
.
t
*
static_arg
srcflagged
)
list
->
check_arg_acc
->
static_param
srcflagged
->
check_arg_acc
)
=
fun
(
ctab
,
ttab
,
ntab
)
args
(
defs
,
prov
)
param
->
let
find_arg
id
=
...
...
@@ -56,7 +56,7 @@ let (check_arg :
|
StaticParamType
s
->
(
let
arg
=
find_arg
s
in
let
te
=
match
arg
.
it
with
|
StaticArg
Ident
idr
->
Lxm
.
flagit
(
Named_type_exp
idr
)
arg
.
src
|
StaticArg
Lv6Id
idr
->
Lxm
.
flagit
(
Named_type_exp
idr
)
arg
.
src
|
StaticArgType
x
->
x
|
_
->
instance_error
param
.
src
in
...
...
@@ -69,7 +69,7 @@ let (check_arg :
|
StaticParamConst
(
s
,
te
)
->
(
let
arg
=
find_arg
s
in
let
ce
=
match
(
arg
.
it
)
with
|
StaticArg
Ident
idr
->
Lv6parserUtils
.
leafexp
arg
.
src
(
IDENT_n
idr
)
|
StaticArg
Lv6Id
idr
->
Lv6parserUtils
.
leafexp
arg
.
src
(
IDENT_n
idr
)
|
StaticArgConst
x
->
x
|
_
->
instance_error
param
.
src
in
...
...
@@ -82,7 +82,7 @@ let (check_arg :
|
StaticParamNode
(
s
,
inl
,
outl
,
has_memory
,
is_safe
)
->
(
let
arg
=
find_arg
s
in
let
by_pos_op
=
match
(
arg
.
it
)
with
|
StaticArg
Ident
idr
->
CALL_n
(
Lxm
.
flagit
((
idr
,
[]
))
arg
.
src
)
|
StaticArg
Lv6Id
idr
->
CALL_n
(
Lxm
.
flagit
((
idr
,
[]
))
arg
.
src
)
|
StaticArgNode
by_pos_op
->
by_pos_op
|
_
->
instance_error
param
.
src
in
...
...
@@ -103,7 +103,7 @@ let (check_arg :
((
NodeItem
(
s
,
sparams
))
::
defs
,
x
::
prov
)
)
let
(
f
:
(
Ident
.
t
,
AstV6
.
model_info
Lxm
.
srcflagged
)
Hashtbl
.
t
->
let
(
f
:
(
Lv6Id
.
t
,
AstV6
.
model_info
Lxm
.
srcflagged
)
Hashtbl
.
t
->
(
AstV6
.
pack_info
Lxm
.
srcflagged
)
->
AstV6
.
pack_given
)
=
fun
mtab
pdata
->
match
(
pdata
.
it
.
pa_def
)
with
...
...
@@ -111,7 +111,7 @@ let (f: (Ident.t, AstV6.model_info Lxm.srcflagged) Hashtbl.t ->
|
PackInstance
pi
->
let
mi
=
try
Hashtbl
.
find
mtab
pi
.
pi_model
with
Not_found
->
let
msg
=
Printf
.
sprintf
"bad pack instance: model %s undeclared"
(
Ident
.
to_string
pi
.
pi_model
)
(
Lv6Id
.
to_string
pi
.
pi_model
)
in
raise
(
Compile_error
(
pdata
.
src
,
msg
))
in
...
...
@@ -121,14 +121,14 @@ let (f: (Ident.t, AstV6.model_info Lxm.srcflagged) Hashtbl.t ->
let
ntab
=
Hashtbl
.
copy
mi
.
it
.
mo_body
.
pk_node_table
in
let
args
=
pi
.
pi_args
in
let
pars
=
mi
.
it
.
mo_needs
in
let
(
used_packages
:
Ident
.
pack_name
srcflagged
list
)
=
let
(
used_packages
:
Lv6Id
.
pack_name
srcflagged
list
)
=
(* We add to the list of used packages the packages that are explicitely
used in the model arguments *)
List
.
fold_left
(
fun
acc
(
_
,
arg
)
->
(
match
arg
.
it
with
|
StaticArg
Ident
(
idref
)
->
(
match
Ident
.
pack_of_idref
idref
with
|
StaticArg
Lv6Id
(
idref
)
->
(
match
Lv6Id
.
pack_of_idref
idref
with
|
None
->
acc
|
Some
p
->
let
p_flagged
=
Lxm
.
flagit
p
arg
.
src
in
...
...
@@ -150,7 +150,7 @@ let (f: (Ident.t, AstV6.model_info Lxm.srcflagged) Hashtbl.t ->
if
(
pars_nb
<>
args_nb
)
then
let
msg
=
"
\n
*** "
^
pars_nb
^
" arguments are expected, but "
^
args_nb
^
" were provided when defining package "
^
(
Ident
.
pack_name_to_string
pdata
.
it
.
pa_name
)
(
Lv6Id
.
pack_name_to_string
pdata
.
it
.
pa_name
)
in
raise
(
Compile_error
(
pdata
.
src
,
msg
))
else
...
...
@@ -177,7 +177,7 @@ let (f: (Ident.t, AstV6.model_info Lxm.srcflagged) Hashtbl.t ->
with
Invalid_argument
_
->
let
msg
=
Printf
.
sprintf
"bad pack instance: %d args provided while model %s has %d params"
(
List
.
length
args
)
(
Ident
.
to_string
pi
.
pi_model
)
(
List
.
length
pars
)
(
List
.
length
args
)
(
Lv6Id
.
to_string
pi
.
pi_model
)
(
List
.
length
pars
)
in
raise
(
Compile_error
(
pdata
.
src
,
msg
))
source/lus2lic/astInstanciateModel.mli
View file @
31ca0228
(* Time-stamp: <modified the
13/1
2/201
2
(at 1
1:3
4) by Erwan Jahier> *)
(* Time-stamp: <modified the
26/0
2/201
5
(at 1
3:4
4) by Erwan Jahier> *)
(** Create packages from Model instances. *)
...
...
@@ -43,7 +43,7 @@ On met en relation les couples (param formel, arg effectif) :
(* ZZZ remplit AstTab.t par effet de bords. *)
val
f
:
(* la table des sources de modeles *)
(
Ident
.
t
,
AstV6
.
model_info
Lxm
.
srcflagged
)
Hashtbl
.
t
->
(
Lv6Id
.
t
,
AstV6
.
model_info
Lxm
.
srcflagged
)
Hashtbl
.
t
->
(* la def de pack à traiter *)
(
AstV6
.
pack_info
Lxm
.
srcflagged
)
->
AstV6
.
pack_given
...
...
source/lus2lic/astPredef.ml
View file @
31ca0228
(* Time-stamp: <modified the 26/0
6
/201
4
(at 1
8
:2
9
) by Erwan Jahier> *)
(* Time-stamp: <modified the 26/0
2
/201
5
(at 1
1
:2
5
) by Erwan Jahier> *)
(** Predefined operators Type definition *)
(* XXX shoud not type int, real, and bool be handled there ? *)
type
op
=
(* zero-ary *)
|
TRUE_n
|
FALSE_n
|
RCONST_n
of
Ident
.
t
(* we don't want to touch reals! *)
|
ICONST_n
of
Ident
.
t
(* so we don't touch int either...*)
|
RCONST_n
of
Lv6Id
.
t
(* we don't want to touch reals! *)
|
ICONST_n
of
Lv6Id
.
t
(* so we don't touch int either...*)
(* unary *)
|
NOT_n
|
REAL2INT_n
...
...
@@ -83,8 +85,8 @@ let iterable_op = [
let
op2string
=
function
|
TRUE_n
->
"true"
|
FALSE_n
->
"false"
|
ICONST_n
id
->
Ident
.
to_string
id
|
RCONST_n
id
->
Ident
.
to_string
id
|
ICONST_n
id
->
Lv6Id
.
to_string
id
|
RCONST_n
id
->
Lv6Id
.
to_string
id
|
NOT_n
->
"not"
|
REAL2INT_n
->
"real2int"
|
INT2REAL_n
->
"int2real"
...
...
@@ -254,17 +256,17 @@ let (is_a_predef_op : string -> bool) =
type
'
a
evaluator
=
'
a
list
list
->
'
a
list
let
(
op_to_long
:
op
->
Ident
.
long
)
=
let
(
op_to_long
:
op
->
Lv6Id
.
long
)
=
fun
op
->
Ident
.
make_long
(
Ident
.
pack_name_of_string
"Lustre"
)
(
Ident
.
of_string
(
op2string_long
op
))