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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/bootstrap_natives.h" | 8 #include "vm/bootstrap_natives.h" |
9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 new_array.SetTypeArguments(type_arguments); | 28 new_array.SetTypeArguments(type_arguments); |
29 return new_array.raw(); | 29 return new_array.raw(); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 DEFINE_NATIVE_ENTRY(GrowableList_getIndexed, 2) { | 33 DEFINE_NATIVE_ENTRY(GrowableList_getIndexed, 2) { |
34 const GrowableObjectArray& array = | 34 const GrowableObjectArray& array = |
35 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); | 35 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); |
36 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1)); | 36 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1)); |
37 if ((index.Value() < 0) || (index.Value() >= array.Length())) { | 37 if ((index.Value() < 0) || (index.Value() >= array.Length())) { |
38 Exceptions::ThrowRangeError("index", index, 0, array.Length()); | 38 Exceptions::ThrowRangeError("index", index, 0, array.Length() - 1); |
39 } | 39 } |
40 const Instance& obj = Instance::CheckedHandle(array.At(index.Value())); | 40 const Instance& obj = Instance::CheckedHandle(array.At(index.Value())); |
41 return obj.raw(); | 41 return obj.raw(); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 DEFINE_NATIVE_ENTRY(GrowableList_setIndexed, 3) { | 45 DEFINE_NATIVE_ENTRY(GrowableList_setIndexed, 3) { |
46 const GrowableObjectArray& array = | 46 const GrowableObjectArray& array = |
47 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); | 47 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); |
48 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1)); | 48 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1)); |
49 if ((index.Value() < 0) || (index.Value() >= array.Length())) { | 49 if ((index.Value() < 0) || (index.Value() >= array.Length())) { |
50 Exceptions::ThrowRangeError("index", index, 0, array.Length()); | 50 Exceptions::ThrowRangeError("index", index, 0, array.Length() - 1); |
51 } | 51 } |
52 GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2)); | 52 GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2)); |
53 array.SetAt(index.Value(), value); | 53 array.SetAt(index.Value(), value); |
54 return Object::null(); | 54 return Object::null(); |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 DEFINE_NATIVE_ENTRY(GrowableList_getLength, 1) { | 58 DEFINE_NATIVE_ENTRY(GrowableList_getLength, 1) { |
59 const GrowableObjectArray& array = | 59 const GrowableObjectArray& array = |
60 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); | 60 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 DEFINE_NATIVE_ENTRY(Internal_makeFixedListUnmodifiable, 1) { | 99 DEFINE_NATIVE_ENTRY(Internal_makeFixedListUnmodifiable, 1) { |
100 GET_NON_NULL_NATIVE_ARGUMENT(Array, array, arguments->NativeArgAt(0)); | 100 GET_NON_NULL_NATIVE_ARGUMENT(Array, array, arguments->NativeArgAt(0)); |
101 array.MakeImmutable(); | 101 array.MakeImmutable(); |
102 return array.raw(); | 102 return array.raw(); |
103 } | 103 } |
104 | 104 |
105 } // namespace dart | 105 } // namespace dart |
OLD | NEW |