Hi,
I've added a function template for the 'eval' function in java script.
I've tried some code like below:
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("eval"),
FunctionTemplate::New(eval_Handler));
where eval_Handler is declared as follows:
Handle<Value> DOMWindow_eval_Callback(const Arguments& args)
{
......
}
I'm doing this to record the statements being evaluated by the
function.
Everything works fine and I get the arguments as expected for the eval
call, except, when the eval call is made from within a function.
For example, consider the script:
function f1(x, y, z) {
return eval("Math.min(x,y,z)");
}
var res1 = f1(3, 4, 5);
var res2 = eval("Math.min(4, 5, 6)");
when the eval call is encountered within f1, my eval handler receives
the arguments as "Math.min(x,y,z)" instead of "Math.min(3,4,5)", even
though the function f1 is invoked with the arguments 3,4,5.
On the other hand, the next call to eval for res2 gives me the
arguments "Math.min(4,5,6)" as expected.
I was wondering if there is any way to get the actual arguments being
passed to the eval call within the function f1. I'm not sure if the
string quotes have anything to do with the way the arguments are being
passed to the eval handler.
Please suggest.
Thank you,
Ravi
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users