Dear All I'm new of V8 and would like to know how to implement scope chain with V8 , I was ever with Spider monkey which having object scope to calling with API
JSBool <https://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference/JSBool> *JS_EvaluateScript*(JSContext <https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JSRuntime> *cx, JSObject <https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JSObject> *obj, const char *src, uintN <https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/jsint> length, const char *filename, uintN <https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/jsint> lineno, jsval <https://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference/Jsval> *rval); or if you don't understand please kindly see this JAVA Script code below var global_scope = this; var some_value = 'hello'; global_scope.some_value ; // 'hello' function (){ var function_scope = this; var some_value = 'hi'; function_scope.some_value ; // 'hi' } global_scope.some_value ; // 'hello' function_scope.some_value = 'hi'; // error : function_scope is not defined; because scope chain (function_scope) was terminated; ============================ but when implementing with V8 , I have done something like this code below Handle<Context> contextA = Context::New(isolate); Handle<Context> contextB = Context::New(isolate); Context::Scope context_scope1(contextA); Handle<String> source = String::NewFromUtf8(isolate, “var scope1 = this ; some_value=‘hello’;"); Handle<Script> script = Script::Compile(source); Handle<Value> result = script->Run(); // { Context::Scope context_scope2(contextB); Handle<String> source = String::NewFromUtf8(isolate, “scope1.some_value"); Handle<Script> script = Script::Compile(source); Handle<Value> result = script->Run(); // Error scope1 is not defined !!! result should be as 'hello' as above executing String::Utf8Value utf8(result); } ================================================== Please kindly advise and I do thank you very much for all that read my email. Best Regards Puwanat S. -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
