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

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

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Updated kernels binary.md too. Created 4 years 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_from_binary; 4 library kernel.ast_from_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import 'tag.dart'; 7 import 'tag.dart';
8 import 'loader.dart'; 8 import 'loader.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'package:kernel/transformations/flags.dart'; 10 import 'package:kernel/transformations/flags.dart';
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 } 171 }
172 172
173 Program readProgramFile() { 173 Program readProgramFile() {
174 int magic = readMagicWord(); 174 int magic = readMagicWord();
175 if (magic != Tag.ProgramFile) { 175 if (magic != Tag.ProgramFile) {
176 throw fail('This is not a binary dart file. ' 176 throw fail('This is not a binary dart file. '
177 'Magic number was: ${magic.toRadixString(16)}'); 177 'Magic number was: ${magic.toRadixString(16)}');
178 } 178 }
179 readStringTable(); 179 readStringTable();
180 Map<String, List<int>> uriToLineStarts = readUriToLineStarts(); 180 Map<String, LineStartsAndSource> uriToLineStartsAndSource =
181 readUriToLineStartsAndSource();
181 importTable.length = readUInt(); 182 importTable.length = readUInt();
182 for (int i = 0; i < importTable.length; ++i) { 183 for (int i = 0; i < importTable.length; ++i) {
183 importTable[i] = new Library(null); 184 importTable[i] = new Library(null);
184 } 185 }
185 for (int i = 0; i < importTable.length; ++i) { 186 for (int i = 0; i < importTable.length; ++i) {
186 _currentLibrary = importTable[i]; 187 _currentLibrary = importTable[i];
187 readLibrary(); 188 readLibrary();
188 } 189 }
189 var mainMethod = readMemberReference(allowNull: true); 190 var mainMethod = readMemberReference(allowNull: true);
190 return new Program(importTable, uriToLineStarts)..mainMethod = mainMethod; 191 return new Program(importTable, uriToLineStartsAndSource)
192 ..mainMethod = mainMethod;
191 } 193 }
192 194
193 Map<String, List<int>> readUriToLineStarts() { 195 Map<String, LineStartsAndSource> readUriToLineStartsAndSource() {
194 readSourceUriTable(); 196 readSourceUriTable();
195 int length = _sourceUriTable.length; 197 int length = _sourceUriTable.length;
196 Map<String, List<int>> uriToLineStarts = {}; 198 Map<String, LineStartsAndSource> uriToLineStarts = {};
Kevin Millikin (Google) 2016/12/20 12:03:33 <String, LineStartsAndSource>{}.
jensj 2016/12/20 13:30:22 Done.
197 for (int i = 0; i < length; ++i) { 199 for (int i = 0; i < length; ++i) {
198 String uri = _sourceUriTable[i]; 200 String uri = _sourceUriTable[i];
201 String sourceCode = readStringEntry();
199 int lineCount = readUInt(); 202 int lineCount = readUInt();
200 List<int> lineStarts = new List<int>(lineCount); 203 List<int> lineStarts = new List<int>(lineCount);
201 int previousLineStart = 0; 204 int previousLineStart = 0;
202 for (int j = 0; j < lineCount; ++j) { 205 for (int j = 0; j < lineCount; ++j) {
203 int lineStart = readUInt() + previousLineStart; 206 int lineStart = readUInt() + previousLineStart;
204 lineStarts[j] = lineStart; 207 lineStarts[j] = lineStart;
205 previousLineStart = lineStart; 208 previousLineStart = lineStart;
206 } 209 }
207 uriToLineStarts[uri] = lineStarts; 210 uriToLineStarts[uri] = new LineStartsAndSource(lineStarts, sourceCode);
208 } 211 }
209 return uriToLineStarts; 212 return uriToLineStarts;
210 } 213 }
211 214
212 void _fillLazilyLoadedList( 215 void _fillLazilyLoadedList(
213 List<TreeNode> list, void buildObject(int tag, int index)) { 216 List<TreeNode> list, void buildObject(int tag, int index)) {
214 int length = readUInt(); 217 int length = readUInt();
215 list.length = length; 218 list.length = length;
216 for (int i = 0; i < length; ++i) { 219 for (int i = 0; i < length; ++i) {
217 int tag = readByte(); 220 int tag = readByte();
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 isFinal: flags & 0x1 != 0, 934 isFinal: flags & 0x1 != 0,
932 isConst: flags & 0x2 != 0); 935 isConst: flags & 0x2 != 0);
933 } 936 }
934 937
935 int readOffset() { 938 int readOffset() {
936 // Offset is saved as unsigned, 939 // Offset is saved as unsigned,
937 // but actually ranges from -1 and up (thus the -1) 940 // but actually ranges from -1 and up (thus the -1)
938 return readUInt() - 1; 941 return readUInt() - 1;
939 } 942 }
940 } 943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698