Project

General

Profile

Revision e49b6d55

View differences:

src/corelang.ml
473 473
let sort_handlers hl =
474 474
 List.sort (fun (t, _) (t', _) -> compare t t') hl
475 475

  
476
let num_10 = Num.num_of_int 10
477
  
478
let rec is_eq_const c1 c2 =
479
  match c1, c2 with
480
  | Const_real (n1, i1, _), Const_real (n2, i2, _)
481
    -> Num.(let n1 = n1 // (num_10 **/ (num_of_int i1)) in
482
	    let n2 = n2 // (num_10 **/ (num_of_int i2)) in
483
	    eq_num n1 n2)
484
  | Const_struct lcl1, Const_struct lcl2
485
    -> List.length lcl1 = List.length lcl2
486
    && List.for_all2 (fun (l1, c1) (l2, c2) -> l1 = l2 && is_eq_const c1 c2) lcl1 lcl2
487
  | _  -> c1 = c2
488

  
476 489
let rec is_eq_expr e1 e2 = match e1.expr_desc, e2.expr_desc with
477
  | Expr_const c1, Expr_const c2 -> c1 = c2
490
  | Expr_const c1, Expr_const c2 -> is_eq_const c1 c2
478 491
  | Expr_ident i1, Expr_ident i2 -> i1 = i2
479 492
  | Expr_array el1, Expr_array el2 
480 493
  | Expr_tuple el1, Expr_tuple el2 -> 
src/normalization.ml
80 80
let get_expr_alias defs expr =
81 81
 try Some (List.find (fun eq -> is_eq_expr eq.eq_rhs expr) defs)
82 82
 with
83
   Not_found -> None
84

  
83
 | Not_found -> None
84
  
85 85
(* Replace [expr] with (tuple of) [locals] *)
86 86
let replace_expr locals expr =
87 87
 match locals with
......
156 156
   taking propagated [offsets] into account
157 157
   in order to change expression type *)
158 158
let mk_norm_expr offsets ref_e norm_d =
159
(*Format.eprintf "mk_norm_expr %a %a @." Printers.pp_expr ref_e Printers.pp_expr { ref_e with expr_desc = norm_d};*)
159
  (*Format.eprintf "mk_norm_expr %a %a @." Printers.pp_expr ref_e Printers.pp_expr { ref_e with expr_desc = norm_d};*)
160 160
  let drop_array_type ty =
161 161
    Types.map_tuple_type Types.array_element_type ty in
162 162
  { ref_e with
163 163
    expr_desc = norm_d;
164 164
    expr_type = Utils.repeat (List.length offsets) drop_array_type ref_e.expr_type }
165

  
165
														
166 166
(* normalize_<foo> : defs * used vars -> <foo> -> (updated defs * updated vars) * normalized <foo> *)
167 167
let rec normalize_list alias node offsets norm_element defvars elist =
168 168
  List.fold_right
......
172 172
    ) elist (defvars, [])
173 173

  
174 174
let rec normalize_expr ?(alias=true) node offsets defvars expr =
175
(*Format.eprintf "normalize %B %a:%a [%a]@." alias Printers.pp_expr expr Types.print_ty expr.expr_type (Utils.fprintf_list ~sep:"," Dimension.pp_dimension) offsets;*)
175
  (*Format.eprintf "normalize %B %a:%a [%a]@." alias Printers.pp_expr expr Types.print_ty expr.expr_type (Utils.fprintf_list ~sep:"," Dimension.pp_dimension) offsets;*)
176 176
  match expr.expr_desc with
177 177
  | Expr_const _
178 178
  | Expr_ident _ -> defvars, unfold_offsets expr offsets

Also available in: Unified diff