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/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/regexp/jsregexp.h" | 9 #include "src/regexp/jsregexp.h" |
10 #include "src/regexp/regexp-utils.h" | 10 #include "src/regexp/regexp-utils.h" |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 | 1283 |
1284 Factory* factory = isolate->factory(); | 1284 Factory* factory = isolate->factory(); |
1285 | 1285 |
1286 Handle<Object> string_obj = args.atOrUndefined(isolate, 1); | 1286 Handle<Object> string_obj = args.atOrUndefined(isolate, 1); |
1287 Handle<Object> limit_obj = args.atOrUndefined(isolate, 2); | 1287 Handle<Object> limit_obj = args.atOrUndefined(isolate, 2); |
1288 | 1288 |
1289 Handle<String> string; | 1289 Handle<String> string; |
1290 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string, | 1290 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string, |
1291 Object::ToString(isolate, string_obj)); | 1291 Object::ToString(isolate, string_obj)); |
1292 | 1292 |
1293 if (RegExpUtils::IsUnmodifiedRegExp(isolate, recv)) { | |
1294 RETURN_RESULT_OR_FAILURE( | |
1295 isolate, | |
1296 RegExpSplit(isolate, Handle<JSRegExp>::cast(recv), string, limit_obj)); | |
1297 } | |
1298 | |
1299 Handle<JSFunction> regexp_fun = isolate->regexp_function(); | 1293 Handle<JSFunction> regexp_fun = isolate->regexp_function(); |
1300 Handle<Object> ctor; | 1294 Handle<Object> ctor; |
1301 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1295 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1302 isolate, ctor, SpeciesConstructor(isolate, recv, regexp_fun)); | 1296 isolate, ctor, SpeciesConstructor(isolate, recv, regexp_fun)); |
1303 | 1297 |
| 1298 if (recv->IsJSRegExp() && *ctor == *regexp_fun) { |
| 1299 Handle<Object> exec; |
| 1300 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1301 isolate, exec, JSObject::GetProperty( |
| 1302 recv, factory->NewStringFromAsciiChecked("exec"))); |
| 1303 if (RegExpUtils::IsBuiltinExec(exec)) { |
| 1304 RETURN_RESULT_OR_FAILURE( |
| 1305 isolate, RegExpSplit(isolate, Handle<JSRegExp>::cast(recv), string, |
| 1306 limit_obj)); |
| 1307 } |
| 1308 } |
| 1309 |
1304 Handle<Object> flags_obj; | 1310 Handle<Object> flags_obj; |
1305 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1311 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1306 isolate, flags_obj, JSObject::GetProperty(recv, factory->flags_string())); | 1312 isolate, flags_obj, JSObject::GetProperty(recv, factory->flags_string())); |
1307 | 1313 |
1308 Handle<String> flags; | 1314 Handle<String> flags; |
1309 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, flags, | 1315 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, flags, |
1310 Object::ToString(isolate, flags_obj)); | 1316 Object::ToString(isolate, flags_obj)); |
1311 | 1317 |
1312 Handle<String> u_str = factory->LookupSingleCharacterStringFromCode('u'); | 1318 Handle<String> u_str = factory->LookupSingleCharacterStringFromCode('u'); |
1313 const bool unicode = (String::IndexOf(isolate, flags, u_str, 0) >= 0); | 1319 const bool unicode = (String::IndexOf(isolate, flags, u_str, 0) >= 0); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 a->Bind(&if_matched); | 1695 a->Bind(&if_matched); |
1690 { | 1696 { |
1691 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, | 1697 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, |
1692 match_indices, string); | 1698 match_indices, string); |
1693 a->Return(result); | 1699 a->Return(result); |
1694 } | 1700 } |
1695 } | 1701 } |
1696 | 1702 |
1697 } // namespace internal | 1703 } // namespace internal |
1698 } // namespace v8 | 1704 } // namespace v8 |
OLD | NEW |