On Sat, Mar 02, 2013 at 08:40:39PM +0530, son...@iitk.ac.in wrote: > But i am not able to create a call statement along with parameters (arguments) > any simple example would be helpful.
Example to create: int tmp = foo(1, 2); inside a function bar (assuming [foo] and [bar] are of type fundec, you can find them with a visitor or build them with findOrCreateFunc). let build_call_stmt (foo: fundec) (bar: fundec) = (* variable holding the return value of the call *) let r = makeTempVar bar intType in let ret = (Var r, NoOffset) in (* the function foo *) let f = Lval (Var foo.svar, NoOffset) in (* the arguments: 1, 2 *) let args = [integer 1; integer 2] in (* everything together *) let call = Call (Some ret, f, args, locUnknown) in mkStmtOneInstr call Example use of findOrCreateFunc: let find_foo () = (* foo is of type int (*foo)(int a, int b) *) let foo_type = TFun ( intType, (* return type *) Some [ (* arguments *) ("a", integer, []); ("b", integer, []) ], false, (* foo is NOT variadic *) [] (* foo has not attributes *) ) in findOrCreateFunc file "foo" foo_type (None of this has been tested, there might be a few typos, but you get the idea.) Hope it helps, -- Gabriel ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users