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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1376863004: Avoid eager enqueueing from resolution (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Update minimal_resolution_test. 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.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common/names.dart' show 7 import '../common/names.dart' show
8 Selectors; 8 Selectors;
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 return new ElementResult(element); 407 return new ElementResult(element);
408 } 408 }
409 return const NoneResult(); 409 return const NoneResult();
410 } 410 }
411 } 411 }
412 412
413 TypeResult visitTypeAnnotation(TypeAnnotation node) { 413 TypeResult visitTypeAnnotation(TypeAnnotation node) {
414 DartType type = resolveTypeAnnotation(node); 414 DartType type = resolveTypeAnnotation(node);
415 if (inCheckContext) { 415 if (inCheckContext) {
416 registry.registerIsCheck(type); 416 registry.registerCheckedModeCheck(type);
417 } 417 }
418 return new TypeResult(type); 418 return new TypeResult(type);
419 } 419 }
420 420
421 bool isNamedConstructor(Send node) => node.receiver != null; 421 bool isNamedConstructor(Send node) => node.receiver != null;
422 422
423 Selector getRedirectingThisOrSuperConstructorSelector(Send node) { 423 Selector getRedirectingThisOrSuperConstructorSelector(Send node) {
424 if (isNamedConstructor(node)) { 424 if (isNamedConstructor(node)) {
425 String constructorName = node.selector.asIdentifier().source; 425 String constructorName = node.selector.asIdentifier().source;
426 return new Selector.callConstructor( 426 return new Selector.callConstructor(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 }); 492 });
493 addDeferredAction(enclosingElement, () { 493 addDeferredAction(enclosingElement, () {
494 functionParameters.forEachOptionalParameter( 494 functionParameters.forEachOptionalParameter(
495 (ParameterElementX parameter) { 495 (ParameterElementX parameter) {
496 parameter.constant = 496 parameter.constant =
497 compiler.resolver.constantCompiler.compileConstant(parameter); 497 compiler.resolver.constantCompiler.compileConstant(parameter);
498 }); 498 });
499 }); 499 });
500 if (inCheckContext) { 500 if (inCheckContext) {
501 functionParameters.forEachParameter((ParameterElement element) { 501 functionParameters.forEachParameter((ParameterElement element) {
502 registry.registerIsCheck(element.type); 502 registry.registerCheckedModeCheck(element.type);
503 }); 503 });
504 } 504 }
505 } 505 }
506 506
507 ResolutionResult visitAssert(Assert node) { 507 ResolutionResult visitAssert(Assert node) {
508 if (!compiler.enableAssertMessage) { 508 if (!compiler.enableAssertMessage) {
509 if (node.hasMessage) { 509 if (node.hasMessage) {
510 compiler.reportErrorMessage( 510 compiler.reportErrorMessage(
511 node, MessageKind.EXPERIMENTAL_ASSERT_MESSAGE); 511 node, MessageKind.EXPERIMENTAL_ASSERT_MESSAGE);
512 } 512 }
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 return const NoneResult(); 1182 return const NoneResult();
1183 } 1183 }
1184 1184
1185 /// Handle a type cast expression, like `a as T`. 1185 /// Handle a type cast expression, like `a as T`.
1186 ResolutionResult handleAs(Send node) { 1186 ResolutionResult handleAs(Send node) {
1187 Node expression = node.receiver; 1187 Node expression = node.receiver;
1188 visitExpression(expression); 1188 visitExpression(expression);
1189 1189
1190 Node typeNode = node.arguments.head; 1190 Node typeNode = node.arguments.head;
1191 DartType type = resolveTypeAnnotation(typeNode); 1191 DartType type = resolveTypeAnnotation(typeNode);
1192 registry.registerAsCheck(type); 1192 registry.registerAsCast(type);
1193 registry.registerSendStructure(node, new AsStructure(type)); 1193 registry.registerSendStructure(node, new AsStructure(type));
1194 return const NoneResult(); 1194 return const NoneResult();
1195 } 1195 }
1196 1196
1197 /// Handle the unary expression of an unresolved unary operator [text], like 1197 /// Handle the unary expression of an unresolved unary operator [text], like
1198 /// the no longer supported `+a`. 1198 /// the no longer supported `+a`.
1199 ResolutionResult handleUnresolvedUnary(Send node, String text) { 1199 ResolutionResult handleUnresolvedUnary(Send node, String text) {
1200 Node expression = node.receiver; 1200 Node expression = node.receiver;
1201 if (node.isSuperCall) { 1201 if (node.isSuperCall) {
1202 checkSuperAccess(node); 1202 checkSuperAccess(node);
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 1944 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
1945 {'typeVariableName': name}, 1945 {'typeVariableName': name},
1946 isError: true); 1946 isError: true);
1947 registry.registerCompileTimeError(error); 1947 registry.registerCompileTimeError(error);
1948 semantics = new StaticAccess.invalid(error); 1948 semantics = new StaticAccess.invalid(error);
1949 // TODO(johnniwinther): Clean up registration of elements and selectors 1949 // TODO(johnniwinther): Clean up registration of elements and selectors
1950 // for this case. 1950 // for this case.
1951 } else { 1951 } else {
1952 semantics = new StaticAccess.typeParameterTypeLiteral(element); 1952 semantics = new StaticAccess.typeParameterTypeLiteral(element);
1953 } 1953 }
1954 registry.registerTypeVariableExpression(element);
1955 1954
1956 registry.useElement(node, element); 1955 registry.useElement(node, element);
1957 registry.registerTypeLiteral(node, element.type); 1956 registry.registerTypeLiteral(node, element.type);
1958 1957
1959 if (node.isCall) { 1958 if (node.isCall) {
1960 CallStructure callStructure = 1959 CallStructure callStructure =
1961 resolveArguments(node.argumentsNode).callStructure; 1960 resolveArguments(node.argumentsNode).callStructure;
1962 Selector selector = callStructure.callSelector; 1961 Selector selector = callStructure.callSelector;
1963 // TODO(23998): Remove this when all information goes through 1962 // TODO(23998): Remove this when all information goes through
1964 // the [SendStructure]. 1963 // the [SendStructure].
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 MessageKind.IF_NULL_ASSIGNING_TYPE, const {}); 1996 MessageKind.IF_NULL_ASSIGNING_TYPE, const {});
1998 // TODO(23998): Remove these when all information goes through 1997 // TODO(23998): Remove these when all information goes through
1999 // the [SendStructure]. 1998 // the [SendStructure].
2000 registry.useElement(node.selector, element); 1999 registry.useElement(node.selector, element);
2001 } else { 2000 } else {
2002 error = reportAndCreateErroneousElement( 2001 error = reportAndCreateErroneousElement(
2003 node.selector, name.text, 2002 node.selector, name.text,
2004 MessageKind.ASSIGNING_TYPE, const {}); 2003 MessageKind.ASSIGNING_TYPE, const {});
2005 } 2004 }
2006 2005
2007 if (node.isComplex) {
2008 // We read the type variable before trying write to it.
2009 registry.registerTypeVariableExpression(element);
2010 }
2011
2012 // TODO(23998): Remove this when all information goes through 2006 // TODO(23998): Remove this when all information goes through
2013 // the [SendStructure]. 2007 // the [SendStructure].
2014 registry.useElement(node, error); 2008 registry.useElement(node, error);
2009 // TODO(johnniwinther): Register only on read?
2015 registry.registerTypeLiteral(node, element.type); 2010 registry.registerTypeLiteral(node, element.type);
2016 registry.registerThrowNoSuchMethod(); 2011 registry.registerThrowNoSuchMethod();
2017 semantics = new StaticAccess.typeParameterTypeLiteral(element); 2012 semantics = new StaticAccess.typeParameterTypeLiteral(element);
2018 } 2013 }
2019 return handleUpdate(node, name, semantics); 2014 return handleUpdate(node, name, semantics);
2020 } 2015 }
2021 2016
2022 /// Handle access to a constant type literal of [type]. 2017 /// Handle access to a constant type literal of [type].
2023 // TODO(johnniwinther): Remove [name] when [Selector] is not required for the 2018 // TODO(johnniwinther): Remove [name] when [Selector] is not required for the
2024 // the [GetStructure]. 2019 // the [GetStructure].
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
4000 compiler, this, inConstContext: inConstContext)); 3995 compiler, this, inConstContext: inConstContext));
4001 } 3996 }
4002 3997
4003 DartType resolveTypeAnnotation(TypeAnnotation node, 3998 DartType resolveTypeAnnotation(TypeAnnotation node,
4004 {bool malformedIsError: false, 3999 {bool malformedIsError: false,
4005 bool deferredIsMalformed: true}) { 4000 bool deferredIsMalformed: true}) {
4006 DartType type = typeResolver.resolveTypeAnnotation( 4001 DartType type = typeResolver.resolveTypeAnnotation(
4007 this, node, malformedIsError: malformedIsError, 4002 this, node, malformedIsError: malformedIsError,
4008 deferredIsMalformed: deferredIsMalformed); 4003 deferredIsMalformed: deferredIsMalformed);
4009 if (inCheckContext) { 4004 if (inCheckContext) {
4010 registry.registerIsCheck(type); 4005 registry.registerCheckedModeCheck(type);
4011 registry.registerRequiredType(type, enclosingElement); 4006 registry.registerRequiredType(type, enclosingElement);
4012 } 4007 }
4013 return type; 4008 return type;
4014 } 4009 }
4015 4010
4016 ResolutionResult visitLiteralList(LiteralList node) { 4011 ResolutionResult visitLiteralList(LiteralList node) {
4017 bool isValidAsConstant = true; 4012 bool isValidAsConstant = true;
4018 sendIsMemberAccess = false; 4013 sendIsMemberAccess = false;
4019 4014
4020 NodeList arguments = node.typeArguments; 4015 NodeList arguments = node.typeArguments;
(...skipping 19 matching lines...) Expand all
4040 if (node.isConst && typeArgument.containsTypeVariables) { 4035 if (node.isConst && typeArgument.containsTypeVariables) {
4041 compiler.reportErrorMessage( 4036 compiler.reportErrorMessage(
4042 arguments.nodes.head, 4037 arguments.nodes.head,
4043 MessageKind.TYPE_VARIABLE_IN_CONSTANT); 4038 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
4044 isValidAsConstant = false; 4039 isValidAsConstant = false;
4045 } 4040 }
4046 listType = coreTypes.listType(typeArgument); 4041 listType = coreTypes.listType(typeArgument);
4047 } else { 4042 } else {
4048 listType = coreTypes.listType(); 4043 listType = coreTypes.listType();
4049 } 4044 }
4050 registry.setType(node, listType); 4045 registry.registerLiteralList(
4051 registry.registerInstantiatedType(listType); 4046 node,
4047 listType,
4048 isConstant: node.isConst,
4049 isEmpty: node.elements.isEmpty);
4052 registry.registerRequiredType(listType, enclosingElement); 4050 registry.registerRequiredType(listType, enclosingElement);
4053 if (node.isConst) { 4051 if (node.isConst) {
4054 List<ConstantExpression> constantExpressions = <ConstantExpression>[]; 4052 List<ConstantExpression> constantExpressions = <ConstantExpression>[];
4055 inConstantContext(() { 4053 inConstantContext(() {
4056 for (Node element in node.elements) { 4054 for (Node element in node.elements) {
4057 ResolutionResult elementResult = visit(element); 4055 ResolutionResult elementResult = visit(element);
4058 if (isValidAsConstant && elementResult.isConstant) { 4056 if (isValidAsConstant && elementResult.isConstant) {
4059 constantExpressions.add(elementResult.constant); 4057 constantExpressions.add(elementResult.constant);
4060 } else { 4058 } else {
4061 isValidAsConstant = false; 4059 isValidAsConstant = false;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
4361 mapType = coreTypes.mapType(keyTypeArgument, valueTypeArgument); 4359 mapType = coreTypes.mapType(keyTypeArgument, valueTypeArgument);
4362 } else { 4360 } else {
4363 mapType = coreTypes.mapType(); 4361 mapType = coreTypes.mapType();
4364 } 4362 }
4365 if (node.isConst && mapType.containsTypeVariables) { 4363 if (node.isConst && mapType.containsTypeVariables) {
4366 compiler.reportErrorMessage( 4364 compiler.reportErrorMessage(
4367 arguments, 4365 arguments,
4368 MessageKind.TYPE_VARIABLE_IN_CONSTANT); 4366 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
4369 isValidAsConstant = false; 4367 isValidAsConstant = false;
4370 } 4368 }
4371 registry.registerMapLiteral(node, mapType, node.isConst); 4369 registry.registerMapLiteral(
4370 node,
4371 mapType,
4372 isConstant: node.isConst,
4373 isEmpty: node.entries.isEmpty);
4372 registry.registerRequiredType(mapType, enclosingElement); 4374 registry.registerRequiredType(mapType, enclosingElement);
4373 if (node.isConst) { 4375 if (node.isConst) {
4374 4376
4375 List<ConstantExpression> keyExpressions = <ConstantExpression>[]; 4377 List<ConstantExpression> keyExpressions = <ConstantExpression>[];
4376 List<ConstantExpression> valueExpressions = <ConstantExpression>[]; 4378 List<ConstantExpression> valueExpressions = <ConstantExpression>[];
4377 inConstantContext(() { 4379 inConstantContext(() {
4378 for (LiteralMapEntry entry in node.entries) { 4380 for (LiteralMapEntry entry in node.entries) {
4379 ResolutionResult keyResult = visit(entry.key); 4381 ResolutionResult keyResult = visit(entry.key);
4380 ResolutionResult valueResult = visit(entry.value); 4382 ResolutionResult valueResult = visit(entry.value);
4381 if (isValidAsConstant && 4383 if (isValidAsConstant &&
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4688 } 4690 }
4689 return const NoneResult(); 4691 return const NoneResult();
4690 } 4692 }
4691 } 4693 }
4692 4694
4693 /// Looks up [name] in [scope] and unwraps the result. 4695 /// Looks up [name] in [scope] and unwraps the result.
4694 Element lookupInScope(Compiler compiler, Node node, 4696 Element lookupInScope(Compiler compiler, Node node,
4695 Scope scope, String name) { 4697 Scope scope, String name) {
4696 return Elements.unwrap(scope.lookup(name), compiler, node); 4698 return Elements.unwrap(scope.lookup(name), compiler, node);
4697 } 4699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698