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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1414913002: Introduce .isMalformed (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
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 library dart2js.typechecker; 5 library dart2js.typechecker;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/names.dart' show 8 import 'common/names.dart' show
9 Identifiers; 9 Identifiers;
10 import 'common/resolution.dart' show 10 import 'common/resolution.dart' show
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 } 1016 }
1017 } 1017 }
1018 1018
1019 /** 1019 /**
1020 * Computes the [ElementAccess] for [name] on the [node] possibly using the 1020 * Computes the [ElementAccess] for [name] on the [node] possibly using the
1021 * [element] provided for [node] by the resolver. 1021 * [element] provided for [node] by the resolver.
1022 */ 1022 */
1023 ElementAccess computeAccess(Send node, String name, Element element, 1023 ElementAccess computeAccess(Send node, String name, Element element,
1024 MemberKind memberKind, 1024 MemberKind memberKind,
1025 {bool lookupClassMember: false}) { 1025 {bool lookupClassMember: false}) {
1026 if (element != null && element.isErroneous) { 1026 if (Elements.isMalformed(element)) {
1027 // An error has already been reported for this node. 1027 // An error has already been reported for this node.
Johnni Winther 2015/10/21 07:51:56 This comment will not be true for all malformed, t
sigurdm 2015/10/22 07:33:14 Removed the comment
1028 return const DynamicAccess(); 1028 return const DynamicAccess();
1029 } 1029 }
1030 if (node.receiver != null) { 1030 if (node.receiver != null) {
1031 Element receiverElement = elements[node.receiver]; 1031 Element receiverElement = elements[node.receiver];
1032 if (receiverElement != null) { 1032 if (receiverElement != null) {
1033 if (receiverElement.isPrefix) { 1033 if (receiverElement.isPrefix) {
1034 if (node.isConditional) { 1034 if (node.isConditional) {
1035 // Skip cases like `prefix?.topLevel`. 1035 // Skip cases like `prefix?.topLevel`.
1036 return const DynamicAccess(); 1036 return const DynamicAccess();
1037 } 1037 }
(...skipping 18 matching lines...) Expand all
1056 1056
1057 /** 1057 /**
1058 * Computes the [ElementAccess] for [name] on the [node] using the [element] 1058 * Computes the [ElementAccess] for [name] on the [node] using the [element]
1059 * provided for [node] by the resolver. 1059 * provided for [node] by the resolver.
1060 */ 1060 */
1061 ElementAccess computeResolvedAccess(Send node, String name, 1061 ElementAccess computeResolvedAccess(Send node, String name,
1062 Element element, MemberKind memberKind) { 1062 Element element, MemberKind memberKind) {
1063 if (element == null) { 1063 if (element == null) {
1064 // foo() where foo is unresolved. 1064 // foo() where foo is unresolved.
1065 return lookupMember(node, thisType, name, memberKind, null); 1065 return lookupMember(node, thisType, name, memberKind, null);
1066 } else if (element.isErroneous) { 1066 } else if (element.isMalformed) {
1067 // foo() where foo is erroneous. 1067 // foo() where foo is erroneous.
1068 return const DynamicAccess(); 1068 return const DynamicAccess();
1069 } else if (element.impliesType) { 1069 } else if (element.impliesType) {
1070 // The literal `Foo` where Foo is a class, a typedef, or a type variable. 1070 // The literal `Foo` where Foo is a class, a typedef, or a type variable.
1071 if (elements.isTypeLiteral(node)) { 1071 if (elements.isTypeLiteral(node)) {
1072 return new TypeLiteralAccess(elements.getTypeLiteralType(node)); 1072 return new TypeLiteralAccess(elements.getTypeLiteralType(node));
1073 } 1073 }
1074 return createResolvedAccess(node, name, element); 1074 return createResolvedAccess(node, name, element);
1075 } else if (element.isClassMember) { 1075 } else if (element.isClassMember) {
1076 // foo() where foo is a member. 1076 // foo() where foo is a member.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 Identifier selector = node.selector.asIdentifier(); 1199 Identifier selector = node.selector.asIdentifier();
1200 if (Elements.isClosureSend(node, element)) { 1200 if (Elements.isClosureSend(node, element)) {
1201 if (element != null) { 1201 if (element != null) {
1202 // foo() where foo is a local or a parameter. 1202 // foo() where foo is a local or a parameter.
1203 return analyzeInvocation(node, createPromotedAccess(element)); 1203 return analyzeInvocation(node, createPromotedAccess(element));
1204 } else { 1204 } else {
1205 // exp() where exp is some complex expression like (o) or foo(). 1205 // exp() where exp is some complex expression like (o) or foo().
1206 DartType type = analyze(node.selector); 1206 DartType type = analyze(node.selector);
1207 return analyzeInvocation(node, new TypeAccess(type)); 1207 return analyzeInvocation(node, new TypeAccess(type));
1208 } 1208 }
1209 } else if (Elements.isErroneous(element) && selector == null) { 1209 } else if (Elements.isMalformed(element) && selector == null) {
1210 // exp() where exp is an erroneous construct like `new Unresolved()`. 1210 // exp() where exp is an erroneous construct like `new Unresolved()`.
1211 DartType type = analyze(node.selector); 1211 DartType type = analyze(node.selector);
1212 return analyzeInvocation(node, new TypeAccess(type)); 1212 return analyzeInvocation(node, new TypeAccess(type));
1213 } 1213 }
1214 1214
1215 String name = selector.source; 1215 String name = selector.source;
1216 1216
1217 if (node.isOperator && identical(name, 'is')) { 1217 if (node.isOperator && identical(name, 'is')) {
1218 analyze(node.receiver); 1218 analyze(node.receiver);
1219 if (!node.isIsNotCheck) { 1219 if (!node.isIsNotCheck) {
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 1999
2000 visitTypedef(Typedef node) { 2000 visitTypedef(Typedef node) {
2001 // Do not typecheck [Typedef] nodes. 2001 // Do not typecheck [Typedef] nodes.
2002 } 2002 }
2003 2003
2004 visitNode(Node node) { 2004 visitNode(Node node) {
2005 reporter.internalError(node, 2005 reporter.internalError(node,
2006 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 2006 'Unexpected node ${node.getObjectDescription()} in the type checker.');
2007 } 2007 }
2008 } 2008 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698