OLD | NEW |
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 | 4 |
5 library fasta.kernel_target; | 5 library fasta.kernel_target; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:kernel/ast.dart' | 9 import 'package:kernel/ast.dart' |
10 show | 10 show |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 TypeBuilder, | 87 TypeBuilder, |
88 TypeDeclarationBuilder, | 88 TypeDeclarationBuilder, |
89 TypeVariableBuilder; | 89 TypeVariableBuilder; |
90 | 90 |
91 import 'verifier.dart' show verifyProgram; | 91 import 'verifier.dart' show verifyProgram; |
92 | 92 |
93 class KernelTarget extends TargetImplementation { | 93 class KernelTarget extends TargetImplementation { |
94 /// The [FileSystem] which should be used to access files. | 94 /// The [FileSystem] which should be used to access files. |
95 final FileSystem fileSystem; | 95 final FileSystem fileSystem; |
96 | 96 |
| 97 /// Whether comments should be scanned and parsed. |
| 98 final bool includeComments; |
| 99 |
97 final DillTarget dillTarget; | 100 final DillTarget dillTarget; |
98 | 101 |
99 /// Shared with [CompilerContext]. | 102 /// Shared with [CompilerContext]. |
100 final Map<String, Source> uriToSource; | 103 final Map<String, Source> uriToSource; |
101 | 104 |
102 SourceLoader<Library> loader; | 105 SourceLoader<Library> loader; |
103 | 106 |
104 Program program; | 107 Program program; |
105 | 108 |
106 final List<LocatedMessage> errors = <LocatedMessage>[]; | 109 final List<LocatedMessage> errors = <LocatedMessage>[]; |
107 | 110 |
108 final TypeBuilder dynamicType = | 111 final TypeBuilder dynamicType = |
109 new KernelNamedTypeBuilder("dynamic", null, -1, null); | 112 new KernelNamedTypeBuilder("dynamic", null, -1, null); |
110 | 113 |
111 bool get strongMode => backendTarget.strongMode; | 114 bool get strongMode => backendTarget.strongMode; |
112 | 115 |
113 bool get disableTypeInference => backendTarget.disableTypeInference; | 116 bool get disableTypeInference => backendTarget.disableTypeInference; |
114 | 117 |
115 KernelTarget( | 118 KernelTarget(this.fileSystem, this.includeComments, DillTarget dillTarget, |
116 this.fileSystem, DillTarget dillTarget, UriTranslator uriTranslator, | 119 UriTranslator uriTranslator, |
117 [Map<String, Source> uriToSource]) | 120 [Map<String, Source> uriToSource]) |
118 : dillTarget = dillTarget, | 121 : dillTarget = dillTarget, |
119 uriToSource = uriToSource ?? CompilerContext.current.uriToSource, | 122 uriToSource = uriToSource ?? CompilerContext.current.uriToSource, |
120 super(dillTarget.ticker, uriTranslator, dillTarget.backendTarget) { | 123 super(dillTarget.ticker, uriTranslator, dillTarget.backendTarget) { |
121 resetCrashReporting(); | 124 resetCrashReporting(); |
122 loader = createLoader(); | 125 loader = createLoader(); |
123 } | 126 } |
124 | 127 |
125 SourceLoader<Library> createLoader() => | 128 SourceLoader<Library> createLoader() => |
126 new SourceLoader<Library>(fileSystem, this); | 129 new SourceLoader<Library>(fileSystem, includeComments, this); |
127 | 130 |
128 void addSourceInformation( | 131 void addSourceInformation( |
129 Uri uri, List<int> lineStarts, List<int> sourceCode) { | 132 Uri uri, List<int> lineStarts, List<int> sourceCode) { |
130 String fileUri = relativizeUri(uri); | 133 String fileUri = relativizeUri(uri); |
131 uriToSource[fileUri] = new Source(lineStarts, sourceCode); | 134 uriToSource[fileUri] = new Source(lineStarts, sourceCode); |
132 } | 135 } |
133 | 136 |
134 void read(Uri uri) { | 137 void read(Uri uri) { |
135 loader.read(uri, -1); | 138 loader.read(uri, -1); |
136 } | 139 } |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 } | 657 } |
655 for (Constructor constructor in superclass.constructors) { | 658 for (Constructor constructor in superclass.constructors) { |
656 if (constructor.name.name.isEmpty) { | 659 if (constructor.name.name.isEmpty) { |
657 return constructor.function.requiredParameterCount == 0 | 660 return constructor.function.requiredParameterCount == 0 |
658 ? constructor | 661 ? constructor |
659 : null; | 662 : null; |
660 } | 663 } |
661 } | 664 } |
662 return null; | 665 return null; |
663 } | 666 } |
OLD | NEW |