Hi all,

I'm trying to create some automatic rewriting of all the JS code that is 
being parsed by Chrome/V8. For that I went to ParseInfo::CreateScript and 
just replaced the source string with my rewritten one:

    std::string s = source->ToCString().get();
    std::string transformed = rewrite(isolate, s); // rewrite is 
implemented somewhere else.
    v8::internal::Factory* factory = isolate->factory();
    v8::internal::Vector<const char> vec(transformed.data(), 
static_cast<size_t>(transformed.size()));
    source = factory->NewStringFromUtf8(vec).ToHandleChecked();

However that seems to mess with the rest of the parsing process, because 
the first few hundred characters of my source go randomly missing when the 
parser starts parsing (I couldn't figure that bug out yet).

Are there any better functions where I can inject this rewriting logic, 
e.g. some central parsing function where it's safer to replace the string?

(Note that I only want to create some proof-of-concept, not something that 
would ever go into production).

Cheers,
- Raphael

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/b9cbee12-0368-45b6-8d1e-1ca8c90fdab6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to