(*
- * Copyright 2010, INRIA, University of Copenhagen
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
* Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
(* --------------------------------------------------------------------- *)
-(* drop all distinguishing information from a term *)
-let strip =
- let do_nothing r k e = Ast.make_term (Ast.unwrap (k e)) in
+(* drop all distinguishing information from a term except inherited
+ variables, which are used to improve efficiency of matching process *)
+let strip x =
+ let do_nothing r k e =
+ let inh = Ast.get_inherited e in
+ Ast.make_inherited_term (Ast.unwrap (k e)) inh in
let do_absolutely_nothing r k e = k e in
let mcode m = Ast.make_mcode(Ast.unwrap_mcode m) in
let rule_elem r k re =
do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing
do_nothing rule_elem do_nothing do_nothing
do_nothing do_absolutely_nothing in
- recursor.V.rebuilder_rule_elem
+ recursor.V.rebuilder_rule_elem x
(* --------------------------------------------------------------------- *)
(* --------------------------------------------------------------------- *)
(* the main translation loop *)
-let rule_elem re =
+let rec rule_elem re =
match Ast.unwrap re with
- Ast.DisjRuleElem(res) -> [[(List.length res,strip re)]]
+ Ast.DisjRuleElem(res) ->
+ (* why was the following done? ors have to be kept together for
+ efficiency, so they are considered at once and not individually
+ anded with everything else *)
+ let re =
+ let all_inhs = List.map Ast.get_inherited res in
+ let inhs =
+ List.fold_left
+ (function prev ->
+ function inh ->
+ Common.inter_set inh prev)
+ (List.hd all_inhs) (List.tl all_inhs) in
+ Ast.make_inherited_term (Ast.unwrap re) inhs in
+ [[(List.length res,strip re)]]
| _ -> [[(1,strip re)]]
let conj_one testfn x l =
| Ast.Define(header,body) ->
conj_one testfn header (statement_list testfn mcode tail body)
+ | Ast.AsStmt(stm,asstm) ->
+ conj
+ (statement testfn mcode tail stm)
+ (statement testfn mcode tail asstm)
+
| Ast.OptStm(stm) -> []
| Ast.UniqueStm(stm) -> statement testfn mcode tail stm