OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 { | 176 { |
177 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page()
; | 177 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page()
; |
178 if (!page || !instrumentationForPage(page)->inspectorDebuggerAgent()) | 178 if (!page || !instrumentationForPage(page)->inspectorDebuggerAgent()) |
179 return; | 179 return; |
180 | 180 |
181 V8Scope v8Scope(v8::Debug::GetDebugContext()); | 181 V8Scope v8Scope(v8::Debug::GetDebugContext()); |
182 | 182 |
183 ASSERT(Dart_CurrentIsolate()); | 183 ASSERT(Dart_CurrentIsolate()); |
184 int isolateHandle = isolateMap().getByValue(Dart_CurrentIsolate()); | 184 int isolateHandle = isolateMap().getByValue(Dart_CurrentIsolate()); |
185 | 185 |
| 186 ScriptState* scriptState = ScriptState::current(); |
| 187 Frame* frame = DartUtilities::domWindowForCurrentIsolate()->frame(); |
| 188 DartController* controller = DartController::retrieve(frame); |
| 189 Vector<ScriptState*> scriptStates; |
| 190 controller->collectScriptStatesForIsolate(Dart_CurrentIsolate(), DartUtiliti
es::currentV8Context(), scriptStates); |
| 191 for (size_t i = 0; i< scriptStates.size(); i++) |
| 192 InspectorInstrumentation::didCreateIsolatedContext(frame, scriptStates[i
], 0); |
| 193 |
186 ASSERT(!m_dartDebugObject.isEmpty()); | 194 ASSERT(!m_dartDebugObject.isEmpty()); |
187 v8::Local<v8::Function> isolateLoaded = v8::Local<v8::Function>::Cast(dartDe
bugObject()->Get(v8::String::New("isolateLoaded"))); | 195 v8::Local<v8::Function> isolateLoaded = v8::Local<v8::Function>::Cast(dartDe
bugObject()->Get(v8::String::New("isolateLoaded"))); |
188 v8::Handle<v8::Value> args[] = { v8::Number::New(isolateHandle) }; | 196 v8::Handle<v8::Value> args[] = { v8::Number::New(isolateHandle) }; |
189 isolateLoaded->Call(dartDebugObject(), 1, args); | 197 isolateLoaded->Call(dartDebugObject(), 1, args); |
190 } | 198 } |
191 | 199 |
192 void DartDebugServer::disable() | 200 void DartDebugServer::disable() |
193 { | 201 { |
194 V8Scope v8Scope(v8::Debug::GetDebugContext()); | 202 V8Scope v8Scope(v8::Debug::GetDebugContext()); |
195 // Only invoke the disable method when Dart code was executed on the page. | 203 // Only invoke the disable method when Dart code was executed on the page. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 { | 455 { |
448 Dart_SetStepOut(); | 456 Dart_SetStepOut(); |
449 } | 457 } |
450 | 458 |
451 static void evaluateInScope(const v8::FunctionCallbackInfo<v8::Value>& args) | 459 static void evaluateInScope(const v8::FunctionCallbackInfo<v8::Value>& args) |
452 { | 460 { |
453 v8::Handle<v8::String> expression = args[0]->ToString(); | 461 v8::Handle<v8::String> expression = args[0]->ToString(); |
454 v8::Handle<v8::Value> receiver = args[1]; | 462 v8::Handle<v8::Value> receiver = args[1]; |
455 v8::Handle<v8::Object> functionProxy = args[2].As<v8::Object>(); | 463 v8::Handle<v8::Object> functionProxy = args[2].As<v8::Object>(); |
456 v8::Handle<v8::Value> localVariablesProxy = args[3]; | 464 v8::Handle<v8::Value> localVariablesProxy = args[3]; |
| 465 bool disableBreak = args[4]->BooleanValue(); |
457 | 466 |
458 DartScopes scopes(functionProxy); | 467 DartScopes scopes(functionProxy, disableBreak); |
459 Dart_Handle target = 0; | 468 Dart_Handle target = 0; |
460 if (receiver->IsNull() || receiver->IsUndefined()) { | 469 if (receiver->IsNull() || receiver->IsUndefined()) { |
461 Dart_Handle functionHandle = scopes.handle; | 470 Dart_Handle functionHandle = scopes.handle; |
462 ASSERT(Dart_IsFunction(functionHandle)); | 471 ASSERT(Dart_IsFunction(functionHandle)); |
463 target = Dart_FunctionOwner(functionHandle); | 472 target = Dart_FunctionOwner(functionHandle); |
464 } else { | 473 } else { |
465 target = DartHandleProxy::unwrapValue(receiver); | 474 target = DartHandleProxy::unwrapValue(receiver); |
466 } | 475 } |
| 476 |
467 ASSERT(!Dart_IsError(target)); | 477 ASSERT(!Dart_IsError(target)); |
468 Dart_Handle localVariables = DartHandleProxy::unwrapValue(localVariablesProx
y); | 478 Dart_Handle localVariables = DartHandleProxy::unwrapValue(localVariablesProx
y); |
469 ASSERT(Dart_IsList(localVariables)); | |
470 intptr_t localVariablesLength = 0; | |
471 Dart_ListLength(localVariables, &localVariablesLength); | |
472 | 479 |
473 Dart_Handle wrapExpressionArgs[2] = { V8Converter::stringToDart(expression),
localVariables }; | 480 v8SetReturnValue(args, DartHandleProxy::evaluate(target, V8Converter::string
ToDart(expression), localVariables)); |
474 | |
475 Dart_Handle wrappedExpressionTuple = | |
476 DartUtilities::invokeUtilsMethod("wrapExpressionAsClosure", 2, wrapExpre
ssionArgs); | |
477 ASSERT(Dart_IsList(wrappedExpressionTuple)); | |
478 Dart_Handle wrappedExpression = Dart_ListGetAt(wrappedExpressionTuple, 0); | |
479 Dart_Handle wrappedExpressionArgs = Dart_ListGetAt(wrappedExpressionTuple, 1
); | |
480 | |
481 ASSERT(Dart_IsString(wrappedExpression)); | |
482 Dart_Handle closure = Dart_EvaluateExpr(target, wrappedExpression); | |
483 if (Dart_IsError(closure)) { | |
484 // There was a parse error. FIXME: consider cleaning up the line | |
485 // numbers in the error message. | |
486 V8ThrowException::throwError(v8::String::New(Dart_GetError(closure))); | |
487 } else { | |
488 // Invoke the closure passing in the expression arguments specified by | |
489 // wrappedExpressionTuple. | |
490 ASSERT(Dart_IsClosure(closure)); | |
491 intptr_t length = 0; | |
492 Dart_ListLength(wrappedExpressionArgs, &length); | |
493 Vector<Dart_Handle> dartFunctionArgs; | |
494 for (uint32_t i = 0; i < length; i ++) { | |
495 dartFunctionArgs.append(Dart_ListGetAt(wrappedExpressionArgs, i)); | |
496 } | |
497 | |
498 Dart_Handle result = Dart_InvokeClosure(closure, dartFunctionArgs.size()
, dartFunctionArgs.data()); | |
499 if (Dart_IsError(result)) { | |
500 V8ThrowException::throwError(v8::String::New(Dart_GetError(result)))
; | |
501 } else { | |
502 v8SetReturnValue(args, DartHandleProxy::create(result)); | |
503 } | |
504 } | |
505 } | 481 } |
506 | 482 |
507 void DartDebugServer::ensureHooksInstalled() | 483 void DartDebugServer::ensureHooksInstalled() |
508 { | 484 { |
509 DEFINE_STATIC_LOCAL(bool, hooksInstalled, (false)); | 485 DEFINE_STATIC_LOCAL(bool, hooksInstalled, (false)); |
510 | 486 |
511 if (hooksInstalled) | 487 if (hooksInstalled) |
512 return; | 488 return; |
513 | 489 |
514 hooksInstalled = true; | 490 hooksInstalled = true; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 525 } |
550 dartDebugObject()->Set(v8::String::New("nativeCallbacks"), nativeCallbacks); | 526 dartDebugObject()->Set(v8::String::New("nativeCallbacks"), nativeCallbacks); |
551 } | 527 } |
552 | 528 |
553 v8::Local<v8::Object> DartDebugServer::dartDebugObject() | 529 v8::Local<v8::Object> DartDebugServer::dartDebugObject() |
554 { | 530 { |
555 return m_dartDebugObject.newLocal(v8::Isolate::GetCurrent()); | 531 return m_dartDebugObject.newLocal(v8::Isolate::GetCurrent()); |
556 } | 532 } |
557 | 533 |
558 } | 534 } |
OLD | NEW |