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/regexp/regexp-utils.h" | 5 #include "src/regexp/regexp-utils.h" |
6 | 6 |
7 #include "src/factory.h" | 7 #include "src/factory.h" |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/regexp/jsregexp.h" | 10 #include "src/regexp/jsregexp.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S ) | 65 // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S ) |
66 // Also takes an optional exec method in case our caller | 66 // Also takes an optional exec method in case our caller |
67 // has already fetched exec. | 67 // has already fetched exec. |
68 MaybeHandle<Object> RegExpUtils::RegExpExec(Isolate* isolate, | 68 MaybeHandle<Object> RegExpUtils::RegExpExec(Isolate* isolate, |
69 Handle<JSReceiver> regexp, | 69 Handle<JSReceiver> regexp, |
70 Handle<String> string, | 70 Handle<String> string, |
71 Handle<Object> exec) { | 71 Handle<Object> exec) { |
72 if (exec->IsUndefined(isolate)) { | 72 if (exec->IsUndefined(isolate)) { |
73 ASSIGN_RETURN_ON_EXCEPTION( | 73 ASSIGN_RETURN_ON_EXCEPTION( |
74 isolate, exec, | 74 isolate, exec, |
75 Object::GetProperty( | 75 Object::GetProperty(regexp, isolate->factory()->exec_string()), Object); |
76 regexp, isolate->factory()->NewStringFromAsciiChecked("exec")), | |
77 Object); | |
78 } | 76 } |
79 | 77 |
80 if (exec->IsCallable()) { | 78 if (exec->IsCallable()) { |
81 const int argc = 1; | 79 const int argc = 1; |
82 ScopedVector<Handle<Object>> argv(argc); | 80 ScopedVector<Handle<Object>> argv(argc); |
83 argv[0] = string; | 81 argv[0] = string; |
84 | 82 |
85 Handle<Object> result; | 83 Handle<Object> result; |
86 ASSIGN_RETURN_ON_EXCEPTION( | 84 ASSIGN_RETURN_ON_EXCEPTION( |
87 isolate, result, | 85 isolate, result, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 183 |
186 const int last_index = Handle<Smi>::cast(last_index_obj)->value(); | 184 const int last_index = Handle<Smi>::cast(last_index_obj)->value(); |
187 const int new_last_index = | 185 const int new_last_index = |
188 AdvanceStringIndex(isolate, string, last_index, unicode); | 186 AdvanceStringIndex(isolate, string, last_index, unicode); |
189 | 187 |
190 return SetLastIndex(isolate, regexp, new_last_index); | 188 return SetLastIndex(isolate, regexp, new_last_index); |
191 } | 189 } |
192 | 190 |
193 } // namespace internal | 191 } // namespace internal |
194 } // namespace v8 | 192 } // namespace v8 |
OLD | NEW |