Skip to content

Commit 023c317

Browse files
targosAli Sheikh
authored and
Ali Sheikh
committed
src: replace usage of deprecated Compile
PR-URL: #5159 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 79d7475 commit 023c317

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/node.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ using v8::Integer;
115115
using v8::Isolate;
116116
using v8::Local;
117117
using v8::Locker;
118+
using v8::MaybeLocal;
118119
using v8::Message;
119120
using v8::Number;
120121
using v8::Object;
121122
using v8::ObjectTemplate;
122123
using v8::Promise;
123124
using v8::PromiseRejectMessage;
124125
using v8::PropertyCallbackInfo;
126+
using v8::ScriptOrigin;
125127
using v8::SealHandleScope;
126128
using v8::StackFrame;
127129
using v8::StackTrace;
@@ -1610,13 +1612,15 @@ static Local<Value> ExecuteString(Environment* env,
16101612
// we will handle exceptions ourself.
16111613
try_catch.SetVerbose(false);
16121614

1613-
Local<v8::Script> script = v8::Script::Compile(source, filename);
1615+
ScriptOrigin origin(filename);
1616+
MaybeLocal<v8::Script> script =
1617+
v8::Script::Compile(env->context(), source, &origin);
16141618
if (script.IsEmpty()) {
16151619
ReportException(env, try_catch);
16161620
exit(3);
16171621
}
16181622

1619-
Local<Value> result = script->Run();
1623+
Local<Value> result = script.ToLocalChecked()->Run();
16201624
if (result.IsEmpty()) {
16211625
ReportException(env, try_catch);
16221626
exit(4);

src/node_contextify.cc

+4-5
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
}
@@ -262,10 +261,10 @@ class ContextifyContext {
262261
}
263262

264263
Context::Scope context_scope(debug_context);
265-
Local<Script> script = Script::Compile(script_source);
264+
MaybeLocal<Script> script = Script::Compile(debug_context, script_source);
266265
if (script.IsEmpty())
267266
return; // Exception pending.
268-
args.GetReturnValue().Set(script->Run());
267+
args.GetReturnValue().Set(script.ToLocalChecked()->Run());
269268
}
270269

271270

0 commit comments

Comments
 (0)