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

Side by Side Diff: pkg/kernel/lib/binary/ast_to_binary.dart

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Updated kernels binary.md too. Created 3 years, 12 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
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 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 writeByte(node.baseClassKind.index); 130 writeByte(node.baseClassKind.index);
131 writeByte(node.valueBits); 131 writeByte(node.valueBits);
132 } 132 }
133 } 133 }
134 134
135 void writeProgramFile(Program program) { 135 void writeProgramFile(Program program) {
136 writeMagicWord(Tag.ProgramFile); 136 writeMagicWord(Tag.ProgramFile);
137 _importTable = new ProgramImportTable(program); 137 _importTable = new ProgramImportTable(program);
138 _stringIndexer.build(program); 138 _stringIndexer.build(program);
139 writeStringTable(_stringIndexer); 139 writeStringTable(_stringIndexer);
140 writeUriToLineStarts(program); 140 writeUriToLineStartsAndSource(program);
141 writeList(program.libraries, writeNode); 141 writeList(program.libraries, writeNode);
142 writeMemberReference(program.mainMethod, allowNull: true); 142 writeMemberReference(program.mainMethod, allowNull: true);
143 _flush(); 143 _flush();
144 } 144 }
145 145
146 void writeUriToLineStarts(Program program) { 146 void writeUriToLineStartsAndSource(Program program) {
147 program.uriToLineStarts.keys.forEach((uri) { 147 program.uriToLineStartsAndSource.keys.forEach((uri) {
148 _sourceUriIndexer.put(uri); 148 _sourceUriIndexer.put(uri);
149 }); 149 });
150 writeStringTable(_sourceUriIndexer); 150 writeStringTable(_sourceUriIndexer);
151 for (int i = 0; i < _sourceUriIndexer.entries.length; i++) { 151 for (int i = 0; i < _sourceUriIndexer.entries.length; i++) {
152 String uri = _sourceUriIndexer.entries[i].value; 152 String uri = _sourceUriIndexer.entries[i].value;
153 List<int> lineStarts = program.uriToLineStarts[uri] ?? []; 153 LineStartsAndSource lineStartsAndSource =
154 program.uriToLineStartsAndSource[uri] ??
Kevin Millikin (Google) 2016/12/20 12:03:33 Can this be null? It's not clear that it can, or
jensj 2016/12/20 13:30:22 It iterates over all entries in StringIndexer, tha
155 new LineStartsAndSource([], "");
156 String sourceCode = lineStartsAndSource.source;
157 writeStringTableEntry(sourceCode);
158 List<int> lineStarts = lineStartsAndSource.lineStarts;
154 writeUInt30(lineStarts.length); 159 writeUInt30(lineStarts.length);
155 int previousLineStart = 0; 160 int previousLineStart = 0;
156 lineStarts.forEach((lineStart) { 161 lineStarts.forEach((lineStart) {
157 writeUInt30(lineStart - previousLineStart); 162 writeUInt30(lineStart - previousLineStart);
158 previousLineStart = lineStart; 163 previousLineStart = lineStart;
159 }); 164 });
160 } 165 }
161 } 166 }
162 167
163 void writeLibraryImportTable(LibraryImportTable imports) { 168 void writeLibraryImportTable(LibraryImportTable imports) {
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 void flush() { 1222 void flush() {
1218 _sink.add(_buffer.sublist(0, length)); 1223 _sink.add(_buffer.sublist(0, length));
1219 _buffer = new Uint8List(SIZE); 1224 _buffer = new Uint8List(SIZE);
1220 length = 0; 1225 length = 0;
1221 } 1226 }
1222 1227
1223 void flushAndDestroy() { 1228 void flushAndDestroy() {
1224 _sink.add(_buffer.sublist(0, length)); 1229 _sink.add(_buffer.sublist(0, length));
1225 } 1230 }
1226 } 1231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698