From 2c7b609d2ec61984a0982a675f33caab798c2832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Tue, 12 Apr 2011 14:07:05 +0200 Subject: [PATCH] Forme normale Minils --- compiler/minils/minils.ml | 51 ++++++++++++++++++++++++--------------- compiler/obc/obc.ml | 23 ++++++------------ compiler/obc/obc_utils.ml | 4 +-- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/compiler/minils/minils.ml b/compiler/minils/minils.ml index d18b5f1..5a64408 100644 --- a/compiler/minils/minils.ml +++ b/compiler/minils/minils.ml @@ -39,28 +39,38 @@ and tdesc = | Type_enum of constructor_name list | 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 = { e_desc : edesc; - e_base_ck : ck; mutable e_ck: ck; - mutable e_ty: ty; + e_ty : ty; e_loc : location } and edesc = - | Econst of static_exp - | Evar of var_ident - | Efby of static_exp option * exp - (** static_exp fby exp *) - | Eapp of app * exp list * var_ident option - (** app ~args=(exp,exp...) reset ~r=ident *) - | Ewhen of exp * constructor_name * var_ident - (** exp when Constructor(ident) *) - | Emerge of var_ident * (constructor_name * exp) list - (** merge ident (Constructor -> exp)+ *) - | Estruct of (field_name * exp) list - (** { field=exp; ... } *) - | Eiterator of iterator_type * app * static_exp * exp list * exp list * var_ident option - (** map f <> (exp, exp...) reset ident *) + | Eextvalue of extvalue + | Efby of static_exp option * extvalue + (** static_exp fby extvalue *) + | Eapp of app * extvalue list * var_ident option + (** app ~args=(extvalue,extvalue...) reset ~r=ident *) + | Emerge of var_ident * (constructor_name * extvalue) list + (** merge ident (Constructor -> extvalue)+ *) + | Estruct of (field_name * extvalue) list + (** { field=extvalue; ... } *) + | Eiterator of iterator_type * app * static_exp + * extvalue list * extvalue list * var_ident option + (** map f <> (extvalue, extvalue...) reset ident *) and app = { a_op: op; a_params: static_exp list; a_unsafe: bool } (** Unsafe applications could have side effects @@ -136,10 +146,13 @@ type program = { (*Helper functions to build the AST*) -let mk_exp ~ty ?(clock = fresh_clock()) - ?(loc = no_location) ?(base_clock = Cbase) desc = +let mk_extvalue ~ty ?(clock = fresh_clock()) ?(loc = no_location) 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_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 = { v_ident = ident; v_type = ty; v_clock = clock; v_loc = loc } diff --git a/compiler/obc/obc.ml b/compiler/obc/obc.ml index ea9adca..da9027f 100644 --- a/compiler/obc/obc.ml +++ b/compiler/obc/obc.ml @@ -8,19 +8,7 @@ (**************************************************************************) (* Object code internal representation *) -(** { 3 Semantics } - 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. -*) +(** See the manual for the semantics of the language *) open Misc @@ -91,13 +79,15 @@ and block = and var_dec = { v_ident : var_ident; v_type : ty; + v_mutable : bool; v_loc : location } type obj_dec = { o_ident : obj_ident; o_class : class_name; 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 } type method_def = @@ -108,8 +98,9 @@ type method_def = type class_def = { cd_name : class_name; - cd_stateful : bool; (** when false, the class is a function with static parameters - calling other functions with parameters *) + (** when false, the class is a function with static parameters + calling other functions with parameters *) + cd_stateful : bool; cd_mems : var_dec list; cd_objs : obj_dec list; cd_params : param list; diff --git a/compiler/obc/obc_utils.ml b/compiler/obc/obc_utils.ml index b701605..47bba7c 100644 --- a/compiler/obc/obc_utils.ml +++ b/compiler/obc/obc_utils.ml @@ -16,8 +16,8 @@ open Obc open Obc_mapfold open Global_mapfold -let mk_var_dec ?(loc=no_location) ident ty = - { v_ident = ident; v_type = ty; v_loc = loc } +let mk_var_dec ?(loc=no_location) ?(mut=false) ident ty = + { v_ident = ident; v_type = ty; v_mutable = mut; v_loc = loc } let mk_exp ?(loc=no_location) ty desc = { e_desc = desc; e_ty = ty; e_loc = loc }