Hello,
I'm modifying V8 for my master thesis and for this need to access variables
from the frame/context/closure(?) from which a function is called.
In my scenario I have calls to a C++ method from JS like this:
// a global variable
var global = "global_value";
function foo(){
var global = "local_value";
myCppFunction("global", global);
}
foo();
Now I would like to know how in the implementation of myCppFunction I could
access the function local variable "global" (NOT value, this would be given
by the 2nd parameter) from 'foo'?
Handle<Value> MyCppFunction(const Arguments& args){
Local<String> varName = args[0]->ToString();
Local<String> varValue = args[1]->ToString(); // this holds "local_value"
// how to access the variable "global" in the scope of 'foo' using varName?
}
I tried to play around with StackFrameLocator as I thought the Frame for
the function from which my C++ function is called would have to be the
previous on the stack. But I didn't manage to find the variable.
Can someone give me a hint how I could access the desired variable? Is
there a way via internal::Isolate::Current()?
Best regards
Jonas
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users