Hi,  could you please help me clarify some confusions about Cil Visitors
actions below ?


>From the API

| SkipChildren (* Do not visit the children. Return the node as it is. *)
| DoChildren (* Continue with the children of this node. Rebuild the node on
return if any of the children changes (use == test) *)
| ChangeTo of 'a (* Replace the expression with the given one *)
| ChangeDoChildrenPost of 'a * ('a -> 'a) (* First consider that the entire
exp is replaced by the first parameter. Then continue with the children. On
return rebuild the node if any of the children has changed and then apply
the function on the node


Questions


1)    I wrote the below visitor which simply store all statements' sids to a
hashtable.  The 2 vstmts versions give completely different results  (e..,g
the length of ht in version1 is much smaller than in version2).   I thought
vstmt s would visit all statements so the two versions would give equal ht
length

class visitV ht = object
  inherit nopCilVisitor

   (*VERSION 1*)
  method vstmt s = (
   if not (H.mem ht s.sid) then H.add ht s.sid () ;
   SkipChildren
  )

   (*VERSION 2*)
  method vstmt s = ChangeDoChildrenPost(
  s, fun s -> H.add ht s.sid (); s
  )
end


2)  DoChildren (* Continue with the children of this node. Rebuild the node
on return if any of the children changes (use == test) *)
What're the meanings of node and children ?  Can you give me some simple
examples ?   What is the meaning of _rebuilding_ node ?


3)  ChangeDoChildrenPost of 'a * ('a -> 'a) (* First consider that the
entire exp is replaced by the first parameter. Then continue with the
children. On return rebuild the node if any of the children has changed and
then apply the function on the node  *)

I don't understand this very well,

for example if I have

method vblock b = ChangeDoChildrenPost(
b1, fun b2 -> {b2 with significant change}
)

then what does it do ?    does it replace block b with b1  ?     what about
the 2nd part, fun b2 -> {b2 with significant change}?



Thanks and happy New Year all









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

Reply via email to