If i have wrapped varinfos in record type as below:
type type = {
mutable one : varinfo;
mutable two : varinfo;
}
how can i use this varinfo values?
Also how can i make use of varinfo returned from findOrCreateFunc?
Thanks n Regards
Sonam
> On Sat, Mar 02, 2013 at 08:40:39PM +0530, [email protected] 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
>
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users