| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 byte_array ^= obj.raw(); | 1560 byte_array ^= obj.raw(); |
| 1561 if (Utils::RangeCheck(offset, length, byte_array.Length())) { | 1561 if (Utils::RangeCheck(offset, length, byte_array.Length())) { |
| 1562 ByteArray::Copy(native_array, byte_array, offset, length); | 1562 ByteArray::Copy(native_array, byte_array, offset, length); |
| 1563 return Api::Success(); | 1563 return Api::Success(); |
| 1564 } | 1564 } |
| 1565 return Api::NewError("Invalid length passed in to access list elements"); | 1565 return Api::NewError("Invalid length passed in to access list elements"); |
| 1566 } | 1566 } |
| 1567 if (obj.IsArray()) { | 1567 if (obj.IsArray()) { |
| 1568 Array& array_obj = Array::Handle(); | 1568 Array& array_obj = Array::Handle(); |
| 1569 array_obj ^= obj.raw(); | 1569 array_obj ^= obj.raw(); |
| 1570 if ((offset + length) <= array_obj.Length()) { | 1570 if (Utils::RangeCheck(offset, length, array_obj.Length())) { |
| 1571 Object& element = Object::Handle(); | 1571 Object& element = Object::Handle(); |
| 1572 Integer& integer = Integer::Handle(); | 1572 Integer& integer = Integer::Handle(); |
| 1573 for (int i = 0; i < length; i++) { | 1573 for (int i = 0; i < length; i++) { |
| 1574 element = array_obj.At(offset + i); | 1574 element = array_obj.At(offset + i); |
| 1575 if (!element.IsInteger()) { | 1575 if (!element.IsInteger()) { |
| 1576 return Api::NewError("%s expects the argument 'list' to be " | 1576 return Api::NewError("%s expects the argument 'list' to be " |
| 1577 "a List of int", CURRENT_FUNC); | 1577 "a List of int", CURRENT_FUNC); |
| 1578 } | 1578 } |
| 1579 integer ^= element.raw(); | 1579 integer ^= element.raw(); |
| 1580 native_array[i] = static_cast<uint8_t>(integer.AsInt64Value() & 0xff); | 1580 native_array[i] = static_cast<uint8_t>(integer.AsInt64Value() & 0xff); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 } | 1639 } |
| 1640 return Api::NewError("Invalid length passed in to set list elements"); | 1640 return Api::NewError("Invalid length passed in to set list elements"); |
| 1641 } | 1641 } |
| 1642 if (obj.IsArray()) { | 1642 if (obj.IsArray()) { |
| 1643 if (obj.IsImmutableArray()) { | 1643 if (obj.IsImmutableArray()) { |
| 1644 return Api::NewError("Cannot modify immutable array"); | 1644 return Api::NewError("Cannot modify immutable array"); |
| 1645 } | 1645 } |
| 1646 Array& array_obj = Array::Handle(); | 1646 Array& array_obj = Array::Handle(); |
| 1647 array_obj ^= obj.raw(); | 1647 array_obj ^= obj.raw(); |
| 1648 Integer& integer = Integer::Handle(); | 1648 Integer& integer = Integer::Handle(); |
| 1649 if ((offset + length) <= array_obj.Length()) { | 1649 if (Utils::RangeCheck(offset, length, array_obj.Length())) { |
| 1650 for (int i = 0; i < length; i++) { | 1650 for (int i = 0; i < length; i++) { |
| 1651 integer = Integer::New(native_array[i]); | 1651 integer = Integer::New(native_array[i]); |
| 1652 array_obj.SetAt(offset + i, integer); | 1652 array_obj.SetAt(offset + i, integer); |
| 1653 } | 1653 } |
| 1654 return Api::Success(); | 1654 return Api::Success(); |
| 1655 } | 1655 } |
| 1656 return Api::NewError("Invalid length passed in to set array elements"); | 1656 return Api::NewError("Invalid length passed in to set array elements"); |
| 1657 } | 1657 } |
| 1658 // TODO(5526318): Make access to GrowableObjectArray more efficient. | 1658 // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| 1659 // Now check and handle a dart object that implements the List interface. | 1659 // Now check and handle a dart object that implements the List interface. |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 *buffer = NULL; | 2712 *buffer = NULL; |
| 2713 } | 2713 } |
| 2714 delete debug_region; | 2714 delete debug_region; |
| 2715 } else { | 2715 } else { |
| 2716 *buffer = NULL; | 2716 *buffer = NULL; |
| 2717 *buffer_size = 0; | 2717 *buffer_size = 0; |
| 2718 } | 2718 } |
| 2719 } | 2719 } |
| 2720 | 2720 |
| 2721 } // namespace dart | 2721 } // namespace dart |
| OLD | NEW |