OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 "platform/v8_inspector/V8Regex.h" | 5 #include "platform/v8_inspector/V8Regex.h" |
6 | 6 |
7 #include "platform/v8_inspector/V8Compat.h" | 7 #include "platform/v8_inspector/V8Compat.h" |
8 #include "platform/v8_inspector/V8DebuggerImpl.h" | 8 #include "platform/v8_inspector/V8DebuggerImpl.h" |
9 #include "platform/v8_inspector/V8StringUtil.h" | 9 #include "platform/v8_inspector/V8StringUtil.h" |
10 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 10 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 unsigned flags = v8::RegExp::kNone; | 23 unsigned flags = v8::RegExp::kNone; |
24 if (!caseSensitive) | 24 if (!caseSensitive) |
25 flags |= v8::RegExp::kIgnoreCase; | 25 flags |= v8::RegExp::kIgnoreCase; |
26 if (multiline) | 26 if (multiline) |
27 flags |= v8::RegExp::kMultiline; | 27 flags |= v8::RegExp::kMultiline; |
28 | 28 |
29 v8::Local<v8::RegExp> regex; | 29 v8::Local<v8::RegExp> regex; |
30 if (v8::RegExp::New(context, toV8String(isolate, pattern), static_cast<v8::R
egExp::Flags>(flags)).ToLocal(®ex)) | 30 if (v8::RegExp::New(context, toV8String(isolate, pattern), static_cast<v8::R
egExp::Flags>(flags)).ToLocal(®ex)) |
31 m_regex.Reset(isolate, regex); | 31 m_regex.Reset(isolate, regex); |
| 32 else if (tryCatch.HasCaught()) |
| 33 m_errorMessage = toProtocolString(tryCatch.Message()->Get()); |
| 34 else |
| 35 m_errorMessage = "Internal error"; |
32 } | 36 } |
33 | 37 |
34 int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons
t | 38 int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons
t |
35 { | 39 { |
36 if (matchLength) | 40 if (matchLength) |
37 *matchLength = 0; | 41 *matchLength = 0; |
38 | 42 |
39 if (m_regex.IsEmpty() || string.isEmpty()) | 43 if (m_regex.IsEmpty() || string.isEmpty()) |
40 return -1; | 44 return -1; |
41 | 45 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 v8::Local<v8::Value> match; | 81 v8::Local<v8::Value> match; |
78 if (!result->Get(context, 0).ToLocal(&match)) | 82 if (!result->Get(context, 0).ToLocal(&match)) |
79 return -1; | 83 return -1; |
80 *matchLength = match.As<v8::String>()->Length(); | 84 *matchLength = match.As<v8::String>()->Length(); |
81 } | 85 } |
82 | 86 |
83 return matchOffset.As<v8::Int32>()->Value() + startFrom; | 87 return matchOffset.As<v8::Int32>()->Value() + startFrom; |
84 } | 88 } |
85 | 89 |
86 } // namespace blink | 90 } // namespace blink |
OLD | NEW |