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

merge of indexed labels branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/cminor/cminorPrinter.ml

    r818 r1542  
    116116        (add_parenthesis e3)
    117117  | Cminor.Exp_cost (lab, e) ->
     118      let lab = CostLabel.string_of_cost_label lab in
    118119      Printf.sprintf "/* %s */ %s" lab (print_expression e)
    119120and add_parenthesis (Cminor.Expr (ed, _) as e) = match ed with
     
    136137let print_table n =
    137138  let f s (case, exit) =
    138     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
    139140  in
    140141  List.fold_left f ""
     
    171172        (Primitive.print_sig sg)
    172173  | Cminor.St_seq (s1, s2) -> (print_body n s1) ^ (print_body n s2)
     174  | Cminor.St_ifthenelse (e, s1, Cminor.St_skip) ->
     175    Printf.sprintf "%sif (%s) {\n%s%s}\n"
     176    (n_spaces n)
     177    (print_expression e)
     178    (print_body (n+2) s1)
     179    (n_spaces n)
    173180  | Cminor.St_ifthenelse (e, s1, s2) ->
    174181      Printf.sprintf "%sif (%s) {\n%s%s}\n%selse {\n%s%s}\n"
     
    180187        (print_body (n+2) s2)
    181188        (n_spaces n)
    182   | Cminor.St_loop s ->
     189(*  | Cminor.St_loop s ->
    183190      Printf.sprintf "%sloop {\n%s%s}\n"
    184191        (n_spaces n)
     
    191198        (n_spaces n)
    192199  | Cminor.St_exit i ->
    193       Printf.sprintf "%sexit %d;\n" (n_spaces n) i
     200      Printf.sprintf "%sexit %d;\n" (n_spaces n) i *)
    194201  | Cminor.St_switch (e, tbl, dflt) ->
    195       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"
    196203        (n_spaces n)
    197204        (print_expression e)
     
    208215      Printf.sprintf "%sgoto %s;\n" (n_spaces n) lbl
    209216  | Cminor.St_cost (lbl, s) ->
    210       Printf.sprintf "%s%s:\n%s"
    211         (n_spaces n) lbl (print_body n s)
     217      let lbl = CostLabel.string_of_cost_label lbl in
     218      Printf.sprintf "%s%s:\n%s" (n_spaces n) lbl (print_body n s)
     219  | Cminor.St_ind_0 (i, s) ->
     220      Printf.sprintf "%sindex %d:\n%s" (n_spaces n) i (print_body n s)
     221  | Cminor.St_ind_inc (i,s) ->
     222      Printf.sprintf "%sincrement %d:\n%s\n" (n_spaces n) i (print_body n s)
    212223
    213224let print_internal f_name f_def =
     
    246257  | Cminor.St_seq(_,_) -> "seq"
    247258  | Cminor.St_ifthenelse(_,_,_) -> "ifthenelse"
    248   | Cminor.St_loop(_) -> "loop"
     259(*  | Cminor.St_loop(_) -> "loop"
    249260  | Cminor.St_block(_) -> "block"
    250   | Cminor.St_exit(_) -> "exit"
     261  | Cminor.St_exit(_) -> "exit" *)
    251262  | Cminor.St_switch(_,_,_) -> "switch"
    252263  | Cminor.St_return(_) -> "return"
     
    254265  | Cminor.St_goto(_) -> "goto"
    255266  | Cminor.St_cost(_,_) -> "cost"
     267  | Cminor.St_ind_0 _ -> "index"
     268  | Cminor.St_ind_inc _ -> "increment"
Note: See TracChangeset for help on using the changeset viewer.