Chromium Code Reviews| 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 import "dart:_internal" hide Symbol; | 5 import "dart:_internal" hide Symbol; |
| 6 import "dart:collection" show ListBase; | 6 import "dart:collection" show ListBase; |
| 7 import 'dart:math' show Random; | 7 import 'dart:math' show Random; |
| 8 | 8 |
| 9 @patch | 9 @patch |
| 10 class ByteData implements TypedData { | 10 class ByteData implements TypedData { |
| (...skipping 3026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3037 } | 3037 } |
| 3038 | 3038 |
| 3039 int _toInt32(int value) { | 3039 int _toInt32(int value) { |
| 3040 return _toInt(value, 0xFFFFFFFF); | 3040 return _toInt(value, 0xFFFFFFFF); |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 int _toUint32(int value) { | 3043 int _toUint32(int value) { |
| 3044 return value & 0xFFFFFFFF; | 3044 return value & 0xFFFFFFFF; |
| 3045 } | 3045 } |
| 3046 | 3046 |
| 3047 const _uint64Mask = (1 << 64) - 1; | |
|
regis
2017/07/17 16:45:31
ditto
alexmarkov
2017/07/17 20:21:28
Done.
| |
| 3048 | |
| 3047 int _toInt64(int value) { | 3049 int _toInt64(int value) { |
| 3048 // Avoid bigint mask when possible. | 3050 // Avoid bigint mask when possible. |
| 3049 return (ClassID.getID(value) == ClassID.cidBigint) | 3051 return (ClassID.getID(value) == ClassID.cidBigint) |
| 3050 ? _toInt(value, 0xFFFFFFFFFFFFFFFF) | 3052 ? _toInt(value, _uint64Mask) |
| 3051 : value; | 3053 : value; |
| 3052 } | 3054 } |
| 3053 | 3055 |
| 3054 int _toUint64(int value) { | 3056 int _toUint64(int value) { |
| 3055 // Avoid bigint mask when possible. | 3057 // Avoid bigint mask when possible. |
| 3056 return (ClassID.getID(value) == ClassID.cidBigint) | 3058 return (ClassID.getID(value) == ClassID.cidBigint) |
| 3057 ? _toInt(value, 0xFFFFFFFFFFFFFFFF) | 3059 ? _toInt(value, _uint64Mask) |
| 3058 : value; | 3060 : value; |
| 3059 } | 3061 } |
| 3060 | 3062 |
| 3061 void _rangeCheck(int listLength, int start, int length) { | 3063 void _rangeCheck(int listLength, int start, int length) { |
| 3062 if (length < 0) { | 3064 if (length < 0) { |
| 3063 throw new RangeError.value(length); | 3065 throw new RangeError.value(length); |
| 3064 } | 3066 } |
| 3065 if (start < 0) { | 3067 if (start < 0) { |
| 3066 throw new RangeError.value(start); | 3068 throw new RangeError.value(start); |
| 3067 } | 3069 } |
| 3068 if (start + length > listLength) { | 3070 if (start + length > listLength) { |
| 3069 throw new RangeError.value(start + length); | 3071 throw new RangeError.value(start + length); |
| 3070 } | 3072 } |
| 3071 } | 3073 } |
| 3072 | 3074 |
| 3073 void _offsetAlignmentCheck(int offset, int alignment) { | 3075 void _offsetAlignmentCheck(int offset, int alignment) { |
| 3074 if ((offset % alignment) != 0) { | 3076 if ((offset % alignment) != 0) { |
| 3075 throw new RangeError('Offset ($offset) must be a multiple of ' | 3077 throw new RangeError('Offset ($offset) must be a multiple of ' |
| 3076 'BYTES_PER_ELEMENT ($alignment)'); | 3078 'BYTES_PER_ELEMENT ($alignment)'); |
| 3077 } | 3079 } |
| 3078 } | 3080 } |
| 3079 | 3081 |
| 3080 int _defaultIfNull(object, value) { | 3082 int _defaultIfNull(object, value) { |
| 3081 if (object == null) { | 3083 if (object == null) { |
| 3082 return value; | 3084 return value; |
| 3083 } | 3085 } |
| 3084 return object; | 3086 return object; |
| 3085 } | 3087 } |
| OLD | NEW |