src: fix up after v8 upgrade
The two biggest changes are that v8::Script::New() has been removed and that a v8::Script object now has to be explicitly bound to a context if you want to run it from another context. We can accommodate both changes without breaking the vm module's public API or even the internal JS API.
This commit is contained in:
parent
5e24adbb90
commit
c7214fe355
@ -1491,7 +1491,7 @@ static void ReportException(Environment* env, const TryCatch& try_catch) {
|
||||
// Executes a str within the current v8 context.
|
||||
static Local<Value> ExecuteString(Environment* env,
|
||||
Handle<String> source,
|
||||
Handle<Value> filename) {
|
||||
Handle<String> filename) {
|
||||
EscapableHandleScope scope(env->isolate());
|
||||
TryCatch try_catch;
|
||||
|
||||
|
@ -51,8 +51,11 @@ using v8::ObjectTemplate;
|
||||
using v8::Persistent;
|
||||
using v8::PropertyCallbackInfo;
|
||||
using v8::Script;
|
||||
using v8::ScriptCompiler;
|
||||
using v8::ScriptOrigin;
|
||||
using v8::String;
|
||||
using v8::TryCatch;
|
||||
using v8::UnboundScript;
|
||||
using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackData;
|
||||
@ -430,7 +433,7 @@ class ContextifyContext {
|
||||
|
||||
class ContextifyScript : public BaseObject {
|
||||
private:
|
||||
Persistent<Script> script_;
|
||||
Persistent<UnboundScript> script_;
|
||||
|
||||
public:
|
||||
static void Init(Environment* env, Local<Object> target) {
|
||||
@ -473,10 +476,10 @@ class ContextifyScript : public BaseObject {
|
||||
return;
|
||||
}
|
||||
|
||||
Local<Context> context = env->context();
|
||||
Context::Scope context_scope(context);
|
||||
|
||||
Local<Script> v8_script = Script::New(code, filename);
|
||||
ScriptOrigin origin(filename);
|
||||
ScriptCompiler::Source source(code, origin);
|
||||
Local<UnboundScript> v8_script =
|
||||
ScriptCompiler::CompileUnbound(env->isolate(), &source);
|
||||
|
||||
if (v8_script.IsEmpty()) {
|
||||
if (display_errors) {
|
||||
@ -639,8 +642,9 @@ class ContextifyScript : public BaseObject {
|
||||
|
||||
ContextifyScript* wrapped_script =
|
||||
Unwrap<ContextifyScript>(args.This());
|
||||
Local<Script> script = PersistentToLocal(env->isolate(),
|
||||
wrapped_script->script_);
|
||||
Local<UnboundScript> unbound_script =
|
||||
PersistentToLocal(env->isolate(), wrapped_script->script_);
|
||||
Local<Script> script = unbound_script->BindToCurrentContext();
|
||||
|
||||
Local<Value> result;
|
||||
if (timeout != -1) {
|
||||
|
@ -45,5 +45,5 @@ p.stdout.on('data', function(data) {
|
||||
process.on('exit', function() {
|
||||
assert(/BEGIN CERT/.test(output));
|
||||
assert(/^\s+\^/m.test(output));
|
||||
assert(/Unexpected identifier/.test(output));
|
||||
assert(/Invalid left-hand side expression in prefix operation/.test(output));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user