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 library kernel.ast_to_binary; | 4 library kernel.ast_to_binary; |
5 | 5 |
6 import '../ast.dart'; | 6 import '../ast.dart'; |
7 import '../import_table.dart'; | 7 import '../import_table.dart'; |
8 import 'tag.dart'; | 8 import 'tag.dart'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 void writeCanonicalNameEntry(CanonicalName node) { | 139 void writeCanonicalNameEntry(CanonicalName node) { |
140 var parent = node.parent; | 140 var parent = node.parent; |
141 if (parent.isRoot) { | 141 if (parent.isRoot) { |
142 writeByte(0); | 142 writeByte(0); |
143 } else { | 143 } else { |
144 writeUInt30(parent.index + 1); | 144 writeUInt30(parent.index + 1); |
145 } | 145 } |
146 writeStringReference(node.name); | 146 writeStringReference(node.name); |
147 } | 147 } |
148 | 148 |
| 149 StringIndexer get stringIndexer => _stringIndexer; |
| 150 void flush() => _flush(); |
| 151 |
149 void writeProgramFile(Program program) { | 152 void writeProgramFile(Program program) { |
150 program.computeCanonicalNames(); | 153 program.computeCanonicalNames(); |
151 writeMagicWord(Tag.ProgramFile); | 154 writeMagicWord(Tag.ProgramFile); |
152 _stringIndexer.scanProgram(program); | 155 _stringIndexer.scanProgram(program); |
153 writeStringTable(_stringIndexer); | 156 writeStringTable(_stringIndexer); |
154 writeUriToSource(program); | 157 writeUriToSource(program); |
155 writeLinkTable(program); | 158 writeLinkTable(program); |
156 writeList(program.libraries, writeNode); | 159 writeList(program.libraries, writeNode); |
157 writeMemberReference(program.mainMethod, allowNull: true); | 160 writeMemberReference(program.mainMethod, allowNull: true); |
158 _flush(); | 161 _flush(); |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 void flush() { | 1300 void flush() { |
1298 _sink.add(_buffer.sublist(0, length)); | 1301 _sink.add(_buffer.sublist(0, length)); |
1299 _buffer = new Uint8List(SIZE); | 1302 _buffer = new Uint8List(SIZE); |
1300 length = 0; | 1303 length = 0; |
1301 } | 1304 } |
1302 | 1305 |
1303 void flushAndDestroy() { | 1306 void flushAndDestroy() { |
1304 _sink.add(_buffer.sublist(0, length)); | 1307 _sink.add(_buffer.sublist(0, length)); |
1305 } | 1308 } |
1306 } | 1309 } |
OLD | NEW |