| 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 = V8ScriptRunner::compileAndRunInternalScript(sou
rce, m_isolate).ToLocalChecked(); |
| 618 ASSERT(!value.IsEmpty()); | |
| 619 ASSERT(value->IsObject()); | 618 ASSERT(value->IsObject()); |
| 620 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); | 619 m_debuggerScript.Reset(m_isolate, v8::Handle<v8::Object>::Cast(value)); |
| 621 } | 620 } |
| 622 | 621 |
| 623 void ScriptDebugServer::discardDebuggerScript() | 622 void ScriptDebugServer::discardDebuggerScript() |
| 624 { | 623 { |
| 625 ASSERT(!m_debuggerScript.IsEmpty()); | 624 ASSERT(!m_debuggerScript.IsEmpty()); |
| 626 m_debuggerScript.Reset(); | 625 m_debuggerScript.Reset(); |
| 627 } | 626 } |
| 628 | 627 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 689 } |
| 691 | 690 |
| 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) | 691 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 { | 692 { |
| 694 if (!scriptState->contextIsValid()) | 693 if (!scriptState->contextIsValid()) |
| 695 return; | 694 return; |
| 696 ScriptState::Scope scope(scriptState); | 695 ScriptState::Scope scope(scriptState); |
| 697 | 696 |
| 698 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 697 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
| 699 v8::TryCatch tryCatch; | 698 v8::TryCatch tryCatch; |
| 700 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, String(), TextPosition(), m_isolate); | 699 v8::Local<v8::Script> script; |
| 701 if (tryCatch.HasCaught()) { | 700 if (!v8Call(V8ScriptRunner::compileScript(source, sourceURL, String(), TextP
osition(), m_isolate), script, tryCatch)) { |
| 702 v8::Local<v8::Message> message = tryCatch.Message(); | 701 v8::Local<v8::Message> message = tryCatch.Message(); |
| 703 if (!message.IsEmpty()) { | 702 if (!message.IsEmpty()) { |
| 704 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); | 703 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
| 705 *lineNumber = message->GetLineNumber(); | 704 *lineNumber = message->GetLineNumber(); |
| 706 *columnNumber = message->GetStartColumn(); | 705 *columnNumber = message->GetStartColumn(); |
| 707 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); | 706 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); |
| 708 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) | 707 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) |
| 709 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); | 708 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); |
| 710 } | 709 } |
| 711 return; | 710 return; |
| 712 } | 711 } |
| 713 if (script.IsEmpty() || !persistScript) | 712 if (!persistScript) |
| 714 return; | 713 return; |
| 715 | 714 |
| 716 *scriptId = String::number(script->GetUnboundScript()->GetId()); | 715 *scriptId = String::number(script->GetUnboundScript()->GetId()); |
| 717 m_compiledScripts.Set(*scriptId, script); | 716 m_compiledScripts.Set(*scriptId, script); |
| 718 } | 717 } |
| 719 | 718 |
| 720 void ScriptDebugServer::clearCompiledScripts() | 719 void ScriptDebugServer::clearCompiledScripts() |
| 721 { | 720 { |
| 722 m_compiledScripts.Clear(); | 721 m_compiledScripts.Clear(); |
| 723 } | 722 } |
| 724 | 723 |
| 725 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) | 724 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) |
| 726 { | 725 { |
| 727 if (!m_compiledScripts.Contains(scriptId)) | 726 if (!m_compiledScripts.Contains(scriptId)) |
| 728 return; | 727 return; |
| 729 v8::HandleScope handleScope(m_isolate); | 728 v8::HandleScope handleScope(m_isolate); |
| 730 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi
ledScripts.Remove(scriptId)); | 729 v8::Local<v8::Script> script = v8::Local<v8::Script>::New(m_isolate, m_compi
ledScripts.Remove(scriptId)); |
| 731 if (script.IsEmpty()) | 730 if (script.IsEmpty()) |
| 732 return; | 731 return; |
| 733 | 732 |
| 734 if (!scriptState->contextIsValid()) | 733 if (!scriptState->contextIsValid()) |
| 735 return; | 734 return; |
| 736 ScriptState::Scope scope(scriptState); | 735 ScriptState::Scope scope(scriptState); |
| 737 v8::TryCatch tryCatch; | 736 v8::TryCatch tryCatch; |
| 738 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(m_isolate, sc
ript, scriptState->executionContext()); | 737 v8::Local<v8::Value> value; |
| 739 *wasThrown = false; | 738 *wasThrown = false; |
| 740 if (tryCatch.HasCaught()) { | 739 if (!V8ScriptRunner::runCompiledScript(m_isolate, script, scriptState->execu
tionContext()).ToLocal(&value)) { |
| 740 *result = ScriptValue(scriptState, value); |
| 741 } else { |
| 742 if (!tryCatch.HasCaught()) |
| 743 return; |
| 741 *wasThrown = true; | 744 *wasThrown = true; |
| 742 *result = ScriptValue(scriptState, tryCatch.Exception()); | 745 *result = ScriptValue(scriptState, tryCatch.Exception()); |
| 743 v8::Local<v8::Message> message = tryCatch.Message(); | 746 v8::Local<v8::Message> message = tryCatch.Message(); |
| 744 if (!message.IsEmpty()) { | 747 if (!message.IsEmpty()) { |
| 745 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); | 748 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
| 746 *lineNumber = message->GetLineNumber(); | 749 *lineNumber = message->GetLineNumber(); |
| 747 *columnNumber = message->GetStartColumn(); | 750 *columnNumber = message->GetStartColumn(); |
| 748 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); | 751 v8::Handle<v8::StackTrace> messageStackTrace = message->GetStackTrac
e(); |
| 749 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) | 752 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount
() > 0) |
| 750 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); | 753 *stackTrace = createScriptCallStack(m_isolate, messageStackTrace
, messageStackTrace->GetFrameCount()); |
| 751 } | 754 } |
| 752 } else { | |
| 753 *result = ScriptValue(scriptState, value); | |
| 754 } | 755 } |
| 755 } | 756 } |
| 756 | 757 |
| 757 } // namespace blink | 758 } // namespace blink |
| OLD | NEW |