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

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

Issue 1570193004: Remove Int64 support from FlatBuffers. (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 | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | 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 21 matching lines...) Expand all
32 @override 32 @override
33 String toString() => _offset.toString(); 33 String toString() => _offset.toString();
34 34
35 BufferPointer _advance(int delta) { 35 BufferPointer _advance(int delta) {
36 return new BufferPointer._(_buffer, _offset + delta); 36 return new BufferPointer._(_buffer, _offset + delta);
37 } 37 }
38 38
39 int _getInt32([int delta = 0]) => 39 int _getInt32([int delta = 0]) =>
40 _buffer.getInt32(_offset + delta, Endianness.LITTLE_ENDIAN); 40 _buffer.getInt32(_offset + delta, Endianness.LITTLE_ENDIAN);
41 41
42 int _getInt64([int delta = 0]) =>
43 _buffer.getInt64(_offset + delta, Endianness.LITTLE_ENDIAN);
44
45 int _getInt8([int delta = 0]) => _buffer.getInt8(_offset + delta); 42 int _getInt8([int delta = 0]) => _buffer.getInt8(_offset + delta);
46 43
47 int _getUint16([int delta = 0]) => 44 int _getUint16([int delta = 0]) =>
48 _buffer.getUint16(_offset + delta, Endianness.LITTLE_ENDIAN); 45 _buffer.getUint16(_offset + delta, Endianness.LITTLE_ENDIAN);
49 46
50 int _getUint32([int delta = 0]) => 47 int _getUint32([int delta = 0]) =>
51 _buffer.getUint32(_offset + delta, Endianness.LITTLE_ENDIAN); 48 _buffer.getUint32(_offset + delta, Endianness.LITTLE_ENDIAN);
52 49
53 /** 50 /**
54 * If the [byteList] is already a [Uint8List] return it. 51 * If the [byteList] is already a [Uint8List] return it.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 108 }
112 if (value != def) { 109 if (value != def) {
113 int size = 4; 110 int size = 4;
114 _prepare(size, 1); 111 _prepare(size, 1);
115 _trackField(field); 112 _trackField(field);
116 _setInt32AtTail(_buf, _tail, value); 113 _setInt32AtTail(_buf, _tail, value);
117 } 114 }
118 } 115 }
119 116
120 /** 117 /**
121 * Add the [field] with the given 64-bit signed integer [value]. The field is
122 * not added if the [value] is equal to [def].
123 */
124 void addInt64(int field, int value, [int def]) {
125 if (_currentVTable == null) {
126 throw new StateError('Start a table before adding values.');
127 }
128 if (value != def) {
129 int size = 8;
130 _prepare(size, 1);
131 _trackField(field);
132 _setInt64AtTail(_buf, _tail, value);
133 }
134 }
135
136 /**
137 * Add the [field] with the given 8-bit signed integer [value]. The field is 118 * Add the [field] with the given 8-bit signed integer [value]. The field is
138 * not added if the [value] is equal to [def]. 119 * not added if the [value] is equal to [def].
139 */ 120 */
140 void addInt8(int field, int value, [int def]) { 121 void addInt8(int field, int value, [int def]) {
141 if (_currentVTable == null) { 122 if (_currentVTable == null) {
142 throw new StateError('Start a table before adding values.'); 123 throw new StateError('Start a table before adding values.');
143 } 124 }
144 if (value != def) { 125 if (value != def) {
145 int size = 1; 126 int size = 1;
146 _prepare(size, 1); 127 _prepare(size, 1);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 * This is a low-level method, it should not be invoked by clients. 215 * This is a low-level method, it should not be invoked by clients.
235 */ 216 */
236 void lowWriteUint32(int value) { 217 void lowWriteUint32(int value) {
237 _prepare(4, 1); 218 _prepare(4, 1);
238 _setUint32AtTail(_buf, _tail, value); 219 _setUint32AtTail(_buf, _tail, value);
239 } 220 }
240 221
241 /** 222 /**
242 * This is a low-level method, it should not be invoked by clients. 223 * This is a low-level method, it should not be invoked by clients.
243 */ 224 */
244 void lowWriteUint64(int value) {
245 _prepare(8, 1);
246 _setUint64AtTail(_buf, _tail, value);
247 }
248
249 /**
250 * This is a low-level method, it should not be invoked by clients.
251 */
252 void lowWriteUint8(int value) { 225 void lowWriteUint8(int value) {
253 _prepare(1, 1); 226 _prepare(1, 1);
254 _buf.setUint8(_buf.lengthInBytes - _tail, value); 227 _buf.setUint8(_buf.lengthInBytes - _tail, value);
255 } 228 }
256 229
257 /** 230 /**
258 * Reset the builder and make it ready for filling a new buffer. 231 * Reset the builder and make it ready for filling a new buffer.
259 */ 232 */
260 void reset() { 233 void reset() {
261 _buf = new ByteData(initialSize); 234 _buf = new ByteData(initialSize);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 * Record the offset of the given [field]. 350 * Record the offset of the given [field].
378 */ 351 */
379 void _trackField(int field) { 352 void _trackField(int field) {
380 _currentVTable.addField(field, _tail); 353 _currentVTable.addField(field, _tail);
381 } 354 }
382 355
383 static void _setInt32AtTail(ByteData _buf, int tail, int x) { 356 static void _setInt32AtTail(ByteData _buf, int tail, int x) {
384 _buf.setInt32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN); 357 _buf.setInt32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
385 } 358 }
386 359
387 static void _setInt64AtTail(ByteData _buf, int tail, int x) {
388 _buf.setInt64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
389 }
390
391 static void _setUint32AtTail(ByteData _buf, int tail, int x) { 360 static void _setUint32AtTail(ByteData _buf, int tail, int x) {
392 _buf.setUint32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN); 361 _buf.setUint32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
393 } 362 }
394
395 static void _setUint64AtTail(ByteData _buf, int tail, int x) {
396 _buf.setUint64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
397 }
398 } 363 }
399 364
400 /** 365 /**
401 * The reader of 32-bit signed integers. 366 * The reader of 32-bit signed integers.
402 */ 367 */
403 class Int32Reader extends Reader<int> { 368 class Int32Reader extends Reader<int> {
404 const Int32Reader() : super(); 369 const Int32Reader() : super();
405 370
406 @override 371 @override
407 int get size => 4; 372 int get size => 4;
408 373
409 @override 374 @override
410 int read(BufferPointer bp) => bp._getInt32(); 375 int read(BufferPointer bp) => bp._getInt32();
411 } 376 }
412 377
413 /** 378 /**
414 * The reader of 64-bit signed integers.
415 */
416 class Int64Reader extends Reader<int> {
417 const Int64Reader() : super();
418
419 @override
420 int get size => 8;
421
422 @override
423 int read(BufferPointer bp) => bp._getInt64();
424 }
425
426 /**
427 * The reader of 8-bit signed integers. 379 * The reader of 8-bit signed integers.
428 */ 380 */
429 class Int8Reader extends Reader<int> { 381 class Int8Reader extends Reader<int> {
430 const Int8Reader() : super(); 382 const Int8Reader() : super();
431 383
432 @override 384 @override
433 int get size => 1; 385 int get size => 1;
434 386
435 @override 387 @override
436 int read(BufferPointer bp) => bp._getInt8(); 388 int read(BufferPointer bp) => bp._getInt8();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 // Table size. 580 // Table size.
629 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN); 581 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN);
630 bufOffset += 2; 582 bufOffset += 2;
631 // Field offsets. 583 // Field offsets.
632 for (int fieldOffset in fieldOffsets) { 584 for (int fieldOffset in fieldOffsets) {
633 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN); 585 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN);
634 bufOffset += 2; 586 bufOffset += 2;
635 } 587 }
636 } 588 }
637 } 589 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698