| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 for (var entry in indexer.entries) { | 85 for (var entry in indexer.entries) { |
| 86 writeStringTableEntry(entry.value); | 86 writeStringTableEntry(entry.value); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void writeStringReference(String string) { | 90 void writeStringReference(String string) { |
| 91 writeUInt30(_stringIndexer[string]); | 91 writeUInt30(_stringIndexer[string]); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void writeUriReference(String string) { | 94 void writeUriReference(String string) { |
| 95 writeUInt30(_sourceUriIndexer[string]); | 95 int index = _sourceUriIndexer[string]; |
| 96 if (index == null) { |
| 97 // Assume file was loaded without linking. Bail out to empty string. |
| 98 index = _sourceUriIndexer[""]; |
| 99 } |
| 100 writeUInt30(index); |
| 96 } | 101 } |
| 97 | 102 |
| 98 void writeList(List items, writeItem(x)) { | 103 void writeList(List items, writeItem(x)) { |
| 99 writeUInt30(items.length); | 104 writeUInt30(items.length); |
| 100 items.forEach(writeItem); | 105 items.forEach(writeItem); |
| 101 } | 106 } |
| 102 | 107 |
| 103 void writeNodeList(List<Node> nodes) { | 108 void writeNodeList(List<Node> nodes) { |
| 104 writeList(nodes, writeNode); | 109 writeList(nodes, writeNode); |
| 105 } | 110 } |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 void flush() { | 1249 void flush() { |
| 1245 _sink.add(_buffer.sublist(0, length)); | 1250 _sink.add(_buffer.sublist(0, length)); |
| 1246 _buffer = new Uint8List(SIZE); | 1251 _buffer = new Uint8List(SIZE); |
| 1247 length = 0; | 1252 length = 0; |
| 1248 } | 1253 } |
| 1249 | 1254 |
| 1250 void flushAndDestroy() { | 1255 void flushAndDestroy() { |
| 1251 _sink.add(_buffer.sublist(0, length)); | 1256 _sink.add(_buffer.sublist(0, length)); |
| 1252 } | 1257 } |
| 1253 } | 1258 } |
| OLD | NEW |