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

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

Issue 1691033002: Fix table size in flatbuffers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 } 200 }
201 201
202 /** 202 /**
203 * End the current table and return its offset. 203 * End the current table and return its offset.
204 */ 204 */
205 Offset endTable() { 205 Offset endTable() {
206 if (_currentVTable == null) { 206 if (_currentVTable == null) {
207 throw new StateError('Start a table before ending it.'); 207 throw new StateError('Start a table before ending it.');
208 } 208 }
209 // Prepare the size of the current table.
210 _currentVTable.tableSize = _tail - _currentTableEndTail;
211 // Prepare for writing the VTable. 209 // Prepare for writing the VTable.
212 _prepare(4, 1); 210 _prepare(4, 1);
213 int tableTail = _tail; 211 int tableTail = _tail;
212 // Prepare the size of the current table.
213 _currentVTable.tableSize = tableTail - _currentTableEndTail;
214 // Prepare the VTable to use for the current table. 214 // Prepare the VTable to use for the current table.
215 int vTableTail; 215 int vTableTail;
216 { 216 {
217 _currentVTable.computeFieldOffsets(tableTail); 217 _currentVTable.computeFieldOffsets(tableTail);
218 // Try to find an existing compatible VTable. 218 // Try to find an existing compatible VTable.
219 for (_VTable vTable in _vTables) { 219 for (_VTable vTable in _vTables) {
220 if (_currentVTable.canUseExistingVTable(vTable)) { 220 if (_currentVTable.canUseExistingVTable(vTable)) {
221 vTableTail = vTable.tail; 221 vTableTail = vTable.tail;
222 } 222 }
223 } 223 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // Table size. 759 // Table size.
760 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN); 760 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN);
761 bufOffset += 2; 761 bufOffset += 2;
762 // Field offsets. 762 // Field offsets.
763 for (int fieldOffset in fieldOffsets) { 763 for (int fieldOffset in fieldOffsets) {
764 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN); 764 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN);
765 bufOffset += 2; 765 bufOffset += 2;
766 } 766 }
767 } 767 }
768 } 768 }
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