| Index: Source/bindings/dart/DartHandleProxy.cpp
|
| diff --git a/Source/bindings/dart/DartHandleProxy.cpp b/Source/bindings/dart/DartHandleProxy.cpp
|
| index 9cc0ed0a4c4b5617f94635ba583ee4a6b75c739b..a17fb8d6e2a0c65037cc6692a76d267cc8a50743 100644
|
| --- a/Source/bindings/dart/DartHandleProxy.cpp
|
| +++ b/Source/bindings/dart/DartHandleProxy.cpp
|
| @@ -58,22 +58,24 @@ DartScriptValue* readPointerFromProxy(v8::Handle<v8::Value> proxy)
|
| return static_cast<DartScriptValue*>(pointer);
|
| }
|
|
|
| -DartScopes::DartScopes(v8::Local<v8::Object> v8Handle) :
|
| +DartScopes::DartScopes(v8::Local<v8::Object> v8Handle, bool disableBreak) :
|
| scriptValue(readPointerFromProxy(v8Handle)),
|
| - scope(scriptValue->isolate())
|
| + scope(scriptValue->isolate()),
|
| + disableBreak(disableBreak)
|
| {
|
| ASSERT(scriptValue->isIsolateAlive());
|
| handle = scriptValue->value();
|
| - previousPauseInfo = Dart_GetExceptionPauseInfo();
|
| - // FIXME: it is not clear this is the right long term solution but for
|
| - // now we prevent pausing on exceptions when executing Dart code to
|
| - // avoid crashing when handling an exception triggers an exception.
|
| - Dart_SetExceptionPauseInfo(kNoPauseOnExceptions);
|
| + if (disableBreak) {
|
| + previousPauseInfo = Dart_GetExceptionPauseInfo();
|
| + Dart_SetExceptionPauseInfo(kNoPauseOnExceptions);
|
| + }
|
| }
|
|
|
| DartScopes::~DartScopes()
|
| {
|
| - Dart_SetExceptionPauseInfo(previousPauseInfo);
|
| + if (disableBreak) {
|
| + Dart_SetExceptionPauseInfo(previousPauseInfo);
|
| + }
|
| }
|
|
|
|
|
| @@ -1085,4 +1087,52 @@ v8::Handle<v8::Value> DartHandleProxy::createLocalScopeProxy(Dart_Handle localVa
|
| return proxy;
|
| }
|
|
|
| +v8::Handle<v8::Value> DartHandleProxy::evaluate(Dart_Handle target, Dart_Handle expression, Dart_Handle localVariables)
|
| +{
|
| + ASSERT(Dart_IsList(localVariables) || Dart_IsNull(localVariables));
|
| + intptr_t localVariablesLength = 0;
|
| + Dart_ListLength(localVariables, &localVariablesLength);
|
| +
|
| + Dart_Handle wrapExpressionArgs[2] = { expression, localVariables };
|
| + Dart_Handle exception = 0;
|
| + bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isJsExpression", 1, &expression), exception);
|
| + ASSERT(!exception);
|
| + if (ret) {
|
| + // FIXME(dartbug.com/13468): remove this hacky fallback of invoking JS
|
| + // code when we believe a JS code fragment generated by the chrome
|
| + // developer tools was passed to us rather than a fragment of true
|
| + // Dart code.
|
| + ASSERT(!v8::Context::GetCurrent().IsEmpty());
|
| + v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(V8Converter::stringToV8(expression), v8::Isolate::GetCurrent());
|
| + return result;
|
| + }
|
| +
|
| + Dart_Handle wrappedExpressionTuple =
|
| + DartUtilities::invokeUtilsMethod("wrapExpressionAsClosure", 2, wrapExpressionArgs);
|
| + ASSERT(Dart_IsList(wrappedExpressionTuple));
|
| + Dart_Handle wrappedExpression = Dart_ListGetAt(wrappedExpressionTuple, 0);
|
| + Dart_Handle wrappedExpressionArgs = Dart_ListGetAt(wrappedExpressionTuple, 1);
|
| +
|
| + ASSERT(Dart_IsString(wrappedExpression));
|
| + Dart_Handle closure = Dart_EvaluateExpr(target, wrappedExpression);
|
| + // There was a parse error. FIXME: consider cleaning up the line numbers in
|
| + // the error message.
|
| + if (Dart_IsError(closure))
|
| + return V8ThrowException::throwError(v8::String::New(Dart_GetError(closure)));
|
| +
|
| + // Invoke the closure passing in the expression arguments specified by
|
| + // wrappedExpressionTuple.
|
| + ASSERT(Dart_IsClosure(closure));
|
| + intptr_t length = 0;
|
| + Dart_ListLength(wrappedExpressionArgs, &length);
|
| + Vector<Dart_Handle> dartFunctionArgs;
|
| + for (uint32_t i = 0; i < length; i ++)
|
| + dartFunctionArgs.append(Dart_ListGetAt(wrappedExpressionArgs, i));
|
| +
|
| + Dart_Handle result = Dart_InvokeClosure(closure, dartFunctionArgs.size(), dartFunctionArgs.data());
|
| + if (Dart_IsError(result))
|
| + return V8ThrowException::throwError(v8::String::New(Dart_GetError(result)));
|
| + return DartHandleProxy::create(result);
|
| +}
|
| +
|
| }
|
|
|