Ignore:
Timestamp:
Oct 10, 2011, 2:17:02 PM (8 years ago)
Author:
tranquil
Message:

work on Cminor completed

File:
1 edited

Legend:

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

    r818 r1334  
    486486    AST.res = ret_type }
    487487
     488let ind_0 i stmt = match i with
     489        | None -> stmt
     490        | Some x -> Cminor.St_ind_0(x, stmt)
     491
     492let ind_inc i stmt = match i with
     493        | None -> stmt
     494        | Some x -> Cminor.St_ind_inc(stmt, x)
     495
    488496let f_stmt fresh var_locs stmt sub_exprs_res sub_stmts_res =
    489497  let (tmps, sub_stmts_res) = List.split sub_stmts_res in
     
    509517      ([(tmp, t)], Cminor.St_seq (stmt_call, stmt_assign))
    510518
    511     | Clight.Swhile _, e :: _, stmt :: _ ->
    512       let econd =
    513         Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
     519    | Clight.Swhile (i,_,_), e :: _, stmt :: _ ->
     520      let econd =               
     521        Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
    514522      let scond =
    515         Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    516       ([],
    517        Cminor.St_block (Cminor.St_loop (Cminor.St_seq (scond,
    518                                                        Cminor.St_block stmt))))
    519 
    520     | Clight.Sdowhile _, e :: _, stmt :: _ ->
    521       let econd =
    522         Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
     523        Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
     524            let loop_body = Cminor.St_seq (scond, ind_inc i (Cminor.St_block stmt)) in
     525                        let loop = ind_0 i (Cminor.St_loop loop_body) in
     526      ([], Cminor.St_block loop)
     527                       
     528    | Clight.Sdowhile (i,_,_), e :: _, stmt :: _ ->
     529      let econd =               
     530        Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
    523531      let scond =
    524         Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    525       ([],
    526        Cminor.St_block (Cminor.St_loop (Cminor.St_seq (Cminor.St_block stmt,
    527                                                        scond))))
    528 
    529     | Clight.Sfor _, e :: _, stmt1 :: stmt2 :: stmt3 :: _ ->
    530       let econd =
    531         Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
     532              Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
     533                        let loop_body = ind_inc i (Cminor.St_seq (Cminor.St_block stmt, scond)) in
     534                        let loop = ind_0 i (Cminor.St_loop loop_body) in
     535      ([], Cminor.St_block loop)
     536
     537    | Clight.Sfor (i,_,_,_,_), e :: _, stmt1 :: stmt2 :: stmt3 :: _ ->
     538      let econd =                               
     539        Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
    532540      let scond =
    533         Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    534       let body = Cminor.St_seq (Cminor.St_block stmt3, stmt2) in
    535       ([],
    536        Cminor.St_seq (stmt1,
    537                       Cminor.St_block
    538                         (Cminor.St_loop (Cminor.St_seq (scond, body)))))
     541              Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
     542      let body = Cminor.St_seq (ind_inc i (Cminor.St_block stmt3), stmt2) in
     543                        let body = Cminor.St_seq (scond, body) in
     544                        let block = Cminor.St_block (ind_0 i (Cminor.St_loop body)) in 
     545      ([], Cminor.St_seq (stmt1, block))
    539546
    540547    | Clight.Sifthenelse _, e :: _, stmt1 :: stmt2 :: _ ->
Note: See TracChangeset for help on using the changeset viewer.