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 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer/src/generated/ast.dart' show CompilationUnit; | 9 import 'package:analyzer/src/generated/ast.dart' show CompilationUnit; |
10 import 'package:analyzer/src/generated/element.dart' | 10 import 'package:analyzer/src/generated/element.dart' |
11 show CompilationUnitElement, LibraryElement; | 11 show CompilationUnitElement, LibraryElement; |
12 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 12 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
13 import 'package:path/path.dart' as path; | 13 import 'package:path/path.dart' as path; |
14 | 14 |
15 import 'package:dev_compiler/devc.dart' show AbstractCompiler; | 15 import 'package:dev_compiler/devc.dart' show AbstractCompiler; |
16 import 'package:dev_compiler/src/info.dart'; | 16 import 'package:dev_compiler/src/info.dart'; |
17 import 'package:dev_compiler/src/utils.dart' show canonicalLibraryName; | 17 import 'package:dev_compiler/src/utils.dart' show canonicalLibraryName; |
18 import 'package:dev_compiler/src/checker/rules.dart'; | 18 import 'package:dev_compiler/src/checker/rules.dart'; |
19 import 'package:dev_compiler/src/options.dart'; | 19 import 'package:dev_compiler/src/options.dart' show CodegenOptions; |
20 | 20 |
21 abstract class CodeGenerator { | 21 abstract class CodeGenerator { |
22 final AbstractCompiler compiler; | 22 final AbstractCompiler compiler; |
23 final String outDir; | 23 final String outDir; |
24 final Uri root; | 24 final Uri root; |
25 final TypeRules rules; | 25 final TypeRules rules; |
26 final AnalysisContext context; | 26 final AnalysisContext context; |
27 final CompilerOptions options; | 27 final CodegenOptions options; |
28 | 28 |
29 CodeGenerator(AbstractCompiler compiler) | 29 CodeGenerator(AbstractCompiler compiler) |
30 : compiler = compiler, | 30 : compiler = compiler, |
31 outDir = path.absolute(compiler.options.outputDir), | 31 outDir = path.absolute(compiler.options.codegenOptions.outputDir), |
32 root = compiler.entryPointUri, | 32 root = compiler.entryPointUri, |
33 rules = compiler.rules, | 33 rules = compiler.rules, |
34 context = compiler.context, | 34 context = compiler.context, |
35 options = compiler.options; | 35 options = compiler.options.codegenOptions; |
36 | 36 |
37 /// Return a hash, if any, that can be used for caching purposes. When two | 37 /// Return a hash, if any, that can be used for caching purposes. When two |
38 /// invocations to this function return the same hash, the underlying | 38 /// invocations to this function return the same hash, the underlying |
39 /// code-generator generated the same code. | 39 /// code-generator generated the same code. |
40 String generateLibrary(LibraryUnit unit, LibraryInfo info); | 40 String generateLibrary(LibraryUnit unit, LibraryInfo info); |
41 | 41 |
42 static List<String> _searchPaths = () { | 42 static List<String> _searchPaths = () { |
43 // TODO(vsm): Can we remove redundancy with multi_package_resolver logic? | 43 // TODO(vsm): Can we remove redundancy with multi_package_resolver logic? |
44 var packagePaths = | 44 var packagePaths = |
45 new String.fromEnvironment('package_paths', defaultValue: null); | 45 new String.fromEnvironment('package_paths', defaultValue: null); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Not a package. | 137 // Not a package. |
138 // TODO(leafp) These may need to be adjusted | 138 // TODO(leafp) These may need to be adjusted |
139 // relative to the import location | 139 // relative to the import location |
140 return new Uri(path: suffix); | 140 return new Uri(path: suffix); |
141 } | 141 } |
142 assert(index == 0); | 142 assert(index == 0); |
143 return new Uri( | 143 return new Uri( |
144 scheme: 'package', path: path.joinAll(parts.sublist(index + 1))); | 144 scheme: 'package', path: path.joinAll(parts.sublist(index + 1))); |
145 } | 145 } |
146 } | 146 } |
OLD | NEW |