Ignore:
Timestamp:
Nov 23, 2011, 5:43:24 PM (8 years ago)
Author:
tranquil
Message:

merge of indexed labels branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/clight/clightPrinter.ml

    r818 r1542  
    196196  | Efield(e1, id) ->
    197197      fprintf p "%a.%s" print_expr_prec (level, e1) id
    198   | Ecost (lbl,e1) ->
    199       fprintf p "(/* %s */ %a)" lbl print_expr e1
    200   | Ecall (f, arg, e) ->
     198  | Ecost(lbl, e1) ->
     199    (* printing label uglily even if in comment for consistence *)
     200    let lbl = CostLabel.string_of_cost_label lbl in
     201    fprintf p "(/* %s */ %a)" lbl print_expr e1
     202  | Ecall(f, arg, e) ->
    201203      fprintf p "(%s(%a), %a)" f print_expr arg print_expr e
    202204
     
    214216      print_expr p e1;
    215217      print_expr_list p (false, et)
     218
     219let print_loop_depth p = function
     220  | None -> fprintf p ""
     221  | Some x -> fprintf p "/* single entry loop depth: %d */@," x
    216222
    217223let rec print_stmt p s =
     
    241247              print_stmt s1
    242248              print_stmt s2
    243   | Swhile(e, s) ->
    244       fprintf p "@[<v 2>while (%a) {@ %a@;<0 -2>}@]"
    245               print_expr e
    246               print_stmt s
    247   | Sdowhile(e, s) ->
    248       fprintf p "@[<v 2>do {@ %a@;<0 -2>} while(%a);@]"
    249               print_stmt s
    250               print_expr e
    251   | Sfor(s_init, e, s_iter, s_body) ->
    252       fprintf p "@[<v 2>for (@[<hv 0>%a;@ %a;@ %a) {@]@ %a@;<0 -2>}@]"
    253               print_stmt_for s_init
    254               print_expr e
    255               print_stmt_for s_iter
    256               print_stmt s_body
     249  | Swhile(i, e, s) ->
     250    fprintf p "@[<v 0>%a@[<v 2>while (%a) {@ %a@;<0 -2>}@]@]"
     251      print_loop_depth i
     252      print_expr e
     253      print_stmt s
     254  | Sdowhile(i, e, s) ->
     255    fprintf p "@[<v 0>%a@[<v 2>do {@ %a@;<0 -2>} while(%a);@]@]"
     256      print_loop_depth i
     257      print_stmt s
     258      print_expr e
     259  | Sfor(i, s_init, e, s_iter, s_body) ->
     260    fprintf p "@[<v 0>%a@[<v 2>for (@[<hv 0>%a;@ %a;@ %a) {@]@ %a@;<0 -2>}@]@]"
     261      print_loop_depth i
     262      print_stmt_for s_init
     263      print_expr e
     264      print_stmt_for s_iter
     265      print_stmt s_body
    257266  | Sbreak ->
    258       fprintf p "break;"
     267    fprintf p "break;"
    259268  | Scontinue ->
    260       fprintf p "continue;"
     269    fprintf p "continue;"
    261270  | Sswitch(e, cases) ->
    262       fprintf p "@[<v 2>switch (%a) {@ %a@;<0 -2>}@]"
    263               print_expr e
    264               print_cases cases
     271    fprintf p "@[<v 2>switch (%a) {@ %a@;<0 -2>}@]"
     272      print_expr e
     273      print_cases cases
    265274  | Sreturn None ->
    266       fprintf p "return;"
     275    fprintf p "return;"
    267276  | Sreturn (Some e) ->
    268       fprintf p "return %a;" print_expr e
     277    fprintf p "return %a;" print_expr e
    269278  | Slabel(lbl, s1) ->
    270       fprintf p "%s:@ %a" lbl print_stmt s1
     279    fprintf p "%s:@ %a" lbl print_stmt s1
    271280  | Sgoto lbl ->
    272       fprintf p "goto %s;" lbl
    273  | Scost (lbl,s1) ->
     281    fprintf p "goto %s;" lbl
     282  | Scost (lbl,s1) ->
     283    let lbl = CostLabel.string_of_cost_label lbl in
    274284     fprintf p "%s:@ %a" lbl print_stmt s1
    275285
     
    468478  | Ssequence(s1, s2) -> collect_stmt s1; collect_stmt s2
    469479  | Sifthenelse(e, s1, s2) -> collect_expr e; collect_stmt s1; collect_stmt s2
    470   | Swhile(e, s) -> collect_expr e; collect_stmt s
    471   | Sdowhile(e, s) -> collect_stmt s; collect_expr e
    472   | Sfor(s_init, e, s_iter, s_body) ->
    473       collect_stmt s_init; collect_expr e;
    474       collect_stmt s_iter; collect_stmt s_body
     480  | Swhile(_, e, s) -> collect_expr e; collect_stmt s
     481  | Sdowhile(_, e, s) -> collect_stmt s; collect_expr e
     482  | Sfor(_, s_init, e, s_iter, s_body) ->
     483    collect_stmt s_init; collect_expr e;
     484    collect_stmt s_iter; collect_stmt s_body
    475485  | Sbreak -> ()
    476486  | Scontinue -> ()
Note: See TracChangeset for help on using the changeset viewer.