Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10968010: Import scope rules updated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 return resolveTypeAnnotationInContext(inScope, node, onFailure, 897 return resolveTypeAnnotationInContext(inScope, node, onFailure,
898 whenResolved); 898 whenResolved);
899 } 899 }
900 900
901 DartType resolveTypeAnnotationInContext(Scope scope, TypeAnnotation node, 901 DartType resolveTypeAnnotationInContext(Scope scope, TypeAnnotation node,
902 onFailure, whenResolved) { 902 onFailure, whenResolved) {
903 Element element = resolveTypeName(scope, node); 903 Element element = resolveTypeName(scope, node);
904 DartType type; 904 DartType type;
905 if (element === null) { 905 if (element === null) {
906 onFailure(node, MessageKind.CANNOT_RESOLVE_TYPE, [node.typeName]); 906 onFailure(node, MessageKind.CANNOT_RESOLVE_TYPE, [node.typeName]);
907 } else if (element.isErroneous()) {
908 ErroneousElement error = element;
909 onFailure(node, error.messageKind, error.messageArguments);
907 } else if (!element.impliesType()) { 910 } else if (!element.impliesType()) {
908 onFailure(node, MessageKind.NOT_A_TYPE, [node.typeName]); 911 onFailure(node, MessageKind.NOT_A_TYPE, [node.typeName]);
909 } else { 912 } else {
910 if (element === compiler.types.voidType.element || 913 if (element === compiler.types.voidType.element ||
911 element === compiler.types.dynamicType.element) { 914 element === compiler.types.dynamicType.element) {
912 type = element.computeType(compiler); 915 type = element.computeType(compiler);
913 } else if (element.isClass()) { 916 } else if (element.isClass()) {
914 ClassElement cls = element; 917 ClassElement cls = element;
915 cls.ensureResolved(compiler); 918 cls.ensureResolved(compiler);
916 Link<DartType> arguments = 919 Link<DartType> arguments =
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1047 }
1045 1048
1046 visitInStaticContext(Node node) { 1049 visitInStaticContext(Node node) {
1047 inStaticContext(() => visit(node)); 1050 inStaticContext(() => visit(node));
1048 } 1051 }
1049 1052
1050 ErroneousElement warnAndCreateErroneousElement(Node node, 1053 ErroneousElement warnAndCreateErroneousElement(Node node,
1051 SourceString name, 1054 SourceString name,
1052 MessageKind kind, 1055 MessageKind kind,
1053 List<Node> arguments) { 1056 List<Node> arguments) {
1054 ResolutionWarning warning = new ResolutionWarning(kind, arguments); 1057 return warnOnErroneousElement(node,
1058 new ErroneousElement(kind, arguments, name, enclosingElement));
1059 }
1060
1061 ErroneousElement warnOnErroneousElement(Node node,
1062 ErroneousElement erroneousElement) {
1063 ResolutionWarning warning =
1064 new ResolutionWarning(erroneousElement.messageKind,
1065 erroneousElement.messageArguments);
1055 compiler.reportWarning(node, warning); 1066 compiler.reportWarning(node, warning);
1056 return new ErroneousElement(warning.message, name, enclosingElement); 1067 return erroneousElement;
1057 } 1068 }
1058 1069
1059 Element visitIdentifier(Identifier node) { 1070 Element visitIdentifier(Identifier node) {
1060 if (node.isThis()) { 1071 if (node.isThis()) {
1061 if (!inInstanceContext) { 1072 if (!inInstanceContext) {
1062 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]); 1073 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]);
1063 } 1074 }
1064 return null; 1075 return null;
1065 } else if (node.isSuper()) { 1076 } else if (node.isSuper()) {
1066 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC); 1077 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC);
1067 if ((ElementCategory.SUPER & allowedCategory) == 0) { 1078 if ((ElementCategory.SUPER & allowedCategory) == 0) {
1068 error(node, MessageKind.INVALID_USE_OF_SUPER); 1079 error(node, MessageKind.INVALID_USE_OF_SUPER);
1069 } 1080 }
1070 return null; 1081 return null;
1071 } else { 1082 } else {
1072 Element element = lookup(node, node.source); 1083 Element element = lookup(node, node.source);
1073 if (element === null) { 1084 if (element === null) {
1074 if (!inInstanceContext) { 1085 if (!inInstanceContext) {
1075 element = warnAndCreateErroneousElement(node, node.source, 1086 element = warnAndCreateErroneousElement(node, node.source,
1076 MessageKind.CANNOT_RESOLVE, 1087 MessageKind.CANNOT_RESOLVE,
1077 [node]); 1088 [node]);
1078 } 1089 }
1090 } else if (element.isErroneous()) {
1091 element = warnOnErroneousElement(node, element);
1079 } else { 1092 } else {
1080 if ((element.kind.category & allowedCategory) == 0) { 1093 if ((element.kind.category & allowedCategory) == 0) {
1081 // TODO(ahe): Improve error message. Need UX input. 1094 // TODO(ahe): Improve error message. Need UX input.
1082 error(node, MessageKind.GENERIC, ["is not an expression $element"]); 1095 error(node, MessageKind.GENERIC, ["is not an expression $element"]);
1083 } 1096 }
1084 } 1097 }
1085 return useElement(node, element); 1098 return useElement(node, element);
1086 } 1099 }
1087 } 1100 }
1088 1101
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 } 2630 }
2618 2631
2619 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode, 2632 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode,
2620 SourceString targetName, MessageKind kind, 2633 SourceString targetName, MessageKind kind,
2621 List arguments) { 2634 List arguments) {
2622 if (inConstContext) { 2635 if (inConstContext) {
2623 error(diagnosticNode, kind, arguments); 2636 error(diagnosticNode, kind, arguments);
2624 } else { 2637 } else {
2625 ResolutionWarning warning = new ResolutionWarning(kind, arguments); 2638 ResolutionWarning warning = new ResolutionWarning(kind, arguments);
2626 compiler.reportWarning(diagnosticNode, warning); 2639 compiler.reportWarning(diagnosticNode, warning);
2627 return new ErroneousFunctionElement(warning.message, targetName, 2640 return new ErroneousFunctionElement(kind, arguments, targetName,
2628 enclosing); 2641 enclosing);
2629 } 2642 }
2630 } 2643 }
2631 2644
2632 // TODO(ngeoffray): method named lookup should not report errors. 2645 // TODO(ngeoffray): method named lookup should not report errors.
2633 FunctionElement lookupConstructor(ClassElement cls, 2646 FunctionElement lookupConstructor(ClassElement cls,
2634 Node diagnosticNode, 2647 Node diagnosticNode,
2635 SourceString constructorName) { 2648 SourceString constructorName) {
2636 cls.ensureResolved(compiler); 2649 cls.ensureResolved(compiler);
2637 Element result = cls.lookupConstructor(cls.name, constructorName); 2650 Element result = cls.lookupConstructor(cls.name, constructorName);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 2871
2859 Element localLookup(SourceString name) => library.find(name); 2872 Element localLookup(SourceString name) => library.find(name);
2860 Element lookup(SourceString name) => localLookup(name); 2873 Element lookup(SourceString name) => localLookup(name);
2861 Element lexicalLookup(SourceString name) => localLookup(name); 2874 Element lexicalLookup(SourceString name) => localLookup(name);
2862 2875
2863 Element add(Element newElement) { 2876 Element add(Element newElement) {
2864 throw "Cannot add an element in the top scope"; 2877 throw "Cannot add an element in the top scope";
2865 } 2878 }
2866 String toString() => '$element'; 2879 String toString() => '$element';
2867 } 2880 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698