Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: pkg/analyzer/lib/src/summary/flat_buffers.dart

Issue 1581773015: Fix dart2js build - don't use Int64. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library analyzer.src.summary.flat_buffers; 5 library analyzer.src.summary.flat_buffers;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:math'; 9 import 'dart:math';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 int _getInt32([int delta = 0]) => 55 int _getInt32([int delta = 0]) =>
56 _buffer.getInt32(_offset + delta, Endianness.LITTLE_ENDIAN); 56 _buffer.getInt32(_offset + delta, Endianness.LITTLE_ENDIAN);
57 57
58 int _getInt8([int delta = 0]) => _buffer.getInt8(_offset + delta); 58 int _getInt8([int delta = 0]) => _buffer.getInt8(_offset + delta);
59 59
60 int _getUint16([int delta = 0]) => 60 int _getUint16([int delta = 0]) =>
61 _buffer.getUint16(_offset + delta, Endianness.LITTLE_ENDIAN); 61 _buffer.getUint16(_offset + delta, Endianness.LITTLE_ENDIAN);
62 62
63 int _getUint32([int delta = 0]) => 63 int _getUint32([int delta = 0]) =>
64 _buffer.getUint32(_offset + delta, Endianness.LITTLE_ENDIAN); 64 _buffer.getUint32(_offset + delta, Endianness.LITTLE_ENDIAN);
65 int _getUint64([int delta = 0]) =>
66 _buffer.getUint64(_offset + delta, Endianness.LITTLE_ENDIAN);
67 65
68 /** 66 /**
69 * If the [byteList] is already a [Uint8List] return it. 67 * If the [byteList] is already a [Uint8List] return it.
70 * Otherwise return a [Uint8List] copy of the [byteList]. 68 * Otherwise return a [Uint8List] copy of the [byteList].
71 */ 69 */
72 static Uint8List _asUint8List(List<int> byteList) { 70 static Uint8List _asUint8List(List<int> byteList) {
73 if (byteList is Uint8List) { 71 if (byteList is Uint8List) {
74 return byteList; 72 return byteList;
75 } else { 73 } else {
76 return new Uint8List.fromList(byteList); 74 return new Uint8List.fromList(byteList);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 * Write the given list of 64-bit float [values]. 305 * Write the given list of 64-bit float [values].
308 */ 306 */
309 Offset writeListFloat64(List<double> values) { 307 Offset writeListFloat64(List<double> values) {
310 if (_currentVTable != null) { 308 if (_currentVTable != null) {
311 throw new StateError( 309 throw new StateError(
312 'Cannot write a non-scalar value while writing a table.'); 310 'Cannot write a non-scalar value while writing a table.');
313 } 311 }
314 _prepare(8, 1 + values.length); 312 _prepare(8, 1 + values.length);
315 Offset result = new Offset(_tail); 313 Offset result = new Offset(_tail);
316 int tail = _tail; 314 int tail = _tail;
317 _setUint64AtTail(_buf, tail, values.length); 315 _setUint32AtTail(_buf, tail, values.length);
318 tail -= 8; 316 tail -= 8;
319 for (double value in values) { 317 for (double value in values) {
320 _setFloat64AtTail(_buf, tail, value); 318 _setFloat64AtTail(_buf, tail, value);
321 tail -= 8; 319 tail -= 8;
322 } 320 }
323 return result; 321 return result;
324 } 322 }
325 323
326 /** 324 /**
327 * Write the given list of signed 32-bit integer [values]. 325 * Write the given list of signed 32-bit integer [values].
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 _buf.setFloat64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN); 410 _buf.setFloat64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
413 } 411 }
414 412
415 static void _setInt32AtTail(ByteData _buf, int tail, int x) { 413 static void _setInt32AtTail(ByteData _buf, int tail, int x) {
416 _buf.setInt32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN); 414 _buf.setInt32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
417 } 415 }
418 416
419 static void _setUint32AtTail(ByteData _buf, int tail, int x) { 417 static void _setUint32AtTail(ByteData _buf, int tail, int x) {
420 _buf.setUint32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN); 418 _buf.setUint32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
421 } 419 }
422
423 static void _setUint64AtTail(ByteData _buf, int tail, int x) {
424 _buf.setUint64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
425 }
426 } 420 }
427 421
428 /** 422 /**
429 * The reader of lists of 64-bit float values. 423 * The reader of lists of 64-bit float values.
430 * 424 *
431 * The returned unmodifiable lists lazily read values on access. 425 * The returned unmodifiable lists lazily read values on access.
432 */ 426 */
433 class Float64ListReader extends Reader<List<double>> { 427 class Float64ListReader extends Reader<List<double>> {
434 const Float64ListReader(); 428 const Float64ListReader();
435 429
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 class _FbFloat64List extends _FbList<double> { 567 class _FbFloat64List extends _FbList<double> {
574 final BufferPointer bp; 568 final BufferPointer bp;
575 569
576 int _length; 570 int _length;
577 List<double> _items; 571 List<double> _items;
578 572
579 _FbFloat64List(this.bp); 573 _FbFloat64List(this.bp);
580 574
581 @override 575 @override
582 int get length { 576 int get length {
583 _length ??= bp._getUint64(); 577 _length ??= bp._getUint32();
584 return _length; 578 return _length;
585 } 579 }
586 580
587 @override 581 @override
588 double operator [](int i) { 582 double operator [](int i) {
589 _items ??= new List<double>(length); 583 _items ??= new List<double>(length);
590 double item = _items[i]; 584 double item = _items[i];
591 if (item == null) { 585 if (item == null) {
592 BufferPointer ref = bp._advance(8 + 8 * i); 586 BufferPointer ref = bp._advance(8 + 8 * i);
593 item = ref._getFloat64(); 587 item = ref._getFloat64();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // Table size. 702 // Table size.
709 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN); 703 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN);
710 bufOffset += 2; 704 bufOffset += 2;
711 // Field offsets. 705 // Field offsets.
712 for (int fieldOffset in fieldOffsets) { 706 for (int fieldOffset in fieldOffsets) {
713 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN); 707 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN);
714 bufOffset += 2; 708 bufOffset += 2;
715 } 709 }
716 } 710 }
717 } 711 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698