Chromium Code Reviews| 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 resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element operator[](Node node); | 8 Element operator[](Node node); |
| 9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
| 10 DartType getType(Node node); | 10 DartType getType(Node node); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 class ResolverTask extends CompilerTask { | 72 class ResolverTask extends CompilerTask { |
| 73 ResolverTask(Compiler compiler) : super(compiler); | 73 ResolverTask(Compiler compiler) : super(compiler); |
| 74 | 74 |
| 75 String get name => 'Resolver'; | 75 String get name => 'Resolver'; |
| 76 | 76 |
| 77 TreeElements resolve(Element element) { | 77 TreeElements resolve(Element element) { |
| 78 return measure(() { | 78 return measure(() { |
| 79 ElementKind kind = element.kind; | 79 ElementKind kind = element.kind; |
|
karlklose
2012/11/13 08:33:47
Move variable 'kind' down to its use.
ahe
2012/11/13 13:13:43
Done.
| |
| 80 if (Elements.isErroneousElement(element)) return null; | |
| 81 | |
| 82 for (MetadataAnnotation metadata in element.metadata) { | |
| 83 metadata.ensureResolved(compiler); | |
| 84 } | |
| 85 | |
| 80 if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR) || | 86 if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR) || |
| 81 identical(kind, ElementKind.FUNCTION) || | 87 identical(kind, ElementKind.FUNCTION) || |
| 82 identical(kind, ElementKind.GETTER) || | 88 identical(kind, ElementKind.GETTER) || |
| 83 identical(kind, ElementKind.SETTER)) { | 89 identical(kind, ElementKind.SETTER)) { |
| 84 return resolveMethodElement(element); | 90 return resolveMethodElement(element); |
| 85 } | 91 } |
| 86 | 92 |
| 87 if (identical(kind, ElementKind.FIELD)) return resolveField(element); | 93 if (identical(kind, ElementKind.FIELD)) return resolveField(element); |
| 88 | 94 |
| 89 if (identical(kind, ElementKind.PARAMETER) || | 95 if (identical(kind, ElementKind.PARAMETER) || |
| 90 identical(kind, ElementKind.FIELD_PARAMETER)) { | 96 identical(kind, ElementKind.FIELD_PARAMETER)) { |
| 91 return resolveParameter(element); | 97 return resolveParameter(element); |
| 92 } | 98 } |
| 99 if (element.isClass()) { | |
| 100 ClassElement cls = element; | |
| 101 cls.ensureResolved(compiler); | |
| 102 return null; | |
| 103 } else if (element.isTypedef()) { | |
| 104 element.computeType(compiler); | |
| 105 return null; | |
| 106 } | |
| 93 | 107 |
| 94 compiler.unimplemented("resolve($element)", | 108 compiler.unimplemented("resolve($element)", |
| 95 node: element.parseNode(compiler)); | 109 node: element.parseNode(compiler)); |
| 96 }); | 110 }); |
| 97 } | 111 } |
| 98 | 112 |
| 99 String constructorNameForDiagnostics(SourceString className, | 113 String constructorNameForDiagnostics(SourceString className, |
| 100 SourceString constructorName) { | 114 SourceString constructorName) { |
| 101 String classNameString = className.slowToString(); | 115 String classNameString = className.slowToString(); |
| 102 String constructorNameString = constructorName.slowToString(); | 116 String constructorNameString = constructorName.slowToString(); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 void resolveMetadataAnnotation(PartialMetadataAnnotation annotation) { | 635 void resolveMetadataAnnotation(PartialMetadataAnnotation annotation) { |
| 622 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { | 636 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { |
| 623 assert(annotation.resolutionState == STATE_NOT_STARTED); | 637 assert(annotation.resolutionState == STATE_NOT_STARTED); |
| 624 annotation.resolutionState = STATE_STARTED; | 638 annotation.resolutionState = STATE_STARTED; |
| 625 | 639 |
| 626 Node node = annotation.parseNode(compiler); | 640 Node node = annotation.parseNode(compiler); |
| 627 ResolverVisitor visitor = | 641 ResolverVisitor visitor = |
| 628 visitorFor(annotation.annotatedElement.enclosingElement); | 642 visitorFor(annotation.annotatedElement.enclosingElement); |
| 629 node.accept(visitor); | 643 node.accept(visitor); |
| 630 annotation.value = compiler.constantHandler.compileNodeWithDefinitions( | 644 annotation.value = compiler.constantHandler.compileNodeWithDefinitions( |
| 631 node, visitor.mapping); | 645 node, visitor.mapping, isConst: true); |
| 632 | 646 |
| 633 annotation.resolutionState = STATE_DONE; | 647 annotation.resolutionState = STATE_DONE; |
| 634 })); | 648 })); |
| 635 } | 649 } |
| 636 | 650 |
| 637 error(Node node, MessageKind kind, [arguments = const []]) { | 651 error(Node node, MessageKind kind, [arguments = const []]) { |
| 638 ResolutionError message = new ResolutionError(kind, arguments); | 652 ResolutionError message = new ResolutionError(kind, arguments); |
| 639 compiler.reportError(node, message); | 653 compiler.reportError(node, message); |
| 640 } | 654 } |
| 641 } | 655 } |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 inCheckContext = compiler.enableTypeAssertions, | 1208 inCheckContext = compiler.enableTypeAssertions, |
| 1195 inCatchBlock = false, | 1209 inCatchBlock = false, |
| 1196 super(compiler); | 1210 super(compiler); |
| 1197 | 1211 |
| 1198 Enqueuer get world => compiler.enqueuer.resolution; | 1212 Enqueuer get world => compiler.enqueuer.resolution; |
| 1199 | 1213 |
| 1200 Element lookup(Node node, SourceString name) { | 1214 Element lookup(Node node, SourceString name) { |
| 1201 Element result = scope.lookup(name); | 1215 Element result = scope.lookup(name); |
| 1202 if (!Elements.isUnresolved(result)) { | 1216 if (!Elements.isUnresolved(result)) { |
| 1203 if (!inInstanceContext && result.isInstanceMember()) { | 1217 if (!inInstanceContext && result.isInstanceMember()) { |
| 1204 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]); | 1218 compiler.reportMessage(compiler.spanFromNode(node), |
| 1205 // TODO(johnniwinther): Create an ErroneousElement. | 1219 MessageKind.NO_INSTANCE_AVAILABLE.error([name]), |
| 1220 Diagnostic.ERROR); | |
| 1221 return new ErroneousElement(MessageKind.NO_INSTANCE_AVAILABLE, | |
| 1222 [name], | |
| 1223 name, enclosingElement); | |
| 1206 } else if (result.isAmbiguous()) { | 1224 } else if (result.isAmbiguous()) { |
| 1207 AmbiguousElement ambiguous = result; | 1225 AmbiguousElement ambiguous = result; |
| 1208 compiler.reportMessage(compiler.spanFromNode(node), | 1226 compiler.reportMessage(compiler.spanFromNode(node), |
| 1209 ambiguous.messageKind.error(ambiguous.messageArguments), | 1227 ambiguous.messageKind.error(ambiguous.messageArguments), |
| 1210 Diagnostic.ERROR); | 1228 Diagnostic.ERROR); |
| 1211 return new ErroneousElement(ambiguous.messageKind, | 1229 return new ErroneousElement(ambiguous.messageKind, |
| 1212 ambiguous.messageArguments, | 1230 ambiguous.messageArguments, |
| 1213 name, enclosingElement); | 1231 name, enclosingElement); |
| 1214 } | 1232 } |
| 1215 } | 1233 } |
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3070 return e; | 3088 return e; |
| 3071 } | 3089 } |
| 3072 | 3090 |
| 3073 /// Assumed to be called by [resolveRedirectingFactory]. | 3091 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3074 Element visitReturn(Return node) { | 3092 Element visitReturn(Return node) { |
| 3075 Node expression = node.expression; | 3093 Node expression = node.expression; |
| 3076 return finishConstructorReference(visit(expression), | 3094 return finishConstructorReference(visit(expression), |
| 3077 expression, expression); | 3095 expression, expression); |
| 3078 } | 3096 } |
| 3079 } | 3097 } |
| OLD | NEW |