Forme normale Minils
This commit is contained in:
parent
0fc0c3ba5b
commit
2c7b609d2e
|
@ -39,28 +39,38 @@ and tdesc =
|
||||||
| Type_enum of constructor_name list
|
| Type_enum of constructor_name list
|
||||||
| Type_struct of structure
|
| Type_struct of structure
|
||||||
|
|
||||||
|
and extvalue = {
|
||||||
|
w_desc : edesc;
|
||||||
|
mutable w_ck: ck;
|
||||||
|
w_ty : ty;
|
||||||
|
w_loc : location }
|
||||||
|
|
||||||
|
and extvalue_desc =
|
||||||
|
| Wconst of static_exp
|
||||||
|
| Wvar of var_ident
|
||||||
|
| Wfield of ext_value * field_name
|
||||||
|
| Wwhen of extvalue * constructor_name * var_ident
|
||||||
|
(** extvalue when Constructor(ident) *)
|
||||||
|
|
||||||
and exp = {
|
and exp = {
|
||||||
e_desc : edesc;
|
e_desc : edesc;
|
||||||
e_base_ck : ck;
|
|
||||||
mutable e_ck: ck;
|
mutable e_ck: ck;
|
||||||
mutable e_ty: ty;
|
e_ty : ty;
|
||||||
e_loc : location }
|
e_loc : location }
|
||||||
|
|
||||||
and edesc =
|
and edesc =
|
||||||
| Econst of static_exp
|
| Eextvalue of extvalue
|
||||||
| Evar of var_ident
|
| Efby of static_exp option * extvalue
|
||||||
| Efby of static_exp option * exp
|
(** static_exp fby extvalue *)
|
||||||
(** static_exp fby exp *)
|
| Eapp of app * extvalue list * var_ident option
|
||||||
| Eapp of app * exp list * var_ident option
|
(** app ~args=(extvalue,extvalue...) reset ~r=ident *)
|
||||||
(** app ~args=(exp,exp...) reset ~r=ident *)
|
| Emerge of var_ident * (constructor_name * extvalue) list
|
||||||
| Ewhen of exp * constructor_name * var_ident
|
(** merge ident (Constructor -> extvalue)+ *)
|
||||||
(** exp when Constructor(ident) *)
|
| Estruct of (field_name * extvalue) list
|
||||||
| Emerge of var_ident * (constructor_name * exp) list
|
(** { field=extvalue; ... } *)
|
||||||
(** merge ident (Constructor -> exp)+ *)
|
| Eiterator of iterator_type * app * static_exp
|
||||||
| Estruct of (field_name * exp) list
|
* extvalue list * extvalue list * var_ident option
|
||||||
(** { field=exp; ... } *)
|
(** map f <<n>> (extvalue, extvalue...) reset ident *)
|
||||||
| Eiterator of iterator_type * app * static_exp * exp list * exp list * var_ident option
|
|
||||||
(** map f <<n>> (exp, exp...) reset ident *)
|
|
||||||
|
|
||||||
and app = { a_op: op; a_params: static_exp list; a_unsafe: bool }
|
and app = { a_op: op; a_params: static_exp list; a_unsafe: bool }
|
||||||
(** Unsafe applications could have side effects
|
(** Unsafe applications could have side effects
|
||||||
|
@ -136,10 +146,13 @@ type program = {
|
||||||
|
|
||||||
(*Helper functions to build the AST*)
|
(*Helper functions to build the AST*)
|
||||||
|
|
||||||
let mk_exp ~ty ?(clock = fresh_clock())
|
let mk_extvalue ~ty ?(clock = fresh_clock()) ?(loc = no_location) desc =
|
||||||
?(loc = no_location) ?(base_clock = Cbase) desc =
|
{ w_desc = desc; w_ty = ty;
|
||||||
|
w_ck = clock; w_loc = loc }
|
||||||
|
|
||||||
|
let mk_exp ~ty ?(clock = fresh_clock()) ?(loc = no_location) desc =
|
||||||
{ e_desc = desc; e_ty = ty;
|
{ e_desc = desc; e_ty = ty;
|
||||||
e_base_ck = base_clock; e_ck = clock; e_loc = loc }
|
e_ck = clock; e_loc = loc }
|
||||||
|
|
||||||
let mk_var_dec ?(loc = no_location) ?(clock = fresh_clock()) ident ty =
|
let mk_var_dec ?(loc = no_location) ?(clock = fresh_clock()) ident ty =
|
||||||
{ v_ident = ident; v_type = ty; v_clock = clock; v_loc = loc }
|
{ v_ident = ident; v_type = ty; v_clock = clock; v_loc = loc }
|
||||||
|
|
|
@ -8,19 +8,7 @@
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
(* Object code internal representation *)
|
(* Object code internal representation *)
|
||||||
|
|
||||||
(** { 3 Semantics }
|
(** See the manual for the semantics of the language *)
|
||||||
Any variable is a reference to a constant memory.
|
|
||||||
Thus [p = e] is not the change of the reference,
|
|
||||||
but a recursive copy of what is referenced (deep copy).
|
|
||||||
As an example, [x = 3] but also [x = \[3; 4; 5\]]
|
|
||||||
and [t1 = t2] with the content of the array [t2] copied into the array [t1].
|
|
||||||
Obc is also "SSA" in the sens that a variable is assigned a value only once per call of [step] etc.
|
|
||||||
Thus arguments are passed as constant references to a constant memory.
|
|
||||||
|
|
||||||
One exception to the SSA rule is through the [mutable] variables.
|
|
||||||
Theses variables can be assigned multiple times.
|
|
||||||
Thus a [mutable] argument is passed as a reference to a constant memory.
|
|
||||||
*)
|
|
||||||
|
|
||||||
|
|
||||||
open Misc
|
open Misc
|
||||||
|
@ -91,13 +79,15 @@ and block =
|
||||||
and var_dec =
|
and var_dec =
|
||||||
{ v_ident : var_ident;
|
{ v_ident : var_ident;
|
||||||
v_type : ty;
|
v_type : ty;
|
||||||
|
v_mutable : bool;
|
||||||
v_loc : location }
|
v_loc : location }
|
||||||
|
|
||||||
type obj_dec =
|
type obj_dec =
|
||||||
{ o_ident : obj_ident;
|
{ o_ident : obj_ident;
|
||||||
o_class : class_name;
|
o_class : class_name;
|
||||||
o_params : static_exp list;
|
o_params : static_exp list;
|
||||||
o_size : static_exp option; (** size of the array if the declaration is an array of obj *)
|
(** size of the array if the declaration is an array of obj *)
|
||||||
|
o_size : static_exp option;
|
||||||
o_loc : location }
|
o_loc : location }
|
||||||
|
|
||||||
type method_def =
|
type method_def =
|
||||||
|
@ -108,8 +98,9 @@ type method_def =
|
||||||
|
|
||||||
type class_def =
|
type class_def =
|
||||||
{ cd_name : class_name;
|
{ cd_name : class_name;
|
||||||
cd_stateful : bool; (** when false, the class is a function with static parameters
|
(** when false, the class is a function with static parameters
|
||||||
calling other functions with parameters *)
|
calling other functions with parameters *)
|
||||||
|
cd_stateful : bool;
|
||||||
cd_mems : var_dec list;
|
cd_mems : var_dec list;
|
||||||
cd_objs : obj_dec list;
|
cd_objs : obj_dec list;
|
||||||
cd_params : param list;
|
cd_params : param list;
|
||||||
|
|
|
@ -16,8 +16,8 @@ open Obc
|
||||||
open Obc_mapfold
|
open Obc_mapfold
|
||||||
open Global_mapfold
|
open Global_mapfold
|
||||||
|
|
||||||
let mk_var_dec ?(loc=no_location) ident ty =
|
let mk_var_dec ?(loc=no_location) ?(mut=false) ident ty =
|
||||||
{ v_ident = ident; v_type = ty; v_loc = loc }
|
{ v_ident = ident; v_type = ty; v_mutable = mut; v_loc = loc }
|
||||||
|
|
||||||
let mk_exp ?(loc=no_location) ty desc =
|
let mk_exp ?(loc=no_location) ty desc =
|
||||||
{ e_desc = desc; e_ty = ty; e_loc = loc }
|
{ e_desc = desc; e_ty = ty; e_loc = loc }
|
||||||
|
|
Loading…
Reference in a new issue