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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 641 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
642 { | 642 { |
643 if (!m_debuggerScript.IsEmpty()) | 643 if (!m_debuggerScript.IsEmpty()) |
644 return; | 644 return; |
645 | 645 |
646 v8::HandleScope scope(m_isolate); | 646 v8::HandleScope scope(m_isolate); |
647 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 647 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
648 const blink::WebData& debuggerScriptSourceResource = blink::Platform::curren
t()->loadResource("DebuggerScriptSource.js"); | 648 const blink::WebData& debuggerScriptSourceResource = blink::Platform::curren
t()->loadResource("DebuggerScriptSource.js"); |
649 v8::Handle<v8::String> source = v8String(m_isolate, String(debuggerScriptSou
rceResource.data(), debuggerScriptSourceResource.size())); | 649 v8::Handle<v8::String> source = v8String(m_isolate, String(debuggerScriptSou
rceResource.data(), debuggerScriptSourceResource.size())); |
650 v8::Local<v8::Value> value = V8ScriptRunner::compileAndRunInternalScript(sou
rce, m_isolate); | 650 v8::Local<v8::Value> value; |
651 ASSERT(!value.IsEmpty()); | 651 if (!V8ScriptRunner::compileAndRunInternalScript(source, m_isolate).ToLocal(
&value)) |
| 652 return; |
652 ASSERT(value->IsObject()); | 653 ASSERT(value->IsObject()); |
653 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); | 654 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); |
654 } | 655 } |
655 | 656 |
656 void ScriptDebugServer::discardDebuggerScript() | 657 void ScriptDebugServer::discardDebuggerScript() |
657 { | 658 { |
658 ASSERT(!m_debuggerScript.IsEmpty()); | 659 ASSERT(!m_debuggerScript.IsEmpty()); |
659 m_debuggerScript.Reset(); | 660 m_debuggerScript.Reset(); |
660 } | 661 } |
661 | 662 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 724 } |
724 | 725 |
725 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) | 726 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) |
726 { | 727 { |
727 if (!scriptState->contextIsValid()) | 728 if (!scriptState->contextIsValid()) |
728 return; | 729 return; |
729 ScriptState::Scope scope(scriptState); | 730 ScriptState::Scope scope(scriptState); |
730 | 731 |
731 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 732 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
732 v8::TryCatch tryCatch; | 733 v8::TryCatch tryCatch; |
733 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, String(), TextPosition(), m_isolate); | 734 v8::Local<v8::Script> script; |
734 if (tryCatch.HasCaught()) { | 735 if (!v8Call(V8ScriptRunner::compileScript(source, sourceURL, String(), TextP
osition(), m_isolate), script, tryCatch)) { |
735 v8::Local<v8::Message> message = tryCatch.Message(); | 736 v8::Local<v8::Message> message = tryCatch.Message(); |
736 if (!message.IsEmpty()) { | 737 if (!message.IsEmpty()) { |
737 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); | 738 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
738 *lineNumber = message->GetLineNumber(); | 739 *lineNumber = message->GetLineNumber(); |
739 *columnNumber = message->GetStartColumn(); | 740 *columnNumber = message->GetStartColumn(); |
740 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); | 741 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); |
741 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) | 742 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) |
742 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); | 743 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); |
743 } | 744 } |
744 return; | 745 return; |
745 } | 746 } |
746 if (script.IsEmpty() || !persistScript) | 747 if (!persistScript) |
747 return; | 748 return; |
748 | 749 |
749 *scriptId = String::number(script->GetUnboundScript()->GetId()); | 750 *scriptId = String::number(script->GetUnboundScript()->GetId()); |
750 m_compiledScripts.Set(*scriptId, script); | 751 m_compiledScripts.Set(*scriptId, script); |
751 } | 752 } |
752 | 753 |
753 void ScriptDebugServer::clearCompiledScripts() | 754 void ScriptDebugServer::clearCompiledScripts() |
754 { | 755 { |
755 m_compiledScripts.Clear(); | 756 m_compiledScripts.Clear(); |
756 } | 757 } |
757 | 758 |
758 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) | 759 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) |
759 { | 760 { |
760 if (!m_compiledScripts.Contains(scriptId)) | 761 if (!m_compiledScripts.Contains(scriptId)) |
761 return; | 762 return; |
762 v8::HandleScope handleScope(m_isolate); | 763 v8::HandleScope handleScope(m_isolate); |
763 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi
ledScripts.Remove(scriptId)); | 764 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi
ledScripts.Remove(scriptId)); |
764 if (script.IsEmpty()) | 765 if (script.IsEmpty()) |
765 return; | 766 return; |
766 | 767 |
767 if (!scriptState->contextIsValid()) | 768 if (!scriptState->contextIsValid()) |
768 return; | 769 return; |
769 ScriptState::Scope scope(scriptState); | 770 ScriptState::Scope scope(scriptState); |
770 v8::TryCatch tryCatch; | 771 v8::TryCatch tryCatch; |
771 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(m_isolate, sc
ript, scriptState->executionContext()); | 772 v8::Local<v8::Value> value; |
772 *wasThrown = false; | 773 *wasThrown = false; |
773 if (tryCatch.HasCaught()) { | 774 if (v8Call(V8ScriptRunner::runCompiledScript(m_isolate, script, scriptState-
>executionContext()), value, tryCatch)) { |
| 775 *result = ScriptValue(scriptState, value); |
| 776 } else { |
774 *wasThrown = true; | 777 *wasThrown = true; |
775 *result = ScriptValue(scriptState, tryCatch.Exception()); | 778 *result = ScriptValue(scriptState, tryCatch.Exception()); |
776 v8::Local<v8::Message> message = tryCatch.Message(); | 779 v8::Local<v8::Message> message = tryCatch.Message(); |
777 if (!message.IsEmpty()) { | 780 if (!message.IsEmpty()) { |
778 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); | 781 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
779 *lineNumber = message->GetLineNumber(); | 782 *lineNumber = message->GetLineNumber(); |
780 *columnNumber = message->GetStartColumn(); | 783 *columnNumber = message->GetStartColumn(); |
781 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); | 784 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); |
782 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) | 785 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) |
783 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); | 786 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); |
784 } | 787 } |
785 } else { | |
786 *result = ScriptValue(scriptState, value); | |
787 } | 788 } |
788 } | 789 } |
789 | 790 |
790 } // namespace blink | 791 } // namespace blink |
OLD | NEW |