Frama-C-discuss mailing list archives
This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Frama-c-discuss] Substitution in Cil_types.predicate
- Subject: [Frama-c-discuss] Substitution in Cil_types.predicate
- From: virgile.prevosto at m4x.org (Virgile Prevosto)
- Date: Mon, 27 Feb 2012 11:05:47 +0100
- In-reply-to: <1330330506.2071.75.camel@iti27.informatik.htw-dresden.de>
- References: <1330091763.2071.50.camel@iti27.informatik.htw-dresden.de> <CA+yPOVgMt=gL_ta6EybZdxEdueW+-S0UMOgfXND8EH90VUF_GA@mail.gmail.com> <1330330506.2071.75.camel@iti27.informatik.htw-dresden.de>
Hello, 2012/2/27 Boris Hollas <hollas at informatik.htw-dresden.de>: > This works in a small example: > > method vterm t = > ?begin match t.term_node with > ? ?| TLval(TVar lv, offs) when Logic_utils.is_same_var lv lv_old -> > ? ? ?let t_new = Logic_const.term (TLval(TVar lv_new, offs)) > t.term_type in > ? ? ?Cil.ChangeDoChildrenPost (t, fun _ -> t_new) > > However, I use the term_offset of t in t_new. Is this correct in > general? No. As soon as offs is non-trivial, you end up with some sharing across new and old node. You should either visit the offset manually (let offs_new = Visitor.visitFramacTermOffset self offs in let t_new = Logic_const.term (Logic_const.tvar lv_new,offs_new) t.term_type in Cil.ChangeTo t_new) or overload vlogic_var_use instead of vterm: method vlogic_var_use lv = if Logic_utils.is_same_var lv lv_old then Cil.ChangeTo lv_new else DoChildren The latter can only be used for performing var-to-var substitution. For more complex substitutions, you'll have to operate at the vterm_lval or vterm level. By the way, Logic_utils.is_same_logic_var is based purely on variable's name (not taking into account possible captures). Depending on the intended usage, you might want to rely on Cil_datatype.Logic_variable.equal instead, which is based on the lv_id. > > With ChangeDoChildrenPost, it want to replace t with t_new. In 5.14.3., > the meaning of ChangeDoChildrenPost is explained as follows: > "ChangeDoChildrenPost(v,f) the old node is replaced by v, the visit goes > on with the children of v, and when it is finished, f is applied to the > result." > - does "old node" mean the original node? > - what does the "result" refer to? If it is the result of the visit, > what is this? Yes, old node means the original one, and the result is the result of visiting v. The result is whatever the visitor wants to do with the children of v. Best regards, -- E tutto per oggi, a la prossima volta Virgile
- Follow-Ups:
- [Frama-c-discuss] Substitution in Cil_types.predicate
- From: hollas at informatik.htw-dresden.de (Boris Hollas)
- [Frama-c-discuss] Substitution in Cil_types.predicate
- References:
- [Frama-c-discuss] Substitution in Cil_types.predicate
- From: hollas at informatik.htw-dresden.de (Boris Hollas)
- [Frama-c-discuss] Substitution in Cil_types.predicate
- From: virgile.prevosto at m4x.org (Virgile Prevosto)
- [Frama-c-discuss] Substitution in Cil_types.predicate
- From: hollas at informatik.htw-dresden.de (Boris Hollas)
- [Frama-c-discuss] Substitution in Cil_types.predicate
- Prev by Date: [Frama-c-discuss] Substitution in Cil_types.predicate
- Next by Date: [Frama-c-discuss] Substitution in Cil_types.predicate
- Previous by thread: [Frama-c-discuss] Substitution in Cil_types.predicate
- Next by thread: [Frama-c-discuss] Substitution in Cil_types.predicate
- Index(es):