OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 | 607 |
608 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 608 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
609 { | 609 { |
610 if (!m_debuggerScript.IsEmpty()) | 610 if (!m_debuggerScript.IsEmpty()) |
611 return; | 611 return; |
612 | 612 |
613 v8::HandleScope scope(m_isolate); | 613 v8::HandleScope scope(m_isolate); |
614 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 614 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
615 const blink::WebData& debuggerScriptSourceResource = blink::Platform::curren t()->loadResource("DebuggerScriptSource.js"); | 615 const blink::WebData& debuggerScriptSourceResource = blink::Platform::curren t()->loadResource("DebuggerScriptSource.js"); |
616 v8::Handle<v8::String> source = v8String(m_isolate, String(debuggerScriptSou rceResource.data(), debuggerScriptSourceResource.size())); | 616 v8::Handle<v8::String> source = v8String(m_isolate, String(debuggerScriptSou rceResource.data(), debuggerScriptSourceResource.size())); |
617 v8::Local<v8::Value> value = V8ScriptRunner::compileAndRunInternalScript(sou rce, m_isolate); | 617 v8::Local<v8::Value> value; |
618 ASSERT(!value.IsEmpty()); | 618 if (!V8ScriptRunner::compileAndRunInternalScript(source, m_isolate).ToLocal( &value)) |
619 ASSERT_NOT_REACHED(); | |
dcarney
2015/03/13 08:15:45
In cases like this you want ToLocalChecked instead
bashi
2015/03/17 02:01:36
Done. Please add DCHECK() in ToLocalChecked.
| |
619 ASSERT(value->IsObject()); | 620 ASSERT(value->IsObject()); |
620 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); | 621 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); |
621 } | 622 } |
622 | 623 |
623 void ScriptDebugServer::discardDebuggerScript() | 624 void ScriptDebugServer::discardDebuggerScript() |
624 { | 625 { |
625 ASSERT(!m_debuggerScript.IsEmpty()); | 626 ASSERT(!m_debuggerScript.IsEmpty()); |
626 m_debuggerScript.Reset(); | 627 m_debuggerScript.Reset(); |
627 } | 628 } |
628 | 629 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 } | 691 } |
691 | 692 |
692 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex pression, const String& sourceURL, bool persistScript, String* scriptId, String* exceptionDetailsText, int* lineNumber, int* columnNumber, RefPtrWillBeRawPtr<Sc riptCallStack>* stackTrace) | 693 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex pression, const String& sourceURL, bool persistScript, String* scriptId, String* exceptionDetailsText, int* lineNumber, int* columnNumber, RefPtrWillBeRawPtr<Sc riptCallStack>* stackTrace) |
693 { | 694 { |
694 if (!scriptState->contextIsValid()) | 695 if (!scriptState->contextIsValid()) |
695 return; | 696 return; |
696 ScriptState::Scope scope(scriptState); | 697 ScriptState::Scope scope(scriptState); |
697 | 698 |
698 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 699 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
699 v8::TryCatch tryCatch; | 700 v8::TryCatch tryCatch; |
700 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU RL, String(), TextPosition(), m_isolate); | 701 v8::Local<v8::Script> script; |
701 if (tryCatch.HasCaught()) { | 702 if (!V8ScriptRunner::compileScript(source, sourceURL, String(), TextPosition (), m_isolate).ToLocal(&script)) { |
702 v8::Local<v8::Message> message = tryCatch.Message(); | 703 if (tryCatch.HasCaught()) { |
703 if (!message.IsEmpty()) { | 704 v8::Local<v8::Message> message = tryCatch.Message(); |
704 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message ->Get()); | 705 if (!message.IsEmpty()) { |
705 *lineNumber = message->GetLineNumber(); | 706 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(mes sage->Get()); |
706 *columnNumber = message->GetStartColumn(); | 707 *lineNumber = message->GetLineNumber(); |
707 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac e(); | 708 *columnNumber = message->GetStartColumn(); |
708 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount () > 0) | 709 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStack Trace(); |
709 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace , messageStackTrace->GetFrameCount()); | 710 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameC ount() > 0) |
711 *stackTrace = createScriptCallStack(m_isolate, messageStackT race, messageStackTrace->GetFrameCount()); | |
712 } | |
710 } | 713 } |
711 return; | 714 return; |
712 } | 715 } |
713 if (script.IsEmpty() || !persistScript) | 716 if (!persistScript) |
714 return; | 717 return; |
715 | 718 |
716 *scriptId = String::number(script->GetUnboundScript()->GetId()); | 719 *scriptId = String::number(script->GetUnboundScript()->GetId()); |
717 m_compiledScripts.Set(*scriptId, script); | 720 m_compiledScripts.Set(*scriptId, script); |
718 } | 721 } |
719 | 722 |
720 void ScriptDebugServer::clearCompiledScripts() | 723 void ScriptDebugServer::clearCompiledScripts() |
721 { | 724 { |
722 m_compiledScripts.Clear(); | 725 m_compiledScripts.Clear(); |
723 } | 726 } |
724 | 727 |
725 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) | 728 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) |
726 { | 729 { |
727 if (!m_compiledScripts.Contains(scriptId)) | 730 if (!m_compiledScripts.Contains(scriptId)) |
728 return; | 731 return; |
729 v8::HandleScope handleScope(m_isolate); | 732 v8::HandleScope handleScope(m_isolate); |
730 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi ledScripts.Remove(scriptId)); | 733 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi ledScripts.Remove(scriptId)); |
731 if (script.IsEmpty()) | 734 if (script.IsEmpty()) |
732 return; | 735 return; |
733 | 736 |
734 if (!scriptState->contextIsValid()) | 737 if (!scriptState->contextIsValid()) |
735 return; | 738 return; |
736 ScriptState::Scope scope(scriptState); | 739 ScriptState::Scope scope(scriptState); |
737 v8::TryCatch tryCatch; | 740 v8::TryCatch tryCatch; |
738 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(m_isolate, sc ript, scriptState->executionContext()); | 741 v8::Local<v8::Value> value; |
739 *wasThrown = false; | 742 *wasThrown = false; |
743 if (V8ScriptRunner::runCompiledScript(m_isolate, script, scriptState->execut ionContext()).ToLocal(&value)) { | |
744 *result = ScriptValue(scriptState, value); | |
745 return; | |
746 } | |
740 if (tryCatch.HasCaught()) { | 747 if (tryCatch.HasCaught()) { |
741 *wasThrown = true; | 748 *wasThrown = true; |
742 *result = ScriptValue(scriptState, tryCatch.Exception()); | 749 *result = ScriptValue(scriptState, tryCatch.Exception()); |
743 v8::Local<v8::Message> message = tryCatch.Message(); | 750 v8::Local<v8::Message> message = tryCatch.Message(); |
744 if (!message.IsEmpty()) { | 751 if (!message.IsEmpty()) { |
745 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message ->Get()); | 752 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message ->Get()); |
746 *lineNumber = message->GetLineNumber(); | 753 *lineNumber = message->GetLineNumber(); |
747 *columnNumber = message->GetStartColumn(); | 754 *columnNumber = message->GetStartColumn(); |
748 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac e(); | 755 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac e(); |
749 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount () > 0) | 756 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount () > 0) |
750 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace , messageStackTrace->GetFrameCount()); | 757 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace , messageStackTrace->GetFrameCount()); |
751 } | 758 } |
752 } else { | |
753 *result = ScriptValue(scriptState, value); | |
754 } | 759 } |
755 } | 760 } |
756 | 761 |
757 } // namespace blink | 762 } // namespace blink |
OLD | NEW |