Skip to content

Commit 653cea2

Browse files
committed
src: replace usage of deprecated Compile
PR-URL: #5159 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent b2d8ef1 commit 653cea2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/node.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ using v8::Integer;
114114
using v8::Isolate;
115115
using v8::Local;
116116
using v8::Locker;
117+
using v8::MaybeLocal;
117118
using v8::Message;
118119
using v8::Number;
119120
using v8::Object;
120121
using v8::ObjectTemplate;
121122
using v8::Promise;
122123
using v8::PromiseRejectMessage;
123124
using v8::PropertyCallbackInfo;
125+
using v8::ScriptOrigin;
124126
using v8::SealHandleScope;
125127
using v8::StackFrame;
126128
using v8::StackTrace;
@@ -1607,13 +1609,15 @@ static Local<Value> ExecuteString(Environment* env,
16071609
// we will handle exceptions ourself.
16081610
try_catch.SetVerbose(false);
16091611

1610-
Local<v8::Script> script = v8::Script::Compile(source, filename);
1612+
ScriptOrigin origin(filename);
1613+
MaybeLocal<v8::Script> script =
1614+
v8::Script::Compile(env->context(), source, &origin);
16111615
if (script.IsEmpty()) {
16121616
ReportException(env, try_catch);
16131617
exit(3);
16141618
}
16151619

1616-
Local<Value> result = script->Run();
1620+
Local<Value> result = script.ToLocalChecked()->Run();
16171621
if (result.IsEmpty()) {
16181622
ReportException(env, try_catch);
16191623
exit(4);

src/node_contextify.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ class ContextifyContext {
167167
" }\n"
168168
"})");
169169

170-
Local<String> fname = FIXED_ONE_BYTE_STRING(env()->isolate(),
171-
"binding:script");
172-
Local<Script> script = Script::Compile(code, fname);
170+
Local<Script> script =
171+
Script::Compile(context, code).ToLocalChecked();
173172
clone_property_method = Local<Function>::Cast(script->Run());
174173
CHECK(clone_property_method->IsFunction());
175174
}
@@ -263,10 +262,10 @@ class ContextifyContext {
263262
}
264263

265264
Context::Scope context_scope(debug_context);
266-
Local<Script> script = Script::Compile(script_source);
265+
MaybeLocal<Script> script = Script::Compile(debug_context, script_source);
267266
if (script.IsEmpty())
268267
return; // Exception pending.
269-
args.GetReturnValue().Set(script->Run());
268+
args.GetReturnValue().Set(script.ToLocalChecked()->Run());
270269
}
271270

272271

0 commit comments

Comments
 (0)