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

Side by Side Diff: pkg/fletchc/lib/compiler.dart

Issue 1170123004: Rename CompiledFunction to FletchFunctionBuilder and CompiledClass to FletchClassBuilder. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 6 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) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.compiler; 5 library fletchc.compiler;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:convert' show 10 import 'dart:convert' show
(...skipping 18 matching lines...) Expand all
29 SourceFileProvider; 29 SourceFileProvider;
30 30
31 import 'package:compiler/src/elements/elements.dart' show 31 import 'package:compiler/src/elements/elements.dart' show
32 ConstructorElement, 32 ConstructorElement,
33 ClassElement, 33 ClassElement,
34 FunctionElement; 34 FunctionElement;
35 35
36 import 'package:compiler/src/filenames.dart' show 36 import 'package:compiler/src/filenames.dart' show
37 appendSlash; 37 appendSlash;
38 38
39 import 'src/compiled_function.dart' show 39 import 'src/fletch_function_builder.dart' show
40 CompiledFunction; 40 FletchFunctionBuilder;
41 41
42 import 'src/debug_info.dart'; 42 import 'src/debug_info.dart';
43 43
44 import 'src/fletch_native_descriptor.dart' show 44 import 'src/fletch_native_descriptor.dart' show
45 FletchNativeDescriptor; 45 FletchNativeDescriptor;
46 46
47 import 'src/fletch_backend.dart' show 47 import 'src/fletch_backend.dart' show
48 FletchBackend; 48 FletchBackend;
49 49
50 import 'src/compiled_class.dart' show 50 import 'src/fletch_class_builder.dart' show
51 CompiledClass; 51 FletchClassBuilder;
52 52
53 import 'package:compiler/src/apiimpl.dart' as apiimpl; 53 import 'package:compiler/src/apiimpl.dart' as apiimpl;
54 54
55 import 'src/fletch_compiler.dart' as implementation; 55 import 'src/fletch_compiler.dart' as implementation;
56 56
57 import 'bytecodes.dart' show 57 import 'bytecodes.dart' show
58 Bytecode; 58 Bytecode;
59 59
60 import 'src/fletch_selector.dart'; 60 import 'src/fletch_selector.dart';
61 61
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 Map<String, FletchNativeDescriptor> natives = 235 Map<String, FletchNativeDescriptor> natives =
236 <String, FletchNativeDescriptor>{}; 236 <String, FletchNativeDescriptor>{};
237 Map<String, String> names = <String, String>{}; 237 Map<String, String> names = <String, String>{};
238 FletchNativeDescriptor.decode(data, natives, names); 238 FletchNativeDescriptor.decode(data, natives, names);
239 _compiler.context.nativeDescriptors = natives; 239 _compiler.context.nativeDescriptors = natives;
240 _compiler.context.setNames(names); 240 _compiler.context.setNames(names);
241 } 241 }
242 242
243 Uri get fletchVm => _compiler.fletchVm; 243 Uri get fletchVm => _compiler.fletchVm;
244 244
245 CompiledFunction lookupCompiledFunction(int methodId) { 245 FletchFunctionBuilder lookupFletchFunctionBuilder(int methodId) {
246 CompiledFunction function = _compiler.context.backend.functions[methodId]; 246 FletchFunctionBuilder function = _compiler.context.backend.functions[methodI d];
ahe 2015/06/09 09:14:56 Long line.
Anders Johnsen 2015/06/09 10:15:40 Done.
247 assert(function.methodId == methodId); 247 assert(function.methodId == methodId);
248 return function; 248 return function;
249 } 249 }
250 250
251 String lookupFunctionName(int methodId) { 251 String lookupFunctionName(int methodId) {
252 CompiledFunction function = lookupCompiledFunction(methodId); 252 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
253 if (function == null) return ''; 253 if (function == null) return '';
254 if (function.isConstructor) { 254 if (function.isConstructor) {
255 ConstructorElement constructor = function.element; 255 ConstructorElement constructor = function.element;
256 ClassElement enclosing = constructor.enclosingClass; 256 ClassElement enclosing = constructor.enclosingClass;
257 String name = (constructor.name == null || constructor.name.length == 0) 257 String name = (constructor.name == null || constructor.name.length == 0)
258 ? '' 258 ? ''
259 : '.${constructor.name}'; 259 : '.${constructor.name}';
260 String postfix = function.isInitializerList ? ' initializer' : ''; 260 String postfix = function.isInitializerList ? ' initializer' : '';
261 return '${enclosing.name}$name$postfix'; 261 return '${enclosing.name}$name$postfix';
262 } 262 }
263 String functionName = function.name; 263 String functionName = function.name;
264 if (functionName == null) return ''; 264 if (functionName == null) return '';
265 CompiledClass memberOf = function.memberOf; 265 FletchClassBuilder memberOf = function.memberOf;
266 if (memberOf == null) return functionName; 266 if (memberOf == null) return functionName;
267 if (memberOf.element == null) return functionName; 267 if (memberOf.element == null) return functionName;
268 if (functionName.isEmpty) return memberOf.element.name; 268 if (functionName.isEmpty) return memberOf.element.name;
269 return '${memberOf.element.name}.$functionName'; 269 return '${memberOf.element.name}.$functionName';
270 } 270 }
271 271
272 CompiledClass lookupCompiledClass(int classId) { 272 FletchClassBuilder lookupFletchClassBuilder(int classId) {
273 CompiledClass klass = _compiler.context.backend.classes[classId]; 273 FletchClassBuilder klass = _compiler.context.backend.classes[classId];
274 assert(klass.id == classId); 274 assert(klass.id == classId);
275 return klass; 275 return klass;
276 } 276 }
277 277
278 String lookupClassName(int classId) { 278 String lookupClassName(int classId) {
279 CompiledClass klass = lookupCompiledClass(classId); 279 FletchClassBuilder klass = lookupFletchClassBuilder(classId);
280 if (klass.element != null) return klass.element.name; 280 if (klass.element != null) return klass.element.name;
281 // TODO(ager): Provide better information for closures. 281 // TODO(ager): Provide better information for closures.
282 if (_compiler.context.backend.closureClasses.values.contains(klass)) { 282 if (_compiler.context.backend.closureClasses.values.contains(klass)) {
283 return 'closure'; 283 return 'closure';
284 } 284 }
285 CompiledFunction function = 285 FletchFunctionBuilder function =
286 _compiler.context.backend.compiledFunctionFromTearoffClass(klass); 286 _compiler.context.backend.functionBuilderFromTearoffClass(klass);
287 if (function != null) return 'tearoff of ${function.name}'; 287 if (function != null) return 'tearoff of ${function.name}';
288 return 'unknown'; 288 return 'unknown';
289 } 289 }
290 290
291 String lookupFunctionNameBySelector(int selector) { 291 String lookupFunctionNameBySelector(int selector) {
292 int id = FletchSelector.decodeId(selector); 292 int id = FletchSelector.decodeId(selector);
293 return _compiler.context.symbols[id]; 293 return _compiler.context.symbols[id];
294 } 294 }
295 295
296 List<Bytecode> lookupFunctionBytecodes(int methodId) { 296 List<Bytecode> lookupFunctionBytecodes(int methodId) {
297 return lookupCompiledFunction(methodId).builder.bytecodes; 297 return lookupFletchFunctionBuilder(methodId).builder.bytecodes;
298 } 298 }
299 299
300 Iterable<int> lookupFunctionIdsByName(String name) { 300 Iterable<int> lookupFunctionIdsByName(String name) {
301 return _compiler.context.backend.functions 301 return _compiler.context.backend.functions
302 .where((f) => f.name == name) 302 .where((f) => f.name == name)
303 .map((f) => f.methodId); 303 .map((f) => f.methodId);
304 } 304 }
305 305
306 int mainMethodId() { 306 int mainMethodId() {
307 FunctionElement mainFunctionElement = _compiler.mainFunction; 307 FunctionElement mainFunctionElement = _compiler.mainFunction;
308 CompiledFunction mainMethod = 308 FletchFunctionBuilder mainMethod =
309 _compiler.context.backend.compiledFunctions[mainFunctionElement]; 309 _compiler.context.backend.functionBuilders[mainFunctionElement];
310 return mainMethod.methodId; 310 return mainMethod.methodId;
311 } 311 }
312 312
313 String astString(int methodId, int bytecodeIndex) { 313 String astString(int methodId, int bytecodeIndex) {
314 CompiledFunction function = lookupCompiledFunction(methodId); 314 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
315 _compiler.context.backend.ensureDebugInfo(function); 315 _compiler.context.backend.ensureDebugInfo(function);
316 return function.debugInfo.astStringFor(bytecodeIndex); 316 return function.debugInfo.astStringFor(bytecodeIndex);
317 } 317 }
318 318
319 String fileAndLineString(int methodId, int bytecodeIndex) { 319 String fileAndLineString(int methodId, int bytecodeIndex) {
320 CompiledFunction function = lookupCompiledFunction(methodId); 320 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
321 _compiler.context.backend.ensureDebugInfo(function); 321 _compiler.context.backend.ensureDebugInfo(function);
322 return function.debugInfo.fileAndLineStringFor(bytecodeIndex); 322 return function.debugInfo.fileAndLineStringFor(bytecodeIndex);
323 } 323 }
324 324
325 String sourceListString(int methodId, 325 String sourceListString(int methodId,
326 int bytecodeIndex, 326 int bytecodeIndex,
327 {int contextLines : 5}) { 327 {int contextLines : 5}) {
328 CompiledFunction function = lookupCompiledFunction(methodId); 328 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
329 _compiler.context.backend.ensureDebugInfo(function); 329 _compiler.context.backend.ensureDebugInfo(function);
330 return function.debugInfo.sourceListStringFor(bytecodeIndex, contextLines); 330 return function.debugInfo.sourceListStringFor(bytecodeIndex, contextLines);
331 } 331 }
332 332
333 SourceLocation sourceLocation(int methodId, int bytecodeIndex) { 333 SourceLocation sourceLocation(int methodId, int bytecodeIndex) {
334 CompiledFunction function = lookupCompiledFunction(methodId); 334 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
335 _compiler.context.backend.ensureDebugInfo(function); 335 _compiler.context.backend.ensureDebugInfo(function);
336 return function.debugInfo.sourceLocationFor(bytecodeIndex); 336 return function.debugInfo.sourceLocationFor(bytecodeIndex);
337 } 337 }
338 338
339 ScopeInfo scopeInfo(int methodId, int bytecodeIndex) { 339 ScopeInfo scopeInfo(int methodId, int bytecodeIndex) {
340 CompiledFunction function = lookupCompiledFunction(methodId); 340 FletchFunctionBuilder function = lookupFletchFunctionBuilder(methodId);
341 _compiler.context.backend.ensureDebugInfo(function); 341 _compiler.context.backend.ensureDebugInfo(function);
342 return function.debugInfo.scopeInfoFor(bytecodeIndex); 342 return function.debugInfo.scopeInfoFor(bytecodeIndex);
343 } 343 }
344 344
345 DebugInfo debugInfoForPosition(String file, int position) { 345 DebugInfo debugInfoForPosition(String file, int position) {
346 return _compiler.debugInfoForPosition(file, position); 346 return _compiler.debugInfoForPosition(file, position);
347 } 347 }
348 348
349 int positionInFileFromPattern(String file, int line, String pattern) { 349 int positionInFileFromPattern(String file, int line, String pattern) {
350 return _compiler.positionInFileFromPattern(file, line, pattern); 350 return _compiler.positionInFileFromPattern(file, line, pattern);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 Uri _guessPatchRoot(Uri libraryRoot) { 461 Uri _guessPatchRoot(Uri libraryRoot) {
462 Uri guess = libraryRoot.resolve('../../fletch/'); 462 Uri guess = libraryRoot.resolve('../../fletch/');
463 if (_looksLikePatchRoot(guess)) return guess; 463 if (_looksLikePatchRoot(guess)) return guess;
464 return null; 464 return null;
465 } 465 }
466 466
467 bool _looksLikePatchRoot(Uri uri) { 467 bool _looksLikePatchRoot(Uri uri) {
468 return _containsFile(uri, 'lib/core/core_patch.dart'); 468 return _containsFile(uri, 'lib/core/core_patch.dart');
469 } 469 }
OLDNEW
« no previous file with comments | « no previous file | pkg/fletchc/lib/incremental/library_updater.dart » ('j') | pkg/fletchc/lib/incremental/library_updater.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698