--- layout: fc_discuss_archives title: Message 24 from Frama-C-discuss on December 2013 ---
Dear Guillaume Petiot, Thank you so much. It helps a lot. I am sorry for any inconvenience for not carefully enough. I can do that now by adding this code, similar with using "-then-on". Project.set_current prj; Additionally, whether could I achieve this by using the copy visitor? Thanks. Best wishes, -david On 10 December 2013 07:44, PETIOT Guillaume <Guillaume.PETIOT at cea.fr> wrote: > Hi, > > You applied your transformation on the AST of project prj (called "transfer") when you did > Project.on prj transform() > > but you call the Printer on the current project ("default"). So you have to replace the call to the Printer by something like > Project.on prj (fun () -> > Format.printf "\n\nAfter transfering:\n%a" Printer.pp_file (Ast.get ()) > ) () > So that the Ast.Get() will return the AST of project "transfer". > > > You can also print the AST by invoking frama-c like this: frama-c -load-script transfer.ml pfunc.c -then-on transfer -print > > > Regards. > -- > Guillaume Petiot, PhD student > CEA LIST > > ________________________________________ > From: frama-c-discuss-bounces at lists.gforge.inria.fr [frama-c-discuss-bounces at lists.gforge.inria.fr] on behalf of David Yang [abiao.yang at gmail.com] > Sent: Tuesday, December 10, 2013 3:47 AM > To: Frama-C public discussion > Subject: [Frama-c-discuss] how to modify stmt in AST by using a visitor > > Dear all, > > Inspired by Virgile 's insert_stmt script in this mailing list: > http://lists.gforge.inria.fr/pipermail/frama-c-discuss/2012-March/003141.html > > I am writing a similar script to transform all call stmt of using > function pointer to a regular call stmt. > > For example, in file "pfunc.c": > /* --------------pfunc.c--------------------- */ > typedef int p_func (int *, int); > > int main (p_func* func, int *arg1, int arg2) > { > int result; > > result = (*func)(arg1, arg2); > > return result; > } > /*-------------end----------------*/ > > the func variable is a function pointer type. I want transform this > call to a regular call statement. > > The command I used here is : > frama-c -load-script transfer.ml pfunc.c > > You could download this two files and then run these script directly > as long as you has frama-c in your computer. > > Attached please find these two files for this command. > > But the ast file is not changed by this script. > > Is there anybody could help me fixing this problem? > Thank you very much. > > PS: The frama-c version I used here is: Fluorine-20130601 > > All the best, > -david > > _______________________________________________ > Frama-c-discuss mailing list > Frama-c-discuss at lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/frama-c-discuss