| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/inspector/v8-regex.h" | 5 #include "src/inspector/v8-regex.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "src/inspector/string-util.h" | 9 #include "src/inspector/string-util.h" |
| 10 #include "src/inspector/v8-inspector-impl.h" | 10 #include "src/inspector/v8-inspector-impl.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 if (matchLength) *matchLength = 0; | 42 if (matchLength) *matchLength = 0; |
| 43 | 43 |
| 44 if (m_regex.IsEmpty() || string.isEmpty()) return -1; | 44 if (m_regex.IsEmpty() || string.isEmpty()) return -1; |
| 45 | 45 |
| 46 // v8 strings are limited to int. | 46 // v8 strings are limited to int. |
| 47 if (string.length() > INT_MAX) return -1; | 47 if (string.length() > INT_MAX) return -1; |
| 48 | 48 |
| 49 v8::Isolate* isolate = m_inspector->isolate(); | 49 v8::Isolate* isolate = m_inspector->isolate(); |
| 50 v8::HandleScope handleScope(isolate); | 50 v8::HandleScope handleScope(isolate); |
| 51 v8::Local<v8::Context> context = m_inspector->regexContext(); | 51 v8::Local<v8::Context> context = m_inspector->regexContext(); |
| 52 v8::Context::Scope contextScope(context); |
| 52 v8::MicrotasksScope microtasks(isolate, | 53 v8::MicrotasksScope microtasks(isolate, |
| 53 v8::MicrotasksScope::kDoNotRunMicrotasks); | 54 v8::MicrotasksScope::kDoNotRunMicrotasks); |
| 54 v8::TryCatch tryCatch(isolate); | 55 v8::TryCatch tryCatch(isolate); |
| 55 | 56 |
| 56 v8::Local<v8::RegExp> regex = m_regex.Get(isolate); | 57 v8::Local<v8::RegExp> regex = m_regex.Get(isolate); |
| 57 v8::Local<v8::Value> exec; | 58 v8::Local<v8::Value> exec; |
| 58 if (!regex->Get(context, toV8StringInternalized(isolate, "exec")) | 59 if (!regex->Get(context, toV8StringInternalized(isolate, "exec")) |
| 59 .ToLocal(&exec)) | 60 .ToLocal(&exec)) |
| 60 return -1; | 61 return -1; |
| 61 v8::Local<v8::Value> argv[] = { | 62 v8::Local<v8::Value> argv[] = { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 84 if (matchLength) { | 85 if (matchLength) { |
| 85 v8::Local<v8::Value> match; | 86 v8::Local<v8::Value> match; |
| 86 if (!result->Get(context, 0).ToLocal(&match)) return -1; | 87 if (!result->Get(context, 0).ToLocal(&match)) return -1; |
| 87 *matchLength = match.As<v8::String>()->Length(); | 88 *matchLength = match.As<v8::String>()->Length(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 return matchOffset.As<v8::Int32>()->Value() + startFrom; | 91 return matchOffset.As<v8::Int32>()->Value() + startFrom; |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace v8_inspector | 94 } // namespace v8_inspector |
| OLD | NEW |