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

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

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Fixed some rebase errors Created 3 years, 11 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 | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | runtime/vm/kernel.h » ('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 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 writeUriToSource(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 writeUriToSource(Program program) {
147 program.uriToLineStarts.keys.forEach((uri) { 147 program.uriToSource.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 Source source = program.uriToSource[uri] ?? new Source([], '');
154 String sourceCode = source.source;
155 writeStringTableEntry(sourceCode);
156 List<int> lineStarts = source.lineStarts;
154 writeUInt30(lineStarts.length); 157 writeUInt30(lineStarts.length);
155 int previousLineStart = 0; 158 int previousLineStart = 0;
156 lineStarts.forEach((lineStart) { 159 lineStarts.forEach((lineStart) {
157 writeUInt30(lineStart - previousLineStart); 160 writeUInt30(lineStart - previousLineStart);
158 previousLineStart = lineStart; 161 previousLineStart = lineStart;
159 }); 162 });
160 } 163 }
161 } 164 }
162 165
163 void writeLibraryImportTable(LibraryImportTable imports) { 166 void writeLibraryImportTable(LibraryImportTable imports) {
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 void flush() { 1220 void flush() {
1218 _sink.add(_buffer.sublist(0, length)); 1221 _sink.add(_buffer.sublist(0, length));
1219 _buffer = new Uint8List(SIZE); 1222 _buffer = new Uint8List(SIZE);
1220 length = 0; 1223 length = 0;
1221 } 1224 }
1222 1225
1223 void flushAndDestroy() { 1226 void flushAndDestroy() {
1224 _sink.add(_buffer.sublist(0, length)); 1227 _sink.add(_buffer.sublist(0, length));
1225 } 1228 }
1226 } 1229 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | runtime/vm/kernel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698