| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 | 2036 |
| 2037 | 2037 |
| 2038 DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, | 2038 DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, |
| 2039 intptr_t index, | 2039 intptr_t index, |
| 2040 Dart_Handle value) { | 2040 Dart_Handle value) { |
| 2041 Isolate* isolate = Isolate::Current(); | 2041 Isolate* isolate = Isolate::Current(); |
| 2042 DARTSCOPE(isolate); | 2042 DARTSCOPE(isolate); |
| 2043 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list)); | 2043 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list)); |
| 2044 // If the list is immutable we call into Dart for the indexed setter to | 2044 // If the list is immutable we call into Dart for the indexed setter to |
| 2045 // get the unsupported operation exception as the result. | 2045 // get the unsupported operation exception as the result. |
| 2046 if (obj.IsArray() && !obj.IsImmutableArray()) { | 2046 if (obj.IsArray() && !Array::Cast(obj).IsImmutable()) { |
| 2047 SET_LIST_ELEMENT(isolate, Array, obj, index, value); | 2047 SET_LIST_ELEMENT(isolate, Array, obj, index, value); |
| 2048 } else if (obj.IsGrowableObjectArray()) { | 2048 } else if (obj.IsGrowableObjectArray()) { |
| 2049 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value); | 2049 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value); |
| 2050 } else if (obj.IsError()) { | 2050 } else if (obj.IsError()) { |
| 2051 return list; | 2051 return list; |
| 2052 } else { | 2052 } else { |
| 2053 CHECK_CALLBACK_STATE(isolate); | 2053 CHECK_CALLBACK_STATE(isolate); |
| 2054 | 2054 |
| 2055 // Check and handle a dart object that implements the List interface. | 2055 // Check and handle a dart object that implements the List interface. |
| 2056 const Instance& instance = | 2056 const Instance& instance = |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 if (Utils::RangeCheck(offset, length, array.Length())) { | 2290 if (Utils::RangeCheck(offset, length, array.Length())) { |
| 2291 NoGCScope no_gc; | 2291 NoGCScope no_gc; |
| 2292 memmove(reinterpret_cast<uint8_t*>(array.DataAddr(offset)), | 2292 memmove(reinterpret_cast<uint8_t*>(array.DataAddr(offset)), |
| 2293 native_array, | 2293 native_array, |
| 2294 length); | 2294 length); |
| 2295 return Api::Success(); | 2295 return Api::Success(); |
| 2296 } | 2296 } |
| 2297 return Api::NewError("Invalid length passed in to access list elements"); | 2297 return Api::NewError("Invalid length passed in to access list elements"); |
| 2298 } | 2298 } |
| 2299 } | 2299 } |
| 2300 if (obj.IsArray() && !obj.IsImmutableArray()) { | 2300 if (obj.IsArray() && !Array::Cast(obj).IsImmutable()) { |
| 2301 // If the list is immutable we call into Dart for the indexed setter to | 2301 // If the list is immutable we call into Dart for the indexed setter to |
| 2302 // get the unsupported operation exception as the result. | 2302 // get the unsupported operation exception as the result. |
| 2303 SET_LIST_ELEMENT_AS_BYTES(isolate, | 2303 SET_LIST_ELEMENT_AS_BYTES(isolate, |
| 2304 Array, | 2304 Array, |
| 2305 obj, | 2305 obj, |
| 2306 native_array, | 2306 native_array, |
| 2307 offset, | 2307 offset, |
| 2308 length); | 2308 length); |
| 2309 } | 2309 } |
| 2310 if (obj.IsGrowableObjectArray()) { | 2310 if (obj.IsGrowableObjectArray()) { |
| (...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4837 } | 4837 } |
| 4838 { | 4838 { |
| 4839 NoGCScope no_gc; | 4839 NoGCScope no_gc; |
| 4840 RawObject* raw_obj = obj.raw(); | 4840 RawObject* raw_obj = obj.raw(); |
| 4841 isolate->heap()->SetPeer(raw_obj, peer); | 4841 isolate->heap()->SetPeer(raw_obj, peer); |
| 4842 } | 4842 } |
| 4843 return Api::Success(); | 4843 return Api::Success(); |
| 4844 } | 4844 } |
| 4845 | 4845 |
| 4846 } // namespace dart | 4846 } // namespace dart |
| OLD | NEW |