OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 | 4 |
5 library dev_compiler.src.codegen.code_generator; | 5 library dev_compiler.src.codegen.code_generator; |
6 | 6 |
7 import 'package:analyzer/src/generated/element.dart' | 7 import 'package:analyzer/src/generated/element.dart' |
8 show CompilationUnitElement, LibraryElement; | 8 show CompilationUnitElement, LibraryElement; |
9 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 9 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
10 import 'package:analyzer/src/task/strong/rules.dart'; | |
11 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
12 | 11 |
13 import '../compiler.dart' show AbstractCompiler; | 12 import '../compiler.dart' show AbstractCompiler; |
14 import '../info.dart'; | 13 import '../info.dart'; |
15 import '../utils.dart' show canonicalLibraryName; | 14 import '../utils.dart' show canonicalLibraryName; |
16 import '../options.dart' show CodegenOptions; | 15 import '../options.dart' show CodegenOptions; |
17 | 16 |
18 abstract class CodeGenerator { | 17 abstract class CodeGenerator { |
19 final AbstractCompiler compiler; | 18 final AbstractCompiler compiler; |
20 final TypeRules rules; | |
21 final AnalysisContext context; | 19 final AnalysisContext context; |
22 final CodegenOptions options; | 20 final CodegenOptions options; |
23 | 21 |
24 CodeGenerator(AbstractCompiler compiler) | 22 CodeGenerator(AbstractCompiler compiler) |
25 : compiler = compiler, | 23 : compiler = compiler, |
26 rules = new TypeRules(compiler.context.typeProvider), | |
27 context = compiler.context, | 24 context = compiler.context, |
28 options = compiler.options.codegenOptions; | 25 options = compiler.options.codegenOptions; |
29 | 26 |
30 /// Return a hash, if any, that can be used for caching purposes. When two | 27 /// Return a hash, if any, that can be used for caching purposes. When two |
31 /// invocations to this function return the same hash, the underlying | 28 /// invocations to this function return the same hash, the underlying |
32 /// code-generator generated the same code. | 29 /// code-generator generated the same code. |
33 String generateLibrary(LibraryUnit unit); | 30 String generateLibrary(LibraryUnit unit); |
34 | 31 |
35 static List<String> _searchPaths = () { | 32 static List<String> _searchPaths = () { |
36 // TODO(vsm): Can we remove redundancy with multi_package_resolver logic? | 33 // TODO(vsm): Can we remove redundancy with multi_package_resolver logic? |
(...skipping 83 matching lines...) Loading... |
120 // Not a package. | 117 // Not a package. |
121 // TODO(leafp) These may need to be adjusted | 118 // TODO(leafp) These may need to be adjusted |
122 // relative to the import location | 119 // relative to the import location |
123 return new Uri(path: suffix); | 120 return new Uri(path: suffix); |
124 } | 121 } |
125 assert(index == 0); | 122 assert(index == 0); |
126 return new Uri( | 123 return new Uri( |
127 scheme: 'package', path: path.joinAll(parts.sublist(index + 1))); | 124 scheme: 'package', path: path.joinAll(parts.sublist(index + 1))); |
128 } | 125 } |
129 } | 126 } |
OLD | NEW |