Hi, I am playing with CIL and create a test Visitor below that change the names of statments of form foo(arg1,arg2); to foo_new(arg1,arg2) . The visitor below supposes to do that but its is quite ugly (I am also new to Ocaml) and probably is incorrect (it seems to work ok though). Could someone please look at it and provide suggestions on how to make it cleaner and more correct ? Thanks !
class testVisitor = object inherit nopCilVisitor method vstmt s = ( if s.sid = WHAT_I_WANT then ( match s.skind with |Instr il ->( debug "gh\n"; if L.length il > 0 then ( let i = L.hd il in match i with |Call(lv_opt,e,es,loc)->( debug "gh1\n"; (match lv_opt with | None -> ( debug "gh2:\n"; (match e with |Lval lv -> ( (*NEEDS CLEAN UP HERE*) debug "gh2: lval %s\n" (get_lval lv); let (lh,_) = lv in let lh' = ref lh in (match !lh' with |Var v -> v.vname<- v.vname ^ "_new"; |_->()); let instr = Call(lv_opt,e,es,loc) in let new_stmt = mkStmtOneInstr instr in new_stmt.sid <- s.sid; ChangeTo (new_stmt) ) |_ -> debug"don't know"; SkipChildren ); ) | Some _ -> SkipChildren ) ) |_ -> SkipChildren ) else( SkipChildren ) ) | _ -> SkipChildren ) else ( SkipChildren ) ) end VN -
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users