Ignore:
Timestamp:
Oct 17, 2011, 2:08:27 PM (9 years ago)
Author:
tranquil
Message:

fiddling with Cminor: elimination of loops, blocks and exits

File:
1 edited

Legend:

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

    r1334 r1392  
    137137let print_table n =
    138138  let f s (case, exit) =
    139     Printf.sprintf "%s%scase %d: exit %d;\n" s (n_spaces n) case exit
     139    Printf.sprintf "%s%scase %d: goto %s;\n" s (n_spaces n) case exit
    140140  in
    141141  List.fold_left f ""
     
    187187        (print_body (n+2) s2)
    188188        (n_spaces n)
    189   | Cminor.St_loop s ->
     189(*  | Cminor.St_loop s ->
    190190      Printf.sprintf "%sloop {\n%s%s}\n"
    191191        (n_spaces n)
     
    198198        (n_spaces n)
    199199  | Cminor.St_exit i ->
    200       Printf.sprintf "%sexit %d;\n" (n_spaces n) i
     200      Printf.sprintf "%sexit %d;\n" (n_spaces n) i *)
    201201  | Cminor.St_switch (e, tbl, dflt) ->
    202       Printf.sprintf "%sswitch (%s) {\n%s%sdefault: exit %d;\n%s}\n"
     202      Printf.sprintf "%sswitch (%s) {\n%s%sdefault: goto %s;\n%s}\n"
    203203        (n_spaces n)
    204204        (print_expression e)
     
    219219        | Cminor.St_ind_0 (i, s) ->
    220220                  Printf.sprintf "%sindex %d:\n%s" (n_spaces n) i (print_body n s)
    221         | Cminor.St_ind_inc (s, i) ->
    222                   Printf.sprintf "%s%sincrement %d;\n" (print_body n s) (n_spaces n) i
     221        | Cminor.St_ind_inc (i,s) ->
     222                  Printf.sprintf "%sincrement %d:\n%s\n" (n_spaces n) i (print_body n s)
    223223
    224224let print_internal f_name f_def =
     
    257257  | Cminor.St_seq(_,_) -> "seq"
    258258  | Cminor.St_ifthenelse(_,_,_) -> "ifthenelse"
    259   | Cminor.St_loop(_) -> "loop"
     259(*  | Cminor.St_loop(_) -> "loop"
    260260  | Cminor.St_block(_) -> "block"
    261   | Cminor.St_exit(_) -> "exit"
     261  | Cminor.St_exit(_) -> "exit" *)
    262262  | Cminor.St_switch(_,_,_) -> "switch"
    263263  | Cminor.St_return(_) -> "return"
Note: See TracChangeset for help on using the changeset viewer.