Rename [lhs] to [pattern] in obc
lhs was verrrry bad.
This commit is contained in:
parent
a273170a31
commit
3e2fb0b4b1
5 changed files with 22 additions and 22 deletions
|
@ -327,7 +327,7 @@ and mk_node_call map call_context app loc name_list args =
|
|||
Env.add vd.Minils.v_ident a env in
|
||||
let subst_act_list env act_list =
|
||||
let exp funs env e = match e.e_desc with
|
||||
| Elhs { l_desc = Lvar x } ->
|
||||
| Elhs { pat_desc = Lvar x } ->
|
||||
let e =
|
||||
(try Env.find x env
|
||||
with Not_found -> e) in
|
||||
|
|
|
@ -303,7 +303,7 @@ and cop_of_op var_env op_name exps =
|
|||
let cexps = cexprs_of_exps var_env exps in
|
||||
cop_of_op_aux op_name cexps
|
||||
|
||||
and clhs_of_lhs var_env l = match l.l_desc with
|
||||
and clhs_of_lhs var_env l = match l.pat_desc with
|
||||
(** Each Obc variable corresponds to a real local C variable. *)
|
||||
| Lvar v ->
|
||||
let n = name v in
|
||||
|
@ -339,7 +339,7 @@ let rec assoc_obj instance obj_env =
|
|||
else assoc_obj instance t
|
||||
|
||||
let assoc_cn instance obj_env =
|
||||
(assoc_obj (obj_call_name instance) obj_env).o_class
|
||||
(assoc_obj (obj_ref_name instance) obj_env).o_class
|
||||
|
||||
let is_op = function
|
||||
| { qual = "Pervasives"; name = _ } -> true
|
||||
|
@ -467,7 +467,7 @@ let rec cstm_of_act var_env obj_env act =
|
|||
| Acall (name_list, o, Mreset, args) ->
|
||||
assert_empty name_list;
|
||||
assert_empty args;
|
||||
let on = obj_call_name o in
|
||||
let on = obj_ref_name o in
|
||||
let obj = assoc_obj on obj_env in
|
||||
let classn = cname_of_qn obj.o_class in
|
||||
(match obj.o_size with
|
||||
|
@ -504,7 +504,7 @@ let rec cstm_of_act var_env obj_env act =
|
|||
generate_function_call var_env obj_env outvl objn args
|
||||
|
||||
| Acall(_, o, Mmethod s, _) ->
|
||||
let on = obj_call_name o in
|
||||
let on = obj_ref_name o in
|
||||
let obj = assoc_obj on obj_env in
|
||||
Error.message obj.o_loc (Error.Eunknown_method s)
|
||||
|
||||
|
|
|
@ -37,26 +37,26 @@ type const_dec = {
|
|||
c_type : ty;
|
||||
c_loc : location }
|
||||
|
||||
type lhs = { l_desc : lhs_desc; l_ty : ty; l_loc : location }
|
||||
type pattern = { pat_desc : pat_desc; pat_ty : ty; pat_loc : location }
|
||||
|
||||
and lhs_desc =
|
||||
and pat_desc =
|
||||
| Lvar of var_ident
|
||||
| Lmem of var_ident
|
||||
| Lfield of lhs * field_name
|
||||
| Larray of lhs * exp
|
||||
| Lfield of pattern * field_name
|
||||
| Larray of pattern * exp
|
||||
|
||||
and exp = { e_desc : exp_desc; e_ty : ty; e_loc : location }
|
||||
|
||||
and exp_desc =
|
||||
| Elhs of lhs
|
||||
| Elhs of pattern
|
||||
| Econst of static_exp
|
||||
| Eop of op_name * exp list
|
||||
| Estruct of type_name * (field_name * exp) list
|
||||
| Earray of exp list
|
||||
|
||||
type obj_call =
|
||||
type obj_ref =
|
||||
| Oobj of obj_name
|
||||
| Oarray of obj_name * lhs
|
||||
| Oarray of obj_name * pattern
|
||||
|
||||
type method_name =
|
||||
| Mreset
|
||||
|
@ -64,8 +64,8 @@ type method_name =
|
|||
| Mmethod of name
|
||||
|
||||
type act =
|
||||
| Aassgn of lhs * exp
|
||||
| Acall of lhs list * obj_call * method_name * exp list
|
||||
| Aassgn of pattern * exp
|
||||
| Acall of pattern list * obj_ref * method_name * exp list
|
||||
| Acase of exp * (constructor_name * block) list
|
||||
| Afor of var_ident * static_exp * static_exp * block
|
||||
|
||||
|
@ -113,7 +113,7 @@ let mk_exp ?(ty=invalid_type) ?(loc=no_location) desc =
|
|||
{ e_desc = desc; e_ty = ty; e_loc = loc }
|
||||
|
||||
let mk_lhs ?(ty=invalid_type) ?(loc=no_location) desc =
|
||||
{ l_desc = desc; l_ty = ty; l_loc = loc }
|
||||
{ pat_desc = desc; pat_ty = ty; pat_loc = loc }
|
||||
|
||||
let mk_lhs_exp ?(ty=invalid_type) desc =
|
||||
let lhs = mk_lhs ~ty:ty desc in
|
||||
|
@ -127,7 +127,7 @@ let mk_block ?(locals=[]) eq_list =
|
|||
b_body = eq_list }
|
||||
|
||||
let rec var_name x =
|
||||
match x.l_desc with
|
||||
match x.pat_desc with
|
||||
| Lvar x -> x
|
||||
| Lmem x -> x
|
||||
| Lfield(x,_) -> var_name x
|
||||
|
@ -155,7 +155,7 @@ let find_step_method cd =
|
|||
let find_reset_method cd =
|
||||
List.find (fun m -> m.m_name = Mreset) cd.cd_methods
|
||||
|
||||
let obj_call_name o =
|
||||
let obj_ref_name o =
|
||||
match o with
|
||||
| Oobj obj
|
||||
| Oarray (obj, _) -> obj
|
||||
|
|
|
@ -15,8 +15,8 @@ open Obc
|
|||
type 'a obc_it_funs = {
|
||||
exp: 'a obc_it_funs -> 'a -> Obc.exp -> Obc.exp * 'a;
|
||||
edesc: 'a obc_it_funs -> 'a -> Obc.exp_desc -> Obc.exp_desc * 'a;
|
||||
lhs: 'a obc_it_funs -> 'a -> Obc.lhs -> Obc.lhs * 'a;
|
||||
lhsdesc: 'a obc_it_funs -> 'a -> Obc.lhs_desc -> Obc.lhs_desc * 'a;
|
||||
lhs: 'a obc_it_funs -> 'a -> Obc.pattern -> Obc.pattern * 'a;
|
||||
lhsdesc: 'a obc_it_funs -> 'a -> Obc.pat_desc -> Obc.pat_desc * 'a;
|
||||
act: 'a obc_it_funs -> 'a -> Obc.act -> Obc.act * 'a;
|
||||
block: 'a obc_it_funs -> 'a -> Obc.block -> Obc.block * 'a;
|
||||
var_dec: 'a obc_it_funs -> 'a -> Obc.var_dec -> Obc.var_dec * 'a;
|
||||
|
@ -66,8 +66,8 @@ and edesc funs acc ed = match ed with
|
|||
|
||||
and lhs_it funs acc l = funs.lhs funs acc l
|
||||
and lhs funs acc l =
|
||||
let ld, acc = lhsdesc_it funs acc l.l_desc in
|
||||
{ l with l_desc = ld }, acc
|
||||
let ld, acc = lhsdesc_it funs acc l.pat_desc in
|
||||
{ l with pat_desc = ld }, acc
|
||||
|
||||
|
||||
and lhsdesc_it funs acc ld =
|
||||
|
|
|
@ -23,7 +23,7 @@ let print_obj ff o =
|
|||
fprintf ff "@]"
|
||||
|
||||
let rec print_lhs ff e =
|
||||
match e.l_desc with
|
||||
match e.pat_desc with
|
||||
| Lvar x -> print_ident ff x
|
||||
| Lmem x -> fprintf ff "mem("; print_ident ff x; fprintf ff ")"
|
||||
| Lfield (l, f) -> print_lhs ff l; fprintf ff ".%s" (shortname f)
|
||||
|
|
Loading…
Reference in a new issue