On Thu, Jan 14, 2010 at 04:51:47PM +0100, ROGER Muriel wrote:
> method vstmt (myStmt : stmt) =
>       match myStmt.skind with
>           | Instr i ->
>                    match i with
>                      | Set((Var vi,off),e,loc) when (Pc_util.isBoolExp e) ->
>                          let thenBlock = mkBlock [mkStmtOneInstrWithValidSid
>                                                     (Set((Var 
> vi,off),Cil.one,loc))]
>                          and elseBlock = mkBlock [mkStmtOneInstrWithValidSid
>                                                     (Set((Var 
> vi,off),Cil.zero,loc))]
>                          in let ifStmt = mkStmt ~valid_sid:true (If(e, 
> thenBlock, elseBlock, loc))
>                          in ChangeDoChildrenPost (myStmt, fun _ -> ifStmt)
>                      | _ ->   s)
>           | ...

1) This won't compile since i is an instruction *list*.  You should
   match [Set( ...)] instead of Set( ... ) (splitting Instr [i1; ... ; in]
   into Block { [ Instr i1; ... ; Instr in ] } in a first-pass), or handle
   things in vinstr (but this would be very tricky in your case, since you
    want to replace an instruction by a statement).
2) Your use of ChangeDoChildrenPost is incorrect, hence the lack of
   traversal you observe.  You should use:
   ChangeDoChildrenPost(ifStmt, fun s -> s)

Regards,
-- 
Gabriel Kerneis

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to