--
--
v8-users mailing list
v8-u...@googlegroups.com
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 v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/746a4d9f-d364-4506-8783-347eee5dad6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don’t believe you can do exactly what you want here, as there are two parts:1) getting `this` set properly. I believe you should be able to use `CompileFunctionInContext()` to this effect, which is used to provide implicit arguments to DOM onxxx=“script...” handlers. I believe you can then make `this` whatever you want in that function. Return statements would still be legal, as they are in DOM events, though.2) completion value of the script. This is trickier, as the v8 API does not expose a way to run the AST rewriter on arbitrary functions afaict. It may be possible to introduce an API for this, if it’s important.
You might be able to take a third option, transforming the code with a custom Babel plugin before passing it to v8 (at runtime), and providing the sourcemap info along with it for debugging purposes.
Any ideas? :)--
2019. június 7., péntek 13:16:08 UTC+2 időpontban Zoltan B a következőt írta:Hi!Is there a way to provide value for the 'this' keyword, when I'm running a v8 Script?An alternative would be to compile the code as a function instead, and provide 'this' when calling it trough 'recv', but then I would have other issues: running a script like this: "1+1" would not return 2 as a result, as I would have to explicitly put a "return" in front of "1+1", so the function will return the script's value. This seems to be error prone, not to mention that script locations will skew when viewed from DevTools. Using "return eval('1+1')" would work, but it kills performance due to the eval.
--
v8-users mailing list
v8-u...@googlegroups.com
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 v8-u...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/edc28096-a090-4188-9828-11ed67ddd6c1%40googlegroups.com.
No, that method would still require a return statement. Getting rid of the return statement requirement would need a new API, or transforming the source program before using it.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/44b2bf8b-888c-4dc9-bc21-e0b570f4d9c2%40googlegroups.com.