--- layout: fc_discuss_archives title: Message 22 from Frama-C-discuss on December 2013 ---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transfer.ml
Type: application/octet-stream
Size: 1807 bytes
Desc: not available
URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20131210/2797b786/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pfunc.c
Type: text/x-csrc
Size: 158 bytes
Desc: not available
URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20131210/2797b786/attachment.c>