| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/regexp/jsregexp-inl.h" | 10 #include "src/regexp/jsregexp-inl.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 364 } |
| 365 | 365 |
| 366 RegExpImpl::SetLastMatchInfo(regexp_info, subject, capture_count, | 366 RegExpImpl::SetLastMatchInfo(regexp_info, subject, capture_count, |
| 367 global_cache.LastSuccessfulMatch()); | 367 global_cache.LastSuccessfulMatch()); |
| 368 | 368 |
| 369 int matches = offsets.length() / 2; | 369 int matches = offsets.length() / 2; |
| 370 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); | 370 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); |
| 371 Handle<String> substring = | 371 Handle<String> substring = |
| 372 isolate->factory()->NewSubString(subject, offsets.at(0), offsets.at(1)); | 372 isolate->factory()->NewSubString(subject, offsets.at(0), offsets.at(1)); |
| 373 elements->set(0, *substring); | 373 elements->set(0, *substring); |
| 374 for (int i = 1; i < matches; i++) { | 374 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 1, i, i < matches, i++, { |
| 375 HandleScope temp_scope(isolate); | |
| 376 int from = offsets.at(i * 2); | 375 int from = offsets.at(i * 2); |
| 377 int to = offsets.at(i * 2 + 1); | 376 int to = offsets.at(i * 2 + 1); |
| 378 Handle<String> substring = | 377 Handle<String> substring = |
| 379 isolate->factory()->NewProperSubString(subject, from, to); | 378 isolate->factory()->NewProperSubString(subject, from, to); |
| 380 elements->set(i, *substring); | 379 elements->set(i, *substring); |
| 381 } | 380 }); |
| 382 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); | 381 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); |
| 383 result->set_length(Smi::FromInt(matches)); | 382 result->set_length(Smi::FromInt(matches)); |
| 384 return *result; | 383 return *result; |
| 385 } | 384 } |
| 386 | 385 |
| 387 | 386 |
| 388 RUNTIME_FUNCTION(Runtime_StringCharCodeAtRT) { | 387 RUNTIME_FUNCTION(Runtime_StringCharCodeAtRT) { |
| 389 HandleScope handle_scope(isolate); | 388 HandleScope handle_scope(isolate); |
| 390 DCHECK(args.length() == 2); | 389 DCHECK(args.length() == 2); |
| 391 | 390 |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 SealHandleScope shs(isolate); | 1318 SealHandleScope shs(isolate); |
| 1320 DCHECK(args.length() == 2); | 1319 DCHECK(args.length() == 2); |
| 1321 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1320 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
| 1322 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1321 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
| 1323 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1322 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
| 1324 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1323 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
| 1325 } | 1324 } |
| 1326 | 1325 |
| 1327 } // namespace internal | 1326 } // namespace internal |
| 1328 } // namespace v8 | 1327 } // namespace v8 |
| OLD | NEW |