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 abstract class TreeElements { | 5 abstract class TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 DartType getType(TypeAnnotation annotation); | 8 DartType getType(TypeAnnotation annotation); |
| 9 bool isParameterChecked(Element element); | 9 bool isParameterChecked(Element element); |
| 10 } | 10 } |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 visitInStaticContext(Node node) { | 1029 visitInStaticContext(Node node) { |
| 1030 inStaticContext(() => visit(node)); | 1030 inStaticContext(() => visit(node)); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 ErroneousElement warnAndCreateErroneousElement(Node node, | 1033 ErroneousElement warnAndCreateErroneousElement(Node node, |
| 1034 SourceString name, | 1034 SourceString name, |
| 1035 MessageKind kind, | 1035 MessageKind kind, |
| 1036 List<Node> arguments) { | 1036 List<Node> arguments) { |
| 1037 ResolutionWarning warning = new ResolutionWarning(kind, arguments); | 1037 return warnOnErroneousElement(node, |
| 1038 new ErroneousElement(kind, arguments, name, enclosingElement)); | |
| 1039 } | |
| 1040 | |
| 1041 ErroneousElement warnOnErroneousElement(Node node, | |
| 1042 ErroneousElement erroneousElement) { | |
| 1043 ResolutionWarning warning | |
| 1044 = new ResolutionWarning(erroneousElement.messageKind, | |
|
Lasse Reichstein Nielsen
2012/09/20 12:21:08
Put the '=' on the previous line.
Johnni Winther
2012/09/21 14:00:05
Done.
| |
| 1045 erroneousElement.messageArguments); | |
| 1038 compiler.reportWarning(node, warning); | 1046 compiler.reportWarning(node, warning); |
| 1039 return new ErroneousElement(warning.message, name, enclosingElement); | 1047 return erroneousElement; |
| 1040 } | 1048 } |
| 1041 | 1049 |
| 1042 Element visitIdentifier(Identifier node) { | 1050 Element visitIdentifier(Identifier node) { |
| 1043 if (node.isThis()) { | 1051 if (node.isThis()) { |
| 1044 if (!inInstanceContext) { | 1052 if (!inInstanceContext) { |
| 1045 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]); | 1053 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]); |
| 1046 } | 1054 } |
| 1047 return null; | 1055 return null; |
| 1048 } else if (node.isSuper()) { | 1056 } else if (node.isSuper()) { |
| 1049 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC); | 1057 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC); |
| 1050 if ((ElementCategory.SUPER & allowedCategory) == 0) { | 1058 if ((ElementCategory.SUPER & allowedCategory) == 0) { |
| 1051 error(node, MessageKind.INVALID_USE_OF_SUPER); | 1059 error(node, MessageKind.INVALID_USE_OF_SUPER); |
| 1052 } | 1060 } |
| 1053 return null; | 1061 return null; |
| 1054 } else { | 1062 } else { |
| 1055 Element element = lookup(node, node.source); | 1063 Element element = lookup(node, node.source); |
| 1056 if (element === null) { | 1064 if (element === null) { |
| 1057 if (!inInstanceContext) { | 1065 if (!inInstanceContext) { |
| 1058 element = warnAndCreateErroneousElement(node, node.source, | 1066 element = warnAndCreateErroneousElement(node, node.source, |
| 1059 MessageKind.CANNOT_RESOLVE, | 1067 MessageKind.CANNOT_RESOLVE, |
| 1060 [node]); | 1068 [node]); |
| 1061 } | 1069 } |
| 1070 } else if (element.isErroneous()) { | |
| 1071 element = warnOnErroneousElement(node, element); | |
| 1062 } else { | 1072 } else { |
| 1063 if ((element.kind.category & allowedCategory) == 0) { | 1073 if ((element.kind.category & allowedCategory) == 0) { |
| 1064 // TODO(ahe): Improve error message. Need UX input. | 1074 // TODO(ahe): Improve error message. Need UX input. |
| 1065 error(node, MessageKind.GENERIC, ["is not an expression $element"]); | 1075 error(node, MessageKind.GENERIC, ["is not an expression $element"]); |
| 1066 } | 1076 } |
| 1067 } | 1077 } |
| 1068 return useElement(node, element); | 1078 return useElement(node, element); |
| 1069 } | 1079 } |
| 1070 } | 1080 } |
| 1071 | 1081 |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2588 } | 2598 } |
| 2589 | 2599 |
| 2590 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode, | 2600 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode, |
| 2591 SourceString targetName, MessageKind kind, | 2601 SourceString targetName, MessageKind kind, |
| 2592 List arguments) { | 2602 List arguments) { |
| 2593 if (inConstContext) { | 2603 if (inConstContext) { |
| 2594 error(diagnosticNode, kind, arguments); | 2604 error(diagnosticNode, kind, arguments); |
| 2595 } else { | 2605 } else { |
| 2596 ResolutionWarning warning = new ResolutionWarning(kind, arguments); | 2606 ResolutionWarning warning = new ResolutionWarning(kind, arguments); |
| 2597 compiler.reportWarning(diagnosticNode, warning); | 2607 compiler.reportWarning(diagnosticNode, warning); |
| 2598 return new ErroneousFunctionElement(warning.message, targetName, | 2608 return new ErroneousFunctionElement(kind, arguments, targetName, |
| 2599 enclosing); | 2609 enclosing); |
| 2600 } | 2610 } |
| 2601 } | 2611 } |
| 2602 | 2612 |
| 2603 FunctionElement lookupConstructor(ClassElement cls, | 2613 FunctionElement lookupConstructor(ClassElement cls, |
| 2604 Node diagnosticNode, | 2614 Node diagnosticNode, |
| 2605 SourceString constructorName) { | 2615 SourceString constructorName) { |
| 2606 cls.ensureResolved(compiler); | 2616 cls.ensureResolved(compiler); |
| 2607 Element result = cls.lookupConstructor(cls.name, constructorName); | 2617 Element result = cls.lookupConstructor(cls.name, constructorName); |
| 2608 if (result === null) { | 2618 if (result === null) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2825 | 2835 |
| 2826 Element localLookup(SourceString name) => library.find(name); | 2836 Element localLookup(SourceString name) => library.find(name); |
| 2827 Element lookup(SourceString name) => localLookup(name); | 2837 Element lookup(SourceString name) => localLookup(name); |
| 2828 Element lexicalLookup(SourceString name) => localLookup(name); | 2838 Element lexicalLookup(SourceString name) => localLookup(name); |
| 2829 | 2839 |
| 2830 Element add(Element newElement) { | 2840 Element add(Element newElement) { |
| 2831 throw "Cannot add an element in the top scope"; | 2841 throw "Cannot add an element in the top scope"; |
| 2832 } | 2842 } |
| 2833 String toString() => '$element'; | 2843 String toString() => '$element'; |
| 2834 } | 2844 } |
| OLD | NEW |