Ignore:
Timestamp:
Mar 2, 2011, 3:27:41 PM (9 years ago)
Author:
ayache
Message:

Update of D2.2 from Paris.

Location:
Deliverables/D2.2/8051/src/RTLabs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/RTLabs/RTLabsInterpret.ml

    r486 r619  
    3838type state =
    3939  | State of stack_frame list * RTLabs.graph * Val.t (* stack pointer *) *
    40              Label.t * local_env * memory * AST.trace
     40             Label.t * local_env * memory * CostLabel.t list
    4141  | CallState of stack_frame list * RTLabs.function_def *
    42                  Val.t list (* args *) * memory * AST.trace
     42                 Val.t list (* args *) * memory * CostLabel.t list
    4343  | ReturnState of stack_frame list * Val.t (* return value *) *
    44                    memory * AST.trace
     44                   memory * CostLabel.t list
    4545
    4646
     
    135135  | AST.Op_divu -> Val.divu
    136136  | AST.Op_mod -> Val.modulo
    137   | AST.Op_modu -> Val.modu
     137  | AST.Op_modu -> Val.modulou
    138138  | AST.Op_and -> Val.and_op
    139139  | AST.Op_or -> Val.or_op
     
    192192    (mem  : memory)
    193193    (stmt : RTLabs.statement)
    194     (t    : AST.trace) :
     194    (t    : CostLabel.t list) :
    195195    state = match stmt with
    196196
     
    364364    (args  : Val.t list)
    365365    (mem   : memory)
    366     (t     : AST.trace) :
     366    (t     : CostLabel.t list) :
    367367    state =
    368368  match f_def with
     
    382382    (ret_val : Val.t)
    383383    (mem     : memory)
    384     (t       : AST.trace) :
     384    (t       : CostLabel.t list) :
    385385    state =
    386386  let lenv = adds sf.ret_regs ret_val sf.lenv in
     
    400400
    401401
    402 let rec iter_small_step st = match small_step st with
     402let compute_result v =
     403  if Val.is_int v then IntValue.Int8.cast (Val.to_int_repr v)
     404  else IntValue.Int8.zero
     405
     406let rec iter_small_step print_result st = match small_step st with
    403407(*
     408  (* <DEBUG> *)
    404409  | ReturnState ([], v, mem, t) ->
    405410    Mem.print mem ;
     
    409414  | ReturnState (_, _, mem, _)
    410415  | State (_, _, _, _, _, mem, _) as st' -> Mem.print mem ; iter_small_step st'
     416  (* </DEBUG> *)
    411417*)
    412   | ReturnState ([], v, mem, t) -> List.rev t
    413   | st' -> iter_small_step st'
     418  | ReturnState ([], v, mem, t) ->
     419    let (res, cost_labels) as trace = (compute_result v, List.rev t) in
     420    if print_result then
     421      Printf.printf "RTLabs: %s\n%!" (IntValue.Int8.to_string res) ;
     422    trace
     423  | st' -> iter_small_step print_result st'
    414424
    415425
     
    431441(* Interpret the program only if it has a main. *)
    432442
    433 let interpret p = match p.RTLabs.main with
    434   | None -> []
     443let interpret print_result p = match p.RTLabs.main with
     444  | None -> (IntValue.Int8.zero, [])
    435445  | Some main ->
    436446    let mem = init_mem p in
    437447    let main_def = find_function mem main in
    438448    let st = CallState ([], main_def, [], mem, []) in
    439     iter_small_step st
     449    iter_small_step print_result st
  • Deliverables/D2.2/8051/src/RTLabs/RTLabsInterpret.mli

    r486 r619  
    33    and return the trace of cost labels encountered. *)
    44
    5 val interpret : RTLabs.program -> AST.trace
     5val interpret : bool -> RTLabs.program -> AST.trace
Note: See TracChangeset for help on using the changeset viewer.