| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |