| 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 21 matching lines...) Expand all Loading... |
| 32 if ((flags & JSRegExp::kSticky) != 0) flags_string[i++] = 'y'; | 32 if ((flags & JSRegExp::kSticky) != 0) flags_string[i++] = 'y'; |
| 33 | 33 |
| 34 DCHECK_LT(i, kMaxFlagsLength); | 34 DCHECK_LT(i, kMaxFlagsLength); |
| 35 memset(&flags_string[i], '\0', kMaxFlagsLength - i); | 35 memset(&flags_string[i], '\0', kMaxFlagsLength - i); |
| 36 | 36 |
| 37 return isolate->factory()->NewStringFromAsciiChecked(flags_string); | 37 return isolate->factory()->NewStringFromAsciiChecked(flags_string); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // ES#sec-regexpinitialize | 40 // ES#sec-regexpinitialize |
| 41 // Runtime Semantics: RegExpInitialize ( obj, pattern, flags ) | 41 // Runtime Semantics: RegExpInitialize ( obj, pattern, flags ) |
| 42 MaybeHandle<JSRegExp> RegExpInitialize(Isolate* isolate, | 42 MUST_USE_RESULT MaybeHandle<JSRegExp> RegExpInitialize(Isolate* isolate, |
| 43 Handle<JSRegExp> regexp, | 43 Handle<JSRegExp> regexp, |
| 44 Handle<Object> pattern, | 44 Handle<Object> pattern, |
| 45 Handle<Object> flags) { | 45 Handle<Object> flags) { |
| 46 Handle<String> pattern_string; | 46 Handle<String> pattern_string; |
| 47 if (pattern->IsUndefined(isolate)) { | 47 if (pattern->IsUndefined(isolate)) { |
| 48 pattern_string = isolate->factory()->empty_string(); | 48 pattern_string = isolate->factory()->empty_string(); |
| 49 } else { | 49 } else { |
| 50 ASSIGN_RETURN_ON_EXCEPTION(isolate, pattern_string, | 50 ASSIGN_RETURN_ON_EXCEPTION(isolate, pattern_string, |
| 51 Object::ToString(isolate, pattern), JSRegExp); | 51 Object::ToString(isolate, pattern), JSRegExp); |
| 52 } | 52 } |
| 53 | 53 |
| 54 Handle<String> flags_string; | 54 Handle<String> flags_string; |
| 55 if (flags->IsUndefined(isolate)) { | 55 if (flags->IsUndefined(isolate)) { |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 start_index = current_index = end_index; | 1336 start_index = current_index = end_index; |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 return NewJSArrayWithElements(isolate, elems, num_elems); | 1339 return NewJSArrayWithElements(isolate, elems, num_elems); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 // ES##sec-speciesconstructor | 1342 // ES##sec-speciesconstructor |
| 1343 // SpeciesConstructor ( O, defaultConstructor ) | 1343 // SpeciesConstructor ( O, defaultConstructor ) |
| 1344 MaybeHandle<Object> SpeciesConstructor(Isolate* isolate, | 1344 MUST_USE_RESULT MaybeHandle<Object> SpeciesConstructor( |
| 1345 Handle<JSReceiver> recv, | 1345 Isolate* isolate, Handle<JSReceiver> recv, |
| 1346 Handle<JSFunction> default_ctor) { | 1346 Handle<JSFunction> default_ctor) { |
| 1347 Handle<Object> ctor_obj; | 1347 Handle<Object> ctor_obj; |
| 1348 ASSIGN_RETURN_ON_EXCEPTION( | 1348 ASSIGN_RETURN_ON_EXCEPTION( |
| 1349 isolate, ctor_obj, | 1349 isolate, ctor_obj, |
| 1350 JSObject::GetProperty(recv, isolate->factory()->constructor_string()), | 1350 JSObject::GetProperty(recv, isolate->factory()->constructor_string()), |
| 1351 Object); | 1351 Object); |
| 1352 | 1352 |
| 1353 if (ctor_obj->IsUndefined(isolate)) return default_ctor; | 1353 if (ctor_obj->IsUndefined(isolate)) return default_ctor; |
| 1354 | 1354 |
| 1355 if (!ctor_obj->IsJSReceiver()) { | 1355 if (!ctor_obj->IsJSReceiver()) { |
| 1356 THROW_NEW_ERROR(isolate, | 1356 THROW_NEW_ERROR(isolate, |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 a->Bind(&if_matched); | 2010 a->Bind(&if_matched); |
| 2011 { | 2011 { |
| 2012 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, | 2012 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, |
| 2013 match_indices, string); | 2013 match_indices, string); |
| 2014 a->Return(result); | 2014 a->Return(result); |
| 2015 } | 2015 } |
| 2016 } | 2016 } |
| 2017 | 2017 |
| 2018 } // namespace internal | 2018 } // namespace internal |
| 2019 } // namespace v8 | 2019 } // namespace v8 |
| OLD | NEW |