| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.common.resolution; | 5 library dart2js.common.resolution; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../compile_time_constants.dart'; | 8 import '../compile_time_constants.dart'; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/expressions.dart' show ConstantExpression; | 10 import '../constants/expressions.dart' show ConstantExpression; |
| 11 import '../constants/values.dart' show ConstantValue; | 11 import '../constants/values.dart' show ConstantValue; |
| 12 import '../core_types.dart' show CoreClasses, CoreTypes; | 12 import '../core_types.dart' show CoreClasses, CoreTypes, CommonElements; |
| 13 import '../dart_types.dart' show DartType, Types; | 13 import '../dart_types.dart' show DartType, Types; |
| 14 import '../elements/elements.dart' | 14 import '../elements/elements.dart' |
| 15 show | 15 show |
| 16 AstElement, | 16 AstElement, |
| 17 ClassElement, | 17 ClassElement, |
| 18 ConstructorElement, | 18 ConstructorElement, |
| 19 Element, | 19 Element, |
| 20 ExecutableElement, | 20 ExecutableElement, |
| 21 FunctionElement, | 21 FunctionElement, |
| 22 FunctionSignature, | 22 FunctionSignature, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 Iterable<Feature> get features => const <Feature>[]; | 63 Iterable<Feature> get features => const <Feature>[]; |
| 64 Iterable<MapLiteralUse> get mapLiterals => const <MapLiteralUse>[]; | 64 Iterable<MapLiteralUse> get mapLiterals => const <MapLiteralUse>[]; |
| 65 Iterable<ListLiteralUse> get listLiterals => const <ListLiteralUse>[]; | 65 Iterable<ListLiteralUse> get listLiterals => const <ListLiteralUse>[]; |
| 66 Iterable<String> get constSymbolNames => const <String>[]; | 66 Iterable<String> get constSymbolNames => const <String>[]; |
| 67 Iterable<ConstantExpression> get constantLiterals => | 67 Iterable<ConstantExpression> get constantLiterals => |
| 68 const <ConstantExpression>[]; | 68 const <ConstantExpression>[]; |
| 69 | 69 |
| 70 Iterable<dynamic> get nativeData => const <dynamic>[]; | 70 Iterable<dynamic> get nativeData => const <dynamic>[]; |
| 71 } | 71 } |
| 72 | 72 |
| 73 | |
| 74 /// Interface for the accessing the front-end analysis. | 73 /// Interface for the accessing the front-end analysis. |
| 75 // TODO(johnniwinther): Find a better name for this. | 74 // TODO(johnniwinther): Find a better name for this. |
| 76 abstract class Frontend { | 75 abstract class Frontend { |
| 77 /// Returns the [ResolutionImpact] for [element]. | 76 /// Returns the [ResolutionImpact] for [element]. |
| 78 ResolutionImpact getResolutionImpact(Element element); | 77 ResolutionImpact getResolutionImpact(Element element); |
| 79 } | 78 } |
| 80 | 79 |
| 81 /// Interface defining target-specific behavior for resolution. | 80 /// Interface defining target-specific behavior for resolution. |
| 82 abstract class Target { | 81 abstract class Target { |
| 83 /// Returns `true` if [library] is a target specific library whose members | 82 /// Returns `true` if [library] is a target specific library whose members |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 /// Returns `true` if this target supports async/await. | 114 /// Returns `true` if this target supports async/await. |
| 116 bool get supportsAsyncAwait => true; | 115 bool get supportsAsyncAwait => true; |
| 117 } | 116 } |
| 118 | 117 |
| 119 // TODO(johnniwinther): Rename to `Resolver` or `ResolverContext`. | 118 // TODO(johnniwinther): Rename to `Resolver` or `ResolverContext`. |
| 120 abstract class Resolution implements Frontend { | 119 abstract class Resolution implements Frontend { |
| 121 ParsingContext get parsingContext; | 120 ParsingContext get parsingContext; |
| 122 DiagnosticReporter get reporter; | 121 DiagnosticReporter get reporter; |
| 123 CoreClasses get coreClasses; | 122 CoreClasses get coreClasses; |
| 124 CoreTypes get coreTypes; | 123 CoreTypes get coreTypes; |
| 124 CommonElements get commonElements; |
| 125 Types get types; | 125 Types get types; |
| 126 Target get target; | 126 Target get target; |
| 127 ResolverTask get resolver; | 127 ResolverTask get resolver; |
| 128 ResolutionEnqueuer get enqueuer; | 128 ResolutionEnqueuer get enqueuer; |
| 129 CompilerOptions get options; | 129 CompilerOptions get options; |
| 130 IdGenerator get idGenerator; | 130 IdGenerator get idGenerator; |
| 131 ConstantEnvironment get constants; | 131 ConstantEnvironment get constants; |
| 132 MirrorUsageAnalyzerTask get mirrorUsageAnalyzerTask; | 132 MirrorUsageAnalyzerTask get mirrorUsageAnalyzerTask; |
| 133 | 133 |
| 134 // TODO(het): Move all elements into common/elements.dart | 134 /// Whether internally we computed the constant for the [proxy] variable |
| 135 LibraryElement get coreLibrary; | 135 /// defined in dart:core (used only for testing). |
| 136 FunctionElement get identicalFunction; | 136 // TODO(sigmund): delete, we need a better way to test this. |
| 137 ClassElement get mirrorSystemClass; | 137 bool get wasProxyConstantComputedTestingOnly; |
| 138 FunctionElement get mirrorSystemGetNameFunction; | |
| 139 ConstructorElement get mirrorsUsedConstructor; | |
| 140 ConstructorElement get symbolConstructor; | |
| 141 | |
| 142 // TODO(het): This is only referenced in a test... | |
| 143 /// The constant for the [proxy] variable defined in dart:core. | |
| 144 ConstantValue get proxyConstant; | |
| 145 | 138 |
| 146 /// If set to `true` resolution caches will not be cleared. Use this only for | 139 /// If set to `true` resolution caches will not be cleared. Use this only for |
| 147 /// testing. | 140 /// testing. |
| 148 bool retainCachesForTesting; | 141 bool retainCachesForTesting; |
| 149 | 142 |
| 150 void resolveTypedef(TypedefElement typdef); | 143 void resolveTypedef(TypedefElement typdef); |
| 151 void resolveClass(ClassElement cls); | 144 void resolveClass(ClassElement cls); |
| 152 void registerClass(ClassElement cls); | 145 void registerClass(ClassElement cls); |
| 153 void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation); | 146 void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation); |
| 154 FunctionSignature resolveSignature(FunctionElement function); | 147 FunctionSignature resolveSignature(FunctionElement function); |
| 155 DartType resolveTypeAnnotation(Element element, TypeAnnotation node); | 148 DartType resolveTypeAnnotation(Element element, TypeAnnotation node); |
| 156 | 149 |
| 157 /// Returns `true` if [element] has been resolved. | 150 /// Returns `true` if [element] has been resolved. |
| 158 // TODO(johnniwinther): Normalize semantics between normal and deserialized | 151 // TODO(johnniwinther): Normalize semantics between normal and deserialized |
| 159 // elements; deserialized elements are always resolved but the method will | 152 // elements; deserialized elements are always resolved but the method will |
| 160 // return `false`. | 153 // return `false`. |
| 161 bool hasBeenResolved(Element element); | 154 bool hasBeenResolved(Element element); |
| 162 | 155 |
| 163 /// Resolve [element] if it has not already been resolved. | 156 /// Resolve [element] if it has not already been resolved. |
| 164 void ensureResolved(Element element); | 157 void ensureResolved(Element element); |
| 165 | 158 |
| 166 /// Called whenever a class has been resolved. | |
| 167 void onClassResolved(ClassElement element); | |
| 168 | |
| 169 /// Registers that [element] has a compile time error. | 159 /// Registers that [element] has a compile time error. |
| 170 /// | 160 /// |
| 171 /// The error itself is given in [message]. | 161 /// The error itself is given in [message]. |
| 172 void registerCompileTimeError(Element element, DiagnosticMessage message); | 162 void registerCompileTimeError(Element element, DiagnosticMessage message); |
| 173 | 163 |
| 174 ResolutionWorkItem createWorkItem( | 164 ResolutionWorkItem createWorkItem( |
| 175 Element element, ItemCompilationContext compilationContext); | 165 Element element, ItemCompilationContext compilationContext); |
| 176 | 166 |
| 177 /// Returns `true` if [element] as a fully computed [ResolvedAst]. | 167 /// Returns `true` if [element] as a fully computed [ResolvedAst]. |
| 178 bool hasResolvedAst(ExecutableElement element); | 168 bool hasResolvedAst(ExecutableElement element); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 if (cls.isPatch) { | 249 if (cls.isPatch) { |
| 260 patchParser.parsePatchClassNode(cls); | 250 patchParser.parsePatchClassNode(cls); |
| 261 } | 251 } |
| 262 }); | 252 }); |
| 263 } | 253 } |
| 264 | 254 |
| 265 @override | 255 @override |
| 266 ScannerOptions getScannerOptionsFor(Element element) => new ScannerOptions( | 256 ScannerOptions getScannerOptionsFor(Element element) => new ScannerOptions( |
| 267 canUseNative: backend.canLibraryUseNative(element.library)); | 257 canUseNative: backend.canLibraryUseNative(element.library)); |
| 268 } | 258 } |
| OLD | NEW |