| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 intptr_t start = start_obj.Value(); | 50 intptr_t start = start_obj.Value(); |
| 51 if ((start < 0) || (start > length)) { | 51 if ((start < 0) || (start > length)) { |
| 52 Exceptions::ThrowArgumentError(start_obj); | 52 Exceptions::ThrowArgumentError(start_obj); |
| 53 } | 53 } |
| 54 | 54 |
| 55 intptr_t end = end_obj.Value(); | 55 intptr_t end = end_obj.Value(); |
| 56 if ((end < start) || (end > length)) { | 56 if ((end < start) || (end > length)) { |
| 57 Exceptions::ThrowArgumentError(end_obj); | 57 Exceptions::ThrowArgumentError(end_obj); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Zone* zone = isolate->current_zone(); | |
| 61 | |
| 62 // Unbox the array and determine the maximum element width. | 60 // Unbox the array and determine the maximum element width. |
| 63 bool is_one_byte_string = true; | 61 bool is_one_byte_string = true; |
| 64 intptr_t array_len = end - start; | 62 intptr_t array_len = end - start; |
| 65 intptr_t utf16_len = array_len; | 63 intptr_t utf16_len = array_len; |
| 66 int32_t* utf32_array = zone->Alloc<int32_t>(array_len); | 64 int32_t* utf32_array = zone->Alloc<int32_t>(array_len); |
| 67 Instance& index_object = Instance::Handle(isolate); | 65 Instance& index_object = Instance::Handle(isolate); |
| 68 for (intptr_t i = 0; i < array_len; i++) { | 66 for (intptr_t i = 0; i < array_len; i++) { |
| 69 index_object ^= a.At(start + i); | 67 index_object ^= a.At(start + i); |
| 70 if (!index_object.IsSmi()) { | 68 if (!index_object.IsSmi()) { |
| 71 Exceptions::ThrowArgumentError(index_object); | 69 Exceptions::ThrowArgumentError(index_object); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) | 607 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) |
| 610 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); | 608 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); |
| 611 NoGCScope no_gc; | 609 NoGCScope no_gc; |
| 612 | 610 |
| 613 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); | 611 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); |
| 614 String::Copy(result, 0, data_position, length_value); | 612 String::Copy(result, 0, data_position, length_value); |
| 615 return result.raw(); | 613 return result.raw(); |
| 616 } | 614 } |
| 617 | 615 |
| 618 } // namespace dart | 616 } // namespace dart |
| OLD | NEW |