Ignore:
Timestamp:
Oct 11, 2011, 5:42:20 PM (9 years ago)
Author:
tranquil
Message:
  • changed implementation of constant indexings with extensible arrays
  • work on ASM completed
  • next: optimizations!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051-indexed-labels-branch/src/LIN/LINInterpret.ml

    r1349 r1357  
    4848let change_trace st trace = { st with trace = trace }
    4949let add_trace st cost_lbl = change_trace st (cost_lbl :: st.trace)
    50 
    51 let forget_ind st = match st.inds with
    52     | _ :: tail -> {st with inds = tail}
    53     | _ -> assert false (* indexing list must be non-empty *)
    54 let curr_ind st = match st.inds with
    55     | ind :: _ -> ind
    56     | _ -> assert false (* indexing list must be non-empty *)
    57 let allocate_ind st n = { st with inds = Array.make n 0 :: st.inds }
    58 
    59 let max_depth =
    60     let f_stmt j = function
    61         | LIN.St_ind_0 i | LIN.St_ind_inc i -> max (i + 1) j
    62         | _ -> j in
    63     List.fold_left f_stmt 0
     50let ev_label st = CostLabel.ev_indexing (CostLabel.curr_const_ind st.inds)
     51let new_ind st = { st with inds = CostLabel.new_const_ind st.inds }
     52let forget_ind st = { st with inds = CostLabel.forget_const_ind st.inds }
     53let enter_loop st = CostLabel.enter_loop st.inds
     54let continue_loop st = CostLabel.continue_loop st.inds
    6455
    6556let empty_state =
     
    9182
    9283let init_fun_call st ptr def =
    93         let st = allocate_ind st (max_depth def) in
     84        let st = new_ind st in
    9485  change_pc st (Val.change_address_offset ptr Val.Offset.zero)
    9586
     
    217208
    218209    | LIN.St_cost cost_lbl ->
    219                         let cost_lbl = CostLabel.apply_const_indexing (curr_ind st) cost_lbl in
     210                        let cost_lbl = ev_label st cost_lbl in
    220211      let st = add_trace st cost_lbl in
    221212      next_pc st
    222213                       
    223214                | LIN.St_ind_0 i ->
    224                         CostLabel.enter_loop (Some i) (curr_ind st);
     215                        enter_loop st i;
    225216                        next_pc st
    226217
    227218    | LIN.St_ind_inc i ->
    228             CostLabel.continue_loop (Some i) (curr_ind st);
     219            continue_loop st i;
    229220            next_pc st
    230221
Note: See TracChangeset for help on using the changeset viewer.