| 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 function native_ListFactory__new(typeToken, length) { | 5 function native_ListFactory__new(typeToken, length) { |
| 6 return RTT.setTypeInfo( | 6 return RTT.setTypeInfo( |
| 7 new Array(length), | 7 new Array(length), |
| 8 Array.$lookupRTT(RTT.getTypeInfo(typeToken).typeArgs)); | 8 Array.$lookupRTT(RTT.getTypeInfo(typeToken).typeArgs)); |
| 9 } | 9 } |
| 10 | 10 |
| 11 function native_ListImplementation__indexOperator(index) { | 11 function native_ListImplementation_INDEX(index) { |
| 12 return this[index]; | 12 var i = index | 0; |
| 13 if (i !== index) { |
| 14 native__NumberJsUtil__throwIllegalArgumentException(index); |
| 15 } else if (i < 0 || i >= this.length) { |
| 16 native__ListJsUtil__throwIndexOutOfRangeException(index); |
| 17 } |
| 18 return this[i]; |
| 13 } | 19 } |
| 14 | 20 |
| 15 function native_ListImplementation__indexAssignOperator(index, value) { | 21 function native_ListImplementation_ASSIGN_INDEX(index, value) { |
| 16 this[index] = value; | 22 var i = index | 0; |
| 23 if (i !== index) { |
| 24 native__NumberJsUtil__throwIllegalArgumentException(index); |
| 25 } else if (i < 0 || i >= this.length) { |
| 26 native__ListJsUtil__throwIndexOutOfRangeException(index); |
| 27 } |
| 28 this[i] = value; |
| 17 } | 29 } |
| 18 | 30 |
| 19 function native_ListImplementation_get$length() { | 31 function native_ListImplementation_get$length() { |
| 20 return this.length; | 32 return this.length; |
| 21 } | 33 } |
| 22 | 34 |
| 23 function native_ListImplementation__setLength(length) { | 35 function native_ListImplementation__setLength(length) { |
| 24 this.length = length; | 36 this.length = length; |
| 25 } | 37 } |
| 26 | 38 |
| 27 function native_ListImplementation__add(element) { | 39 function native_ListImplementation__add(element) { |
| 28 this.push(element); | 40 this.push(element); |
| 29 } | 41 } |
| 30 | 42 |
| 31 function $inlineArrayIndexCheck(array, index) { | |
| 32 if (index >= 0 && index < array.length) { | |
| 33 return index; | |
| 34 } | |
| 35 native__ListJsUtil__throwIndexOutOfRangeException(index); | |
| 36 } | |
| 37 | |
| 38 function native_ListImplementation__removeRange(start, length) { | 43 function native_ListImplementation__removeRange(start, length) { |
| 39 this.splice(start, length); | 44 this.splice(start, length); |
| 40 } | 45 } |
| 41 | 46 |
| 42 function native_ListImplementation__insertRange(start, length, initialValue) { | 47 function native_ListImplementation__insertRange(start, length, initialValue) { |
| 43 var array = [start, 0]; | 48 var array = [start, 0]; |
| 44 for (var i = 0; i < length; i++){ | 49 for (var i = 0; i < length; i++){ |
| 45 array.push(initialValue); | 50 array.push(initialValue); |
| 46 } | 51 } |
| 47 this.splice.apply(this, array); | 52 this.splice.apply(this, array); |
| 48 } | 53 } |
| 54 |
| 55 function $inlineArrayIndexCheck(array, index) { |
| 56 var i = index | 0; |
| 57 if (i !== index) { |
| 58 native__NumberJsUtil__throwIllegalArgumentException(index); |
| 59 } else if (i < 0 || i >= array.length) { |
| 60 native__ListJsUtil__throwIndexOutOfRangeException(index); |
| 61 } |
| 62 return i; |
| 63 } |
| OLD | NEW |