| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 ParserTask parser; | 182 ParserTask parser; |
| 183 PatchParserTask patchParser; | 183 PatchParserTask patchParser; |
| 184 LibraryLoader libraryLoader; | 184 LibraryLoader libraryLoader; |
| 185 TreeValidatorTask validator; | 185 TreeValidatorTask validator; |
| 186 ResolverTask resolver; | 186 ResolverTask resolver; |
| 187 closureMapping.ClosureTask closureToClassMapper; | 187 closureMapping.ClosureTask closureToClassMapper; |
| 188 TypeCheckerTask checker; | 188 TypeCheckerTask checker; |
| 189 ti.TypesTask typesTask; | 189 ti.TypesTask typesTask; |
| 190 Backend backend; | 190 Backend backend; |
| 191 ConstantHandler constantHandler; | 191 ConstantHandler constantHandler; |
| 192 ConstantHandler metadataHandler; |
| 192 EnqueueTask enqueuer; | 193 EnqueueTask enqueuer; |
| 193 | 194 |
| 194 static const SourceString MAIN = const SourceString('main'); | 195 static const SourceString MAIN = const SourceString('main'); |
| 195 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 196 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
| 196 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 197 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 197 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | 198 static const int NO_SUCH_METHOD_ARG_COUNT = 1; |
| 198 static const SourceString INVOKE_ON = const SourceString('invokeOn'); | 199 static const SourceString INVOKE_ON = const SourceString('invokeOn'); |
| 199 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 200 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
| 200 static const SourceString START_ROOT_ISOLATE = | 201 static const SourceString START_ROOT_ISOLATE = |
| 201 const SourceString('startRootIsolate'); | 202 const SourceString('startRootIsolate'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 resolver = new ResolverTask(this); | 242 resolver = new ResolverTask(this); |
| 242 closureToClassMapper = new closureMapping.ClosureTask(this); | 243 closureToClassMapper = new closureMapping.ClosureTask(this); |
| 243 checker = new TypeCheckerTask(this); | 244 checker = new TypeCheckerTask(this); |
| 244 typesTask = new ti.TypesTask(this, enableConcreteTypeInference); | 245 typesTask = new ti.TypesTask(this, enableConcreteTypeInference); |
| 245 backend = emitJavaScript ? | 246 backend = emitJavaScript ? |
| 246 new js_backend.JavaScriptBackend(this, | 247 new js_backend.JavaScriptBackend(this, |
| 247 generateSourceMap, | 248 generateSourceMap, |
| 248 disallowUnsafeEval) : | 249 disallowUnsafeEval) : |
| 249 new dart_backend.DartBackend(this, strips); | 250 new dart_backend.DartBackend(this, strips); |
| 250 constantHandler = new ConstantHandler(this, backend.constantSystem); | 251 constantHandler = new ConstantHandler(this, backend.constantSystem); |
| 252 metadataHandler = new ConstantHandler(this, backend.constantSystem); |
| 251 enqueuer = new EnqueueTask(this); | 253 enqueuer = new EnqueueTask(this); |
| 252 tasks = [scanner, dietParser, parser, patchParser, libraryLoader, | 254 tasks = [scanner, dietParser, parser, patchParser, libraryLoader, |
| 253 resolver, closureToClassMapper, checker, typesTask, | 255 resolver, closureToClassMapper, checker, typesTask, |
| 254 constantHandler, enqueuer]; | 256 constantHandler, enqueuer]; |
| 255 tasks.addAll(backend.tasks); | 257 tasks.addAll(backend.tasks); |
| 256 } | 258 } |
| 257 | 259 |
| 258 Universe get resolverWorld => enqueuer.resolution.universe; | 260 Universe get resolverWorld => enqueuer.resolution.universe; |
| 259 Universe get codegenWorld => enqueuer.codegen.universe; | 261 Universe get codegenWorld => enqueuer.codegen.universe; |
| 260 | 262 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 withCurrentElement(element, | 719 withCurrentElement(element, |
| 718 () => resolver.resolveTypedef(element)); | 720 () => resolver.resolveTypedef(element)); |
| 719 } | 721 } |
| 720 | 722 |
| 721 FunctionType computeFunctionType(Element element, | 723 FunctionType computeFunctionType(Element element, |
| 722 FunctionSignature signature) { | 724 FunctionSignature signature) { |
| 723 return withCurrentElement(element, | 725 return withCurrentElement(element, |
| 724 () => resolver.computeFunctionType(element, signature)); | 726 () => resolver.computeFunctionType(element, signature)); |
| 725 } | 727 } |
| 726 | 728 |
| 727 bool isLazilyInitialized(VariableElement element) { | |
| 728 Constant initialValue = compileVariable(element); | |
| 729 return initialValue == null; | |
| 730 } | |
| 731 | |
| 732 /** | |
| 733 * Compiles compile-time constants. Never returns [:null:]. | |
| 734 * If the initial value is not a compile-time constants reports an error. | |
| 735 */ | |
| 736 Constant compileConstant(VariableElement element) { | |
| 737 return withCurrentElement(element, () { | |
| 738 return constantHandler.compileConstant(element); | |
| 739 }); | |
| 740 } | |
| 741 | |
| 742 Constant compileVariable(VariableElement element) { | |
| 743 return withCurrentElement(element, () { | |
| 744 return constantHandler.compileVariable(element); | |
| 745 }); | |
| 746 } | |
| 747 | |
| 748 reportWarning(Node node, var message) { | 729 reportWarning(Node node, var message) { |
| 749 if (message is TypeWarning) { | 730 if (message is TypeWarning) { |
| 750 // TODO(ahe): Don't supress these warning when the type checker | 731 // TODO(ahe): Don't supress these warning when the type checker |
| 751 // is more complete. | 732 // is more complete. |
| 752 if (identical(message.message.kind, MessageKind.NOT_ASSIGNABLE)) return; | 733 if (identical(message.message.kind, MessageKind.NOT_ASSIGNABLE)) return; |
| 753 if (identical(message.message.kind, MessageKind.MISSING_RETURN)) return; | 734 if (identical(message.message.kind, MessageKind.MISSING_RETURN)) return; |
| 754 if (identical(message.message.kind, MessageKind.MAYBE_MISSING_RETURN)) ret
urn; | 735 if (identical(message.message.kind, MessageKind.MAYBE_MISSING_RETURN)) ret
urn; |
| 755 if (identical(message.message.kind, MessageKind.ADDITIONAL_ARGUMENT)) retu
rn; | 736 if (identical(message.message.kind, MessageKind.ADDITIONAL_ARGUMENT)) retu
rn; |
| 756 if (identical(message.message.kind, MessageKind.METHOD_NOT_FOUND)) return; | 737 if (identical(message.message.kind, MessageKind.METHOD_NOT_FOUND)) return; |
| 757 } | 738 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 925 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 945 // information on assertion errors. | 926 // information on assertion errors. |
| 946 if (condition is Function){ | 927 if (condition is Function){ |
| 947 condition = condition(); | 928 condition = condition(); |
| 948 } | 929 } |
| 949 if (spannable == null || !condition) { | 930 if (spannable == null || !condition) { |
| 950 throw new SpannableAssertionFailure(spannable, message); | 931 throw new SpannableAssertionFailure(spannable, message); |
| 951 } | 932 } |
| 952 return true; | 933 return true; |
| 953 } | 934 } |
| OLD | NEW |