History

Fixed evaluateInClosure and other V8 stuff

ksuprynowicz committed 3 years ago

Commit 70d4a431 parent cc20ced8 files · +378 −191Browse files

Showing the changes to libraries/script-engine/src/v8/ScriptProgramV8Wrapper.cpp (1 of 8 files). Show all

Unified · Split

libraries/script-engine/src/v8/ScriptProgramV8Wrapper.cpp+8−0
@@ -32,7 +32,14 @@ ScriptSyntaxCheckResultPointer ScriptProgramV8Wrapper::checkSyntax() { · 31 unmodified lines
3232 }
3333
3434 bool ScriptProgramV8Wrapper::compile() {
35+ if (_isCompiled) {
36+ // V8TODO is there a case where source code changes later and needs to be compiled again?
37+ // V8TODO is same program used from multiple isolates
38+ return true;
39+ }
3540 auto isolate = _engine->getIsolate();
41+ v8::Locker locker(isolate);
42+ v8::Isolate::Scope isolateScope(isolate);
3643 v8::HandleScope handleScope(isolate);
3744 auto context = _engine->getContext();
3845 v8::Context::Scope contextScope(context);
@@ -48,6 +55,7 @@ bool ScriptProgramV8Wrapper::compile() { · 9 unmodified lines
4855 qDebug() << "Script compilation succesful: " << _url;
4956 _compileResult = ScriptSyntaxCheckResultV8Wrapper(ScriptSyntaxCheckResult::Valid);
5057 _value = V8ScriptProgram(isolate, script);
58+ _isCompiled = true;
5159 return true;
5260 }
5361 qDebug() << "Script compilation failed: " << _url;