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

Unified Diff: pkg/analyzer/lib/src/summary/flat_buffers.dart

Issue 1571593002: Support for Int64 and fix for the root reference. (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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/flat_buffers.dart
diff --git a/pkg/analyzer/lib/src/summary/flat_buffers.dart b/pkg/analyzer/lib/src/summary/flat_buffers.dart
index 85fd0c9be99a93b6223147d7caaddf2b6a60f0be..86cd2007619e92dfb7421b5771aac5238a836c5c 100644
--- a/pkg/analyzer/lib/src/summary/flat_buffers.dart
+++ b/pkg/analyzer/lib/src/summary/flat_buffers.dart
@@ -38,6 +38,9 @@ class BufferPointer {
int _getInt32([int delta = 0]) =>
_buffer.getInt32(_offset + delta, Endianness.LITTLE_ENDIAN);
+ int _getInt64([int delta = 0]) =>
+ _buffer.getInt64(_offset + delta, Endianness.LITTLE_ENDIAN);
+
int _getInt8([int delta = 0]) => _buffer.getInt8(_offset + delta);
int _getUint16([int delta = 0]) =>
@@ -109,6 +112,22 @@ class Builder {
}
/**
+ * Add the [field] with the given 64-bit signed integer [value]. The field is
+ * not added if the [value] is equal to [def].
+ */
+ void addInt64(int field, int value, [int def]) {
+ if (_currentVTableBuilder == null) {
+ throw new StateError('Start a table before adding values.');
+ }
+ if (value != def) {
+ int size = 8;
+ _prepare(size, 1);
+ _trackField(field);
+ _setInt64AtTail(_buf, _tail, value);
+ }
+ }
+
+ /**
* Add the [field] with the given 8-bit signed integer [value]. The field is
* not added if the [value] is equal to [def].
*/
@@ -169,8 +188,8 @@ class Builder {
*/
Uint8List finish(Offset offset) {
_prepare(4, 1);
- _setUint32AtTail(_buf, _tail, _tail - offset._tail);
int alignedTail = _tail + ((-_tail) % _maxAlign);
+ _setUint32AtTail(_buf, alignedTail, alignedTail - offset._tail);
Paul Berry 2016/01/08 18:11:18 This won't work either. Consider the case where _
scheglov 2016/01/08 18:39:07 Done.
return _buf.buffer.asUint8List(_buf.lengthInBytes - alignedTail);
}
@@ -202,6 +221,14 @@ class Builder {
/**
* This is a low-level method, it should not be invoked by clients.
*/
+ void lowWriteUint64(int value) {
+ _prepare(8, 1);
+ _setUint64AtTail(_buf, _tail, value);
+ }
+
+ /**
+ * This is a low-level method, it should not be invoked by clients.
+ */
void lowWriteUint8(int value) {
_prepare(1, 1);
_buf.setUint8(_buf.lengthInBytes - _tail, value);
@@ -317,9 +344,17 @@ class Builder {
_buf.setInt32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
}
+ static void _setInt64AtTail(ByteData _buf, int tail, int x) {
+ _buf.setInt64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
+ }
+
static void _setUint32AtTail(ByteData _buf, int tail, int x) {
_buf.setUint32(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
}
+
+ static void _setUint64AtTail(ByteData _buf, int tail, int x) {
+ _buf.setUint64(_buf.lengthInBytes - tail, x, Endianness.LITTLE_ENDIAN);
+ }
}
/**
@@ -329,13 +364,26 @@ class Int32Reader extends Reader<int> {
const Int32Reader() : super();
@override
- int get size => 2;
+ int get size => 4;
@override
int read(BufferPointer bp) => bp._getInt32();
}
/**
+ * The reader of 64-bit signed integers.
+ */
+class Int64Reader extends Reader<int> {
+ const Int64Reader() : super();
+
+ @override
+ int get size => 8;
+
+ @override
+ int read(BufferPointer bp) => bp._getInt64();
+}
+
+/**
* The reader of 8-bit signed integers.
*/
class Int8Reader extends Reader<int> {
« 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