 Timestamp:
 Oct 7, 2011, 1:48:26 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D2.2/8051indexedlabelsbranch/src/common/costLabel.ml
r1310 r1319 12 12 let sexpr_id = Sexpr(1, 0) 13 13 14 let const_sexpr n = Sexpr(0, n) 15 14 16 type index = int 15 17 … … 18 20 type indexing = sexpr list 19 21 20 type const_indexing = int ref list22 type const_indexing = int array 21 23 22 24 (** [enter_loop n indexing] is used to update indexing when one is entering a 23 25 loop indexed by [n]. 24 26 The function recycles the same constant indexing *) 25 let rec enter_loop n indexing = match n, indexing with 26  None, _ > indexing (* entering a multientry loop *) 27  Some 0, [] > [ref 0] (* entering a single entry loop, current depth *) 28  Some 0, hd :: tl > hd := 0; indexing (* as above, reusing slot *) 29  Some x, hd :: tl > hd :: enter_loop (Some (x1)) tl (* lower depth *) 30  Some x, [] > assert false(* means I'm entering a single entry loop *) 31 (* without having entered the one containing it *) 27 let rec enter_loop n indexing = match n with 28  None > () 29  Some x > indexing.(x) < 0 32 30 33 31 (** [enter_loop n indexing] is used to update indexing when one is continuing a 34 32 loop indexed by [n]. *) 35 let rec continue_loop n indexing = match n, indexing with 36  None, _ > indexing (* continuing a multientry loop *) 37  Some 0, hd :: tl > hd := !hd + 1; indexing (* incrementing index *) 38  Some x, hd :: tl > hd :: continue_loop (Some (x1)) tl (* lower depth *) 39  Some _, [] > assert false (* means I'm continuing a single entry loop *) 40 (* without having entered it *) 33 let rec continue_loop n indexing = match n with 34  None > () 35  Some x > indexing.(x) < indexing.(x) + 1 41 36 42 37 let sexpr_of i l = … … 47 42  Invalid_argument _ > invalid_arg "costLabel.sexpr_of" 48 43 49 let rec id_indexing = function50  0 > [] 51  n > sexpr_id :: id_indexing (n1) 44 let empty_indexing = [] 45 46 let add_id_indexing ind = sexpr_id :: ind 52 47 53 48 (* a*_+b is composed with c*_+d by substitution: *) … … 70 65  _ > n 71 66 72 let rec compose_const_indexing c m = match c, m with73  i1 :: l1, s2 :: l2 > ev_sexpr !i1 s2 :: compose_const_indexing l1 l274  _, [] > [] (* that's ok as current indexings will not be shrinked *)75  [], _ > assert false (* means an indexed label is not in the right ctx *)67 let rec compose_const_indexing_i i c = function 68  [] > [] 69  s :: l > 70 const_sexpr (ev_sexpr c.(i) s) :: compose_const_indexing_i (i+1) c l 76 71 77 72 module IndexingSet = Set.Make(struct … … 80 75 end) 81 76 82 83 77 type t = { 84 78 name : Atom.t; 85 79 i : indexing 86 80 } 81 82 let apply_const_indexing c lbl = 83 {lbl with i = compose_const_indexing_i 0 c lbl.i} 87 84 88 85
Note: See TracChangeset
for help on using the changeset viewer.