Showing the changes to libraries/script-engine/src/v8/ScriptProgramV8Wrapper.cpp (1 of 10 files). Show all
Unified · Split
| @@ -32,29 +32,32 @@ ScriptSyntaxCheckResultPointer ScriptProgramV8Wrapper::checkSyntax() { · 31 unmodified lines | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | bool ScriptProgramV8Wrapper::compile() { | 34 | bool ScriptProgramV8Wrapper::compile() { |
| 35 | auto isolate = _engine->getIsolate(); | ||
| 36 | v8::HandleScope handleScope(isolate); | ||
| 37 | auto context = _engine->getContext(); | ||
| 35 | int errorColumnNumber = 0; | 38 | int errorColumnNumber = 0; |
| 36 | int errorLineNumber = 0; | 39 | int errorLineNumber = 0; |
| 37 | QString errorMessage = ""; | 40 | QString errorMessage = ""; |
| 38 | QString errorBacktrace = ""; | 41 | QString errorBacktrace = ""; |
| 39 | ScriptSyntaxCheckResult::State state; | 42 | ScriptSyntaxCheckResult::State state; |
| 40 | v8::TryCatch tryCatch(_engine->getIsolate()); | 43 | v8::TryCatch tryCatch(isolate); |
| 41 | v8::ScriptOrigin scriptOrigin(_engine->getIsolate(), v8::String::NewFromUtf8(_engine->getIsolate(), _url.toStdString().c_str()).ToLocalChecked()); | 44 | v8::ScriptOrigin scriptOrigin(isolate, v8::String::NewFromUtf8(isolate, _url.toStdString().c_str()).ToLocalChecked()); |
| 42 | v8::Local<v8::Script> script; | 45 | v8::Local<v8::Script> script; |
| 43 | if (v8::Script::Compile(_engine->getContext(), v8::String::NewFromUtf8(_engine->getIsolate(), _source.toStdString().c_str()).ToLocalChecked(), &scriptOrigin).ToLocal(&script)) { | 46 | if (v8::Script::Compile(context, v8::String::NewFromUtf8(isolate, _source.toStdString().c_str()).ToLocalChecked(), &scriptOrigin).ToLocal(&script)) { |
| 44 | _compileResult = ScriptSyntaxCheckResultV8Wrapper(ScriptSyntaxCheckResult::Valid); | 47 | _compileResult = ScriptSyntaxCheckResultV8Wrapper(ScriptSyntaxCheckResult::Valid); |
| 45 | _value = V8ScriptProgram(_engine->getIsolate(), script); | 48 | _value = V8ScriptProgram(isolate, script); |
| 46 | return true; | 49 | return true; |
| 47 | } | 50 | } |
| 48 | v8::String::Utf8Value utf8Value(_engine->getIsolate(), tryCatch.Exception()); | 51 | v8::String::Utf8Value utf8Value(isolate, tryCatch.Exception()); |
| 49 | errorMessage = QString(*utf8Value); | 52 | errorMessage = QString(*utf8Value); |
| 50 | v8::Local<v8::Message> exceptionMessage = tryCatch.Message(); | 53 | v8::Local<v8::Message> exceptionMessage = tryCatch.Message(); |
| 51 | if (!exceptionMessage.IsEmpty()) { | 54 | if (!exceptionMessage.IsEmpty()) { |
| 52 | errorLineNumber = exceptionMessage->GetLineNumber(_engine->getContext()).FromJust(); | 55 | errorLineNumber = exceptionMessage->GetLineNumber(context).FromJust(); |
| 53 | errorColumnNumber = exceptionMessage->GetStartColumn(_engine->getContext()).FromJust(); | 56 | errorColumnNumber = exceptionMessage->GetStartColumn(context).FromJust(); |
| 54 | v8::Local<v8::Value> backtraceV8String; | 57 | v8::Local<v8::Value> backtraceV8String; |
| 55 | if (tryCatch.StackTrace(_engine->getContext()).ToLocal(&backtraceV8String) && backtraceV8String->IsString() && | 58 | if (tryCatch.StackTrace(context).ToLocal(&backtraceV8String) && backtraceV8String->IsString() && |
| 56 | v8::Local<v8::String>::Cast(backtraceV8String)->Length() > 0) { | 59 | v8::Local<v8::String>::Cast(backtraceV8String)->Length() > 0) { |
| 57 | v8::String::Utf8Value backtraceUtf8Value(_engine->getIsolate(), backtraceV8String); | 60 | v8::String::Utf8Value backtraceUtf8Value(isolate, backtraceV8String); |
| 58 | errorBacktrace = *backtraceUtf8Value; | 61 | errorBacktrace = *backtraceUtf8Value; |
| 59 | } | 62 | } |
| 60 | } | 63 | } |