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 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // ObjectArray src, int srcStart, int dstStart, int count. | 68 // ObjectArray src, int srcStart, int dstStart, int count. |
69 DEFINE_NATIVE_ENTRY(ObjectArray_copyFromObjectArray, 5) { | 69 DEFINE_NATIVE_ENTRY(ObjectArray_copyFromObjectArray, 5) { |
70 const Array& dest = Array::CheckedHandle(arguments->NativeArgAt(0)); | 70 const Array& dest = Array::CheckedHandle(arguments->NativeArgAt(0)); |
71 GET_NON_NULL_NATIVE_ARGUMENT(Array, source, arguments->NativeArgAt(1)); | 71 GET_NON_NULL_NATIVE_ARGUMENT(Array, source, arguments->NativeArgAt(1)); |
72 GET_NON_NULL_NATIVE_ARGUMENT(Smi, src_start, arguments->NativeArgAt(2)); | 72 GET_NON_NULL_NATIVE_ARGUMENT(Smi, src_start, arguments->NativeArgAt(2)); |
73 GET_NON_NULL_NATIVE_ARGUMENT(Smi, dst_start, arguments->NativeArgAt(3)); | 73 GET_NON_NULL_NATIVE_ARGUMENT(Smi, dst_start, arguments->NativeArgAt(3)); |
74 GET_NON_NULL_NATIVE_ARGUMENT(Smi, count, arguments->NativeArgAt(4)); | 74 GET_NON_NULL_NATIVE_ARGUMENT(Smi, count, arguments->NativeArgAt(4)); |
75 intptr_t icount = count.Value(); | 75 intptr_t icount = count.Value(); |
76 if (icount < 0) { | 76 if (icount < 0) { |
77 const Array& args = Array::Handle(Object::empty_array()); | 77 Exceptions::ThrowByType(Exceptions::kArgument, Object::empty_array()); |
78 Exceptions::ThrowByType(Exceptions::kArgument, args); | |
79 } | 78 } |
80 if (icount == 0) { | 79 if (icount == 0) { |
81 return Object::null(); | 80 return Object::null(); |
82 } | 81 } |
83 intptr_t isrc_start = src_start.Value(); | 82 intptr_t isrc_start = src_start.Value(); |
84 intptr_t idst_start = dst_start.Value(); | 83 intptr_t idst_start = dst_start.Value(); |
85 if ((isrc_start < 0) || ((isrc_start + icount) > source.Length())) { | 84 if ((isrc_start < 0) || ((isrc_start + icount) > source.Length())) { |
86 const Array& args = Array::Handle(Array::New(1)); | 85 const Array& args = Array::Handle(Array::New(1)); |
87 args.SetAt(0, src_start); | 86 args.SetAt(0, src_start); |
88 Exceptions::ThrowByType(Exceptions::kRange, args); | 87 Exceptions::ThrowByType(Exceptions::kRange, args); |
(...skipping 13 matching lines...) Expand all Loading... |
102 } else { | 101 } else { |
103 for (intptr_t i = 0; i < icount; i++) { | 102 for (intptr_t i = 0; i < icount; i++) { |
104 src_obj = source.At(isrc_start + i); | 103 src_obj = source.At(isrc_start + i); |
105 dest.SetAt(idst_start + i, src_obj); | 104 dest.SetAt(idst_start + i, src_obj); |
106 } | 105 } |
107 } | 106 } |
108 return Object::null(); | 107 return Object::null(); |
109 } | 108 } |
110 | 109 |
111 } // namespace dart | 110 } // namespace dart |
OLD | NEW |