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

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

Issue 1282773002: Refactor and clean up AccessSemantics (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dart2js.semantics_visitor; 5 part of dart2js.semantics_visitor;
6 6
7 enum SendStructureKind { 7 enum SendStructureKind {
8 GET, 8 GET,
9 SET, 9 SET,
10 INVOKE, 10 INVOKE,
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } else if (isCompound) { 497 } else if (isCompound) {
498 return new CompoundAccessSemantics( 498 return new CompoundAccessSemantics(
499 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element); 499 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element);
500 } else { 500 } else {
501 return new StaticAccess.superMethod(element); 501 return new StaticAccess.superMethod(element);
502 } 502 }
503 } else if (node.isConditional) { 503 } else if (node.isConditional) {
504 // Conditional sends (e?.x) are treated as dynamic property reads because 504 // Conditional sends (e?.x) are treated as dynamic property reads because
505 // they are equivalent to do ((a) => a == null ? null : a.x)(e). If `e` is 505 // they are equivalent to do ((a) => a == null ? null : a.x)(e). If `e` is
506 // a type `A`, this is equivalent to write `(A).x`. 506 // a type `A`, this is equivalent to write `(A).x`.
507 return new DynamicAccess.ifNotNullProperty(node.receiver); 507 return const DynamicAccess.ifNotNullProperty();
508 } else if (node.isOperator) { 508 } else if (node.isOperator) {
509 return new DynamicAccess.dynamicProperty(node.receiver); 509 return const DynamicAccess.dynamicProperty();
510 } else if (Elements.isClosureSend(node, element)) { 510 } else if (Elements.isClosureSend(node, element)) {
511 if (element == null) { 511 if (element == null) {
512 if (node.selector.isThis()) { 512 if (node.selector.isThis()) {
513 return new AccessSemantics.thisAccess(); 513 return new DynamicAccess.thisAccess();
514 } else { 514 } else {
515 return new AccessSemantics.expression(); 515 return new DynamicAccess.expression();
516 } 516 }
517 } else if (Elements.isErroneous(element)) { 517 } else if (Elements.isErroneous(element)) {
518 return new StaticAccess.unresolved(element); 518 return new StaticAccess.unresolved(element);
519 } else { 519 } else {
520 return handleStaticallyResolvedAccess( 520 return handleStaticallyResolvedAccess(
521 node, element, getter, isCompound: isCompound); 521 node, element, getter, isCompound: isCompound);
522 } 522 }
523 } else { 523 } else {
524 bool isDynamicAccess(Element e) => e == null || e.isInstanceMember; 524 bool isDynamicAccess(Element e) => e == null || e.isInstanceMember;
525 525
526 if (isDynamicAccess(element) && 526 if (isDynamicAccess(element) &&
527 (!isCompound || isDynamicAccess(getter))) { 527 (!isCompound || isDynamicAccess(getter))) {
528 if (node.receiver == null || node.receiver.isThis()) { 528 if (node.receiver == null || node.receiver.isThis()) {
529 return new AccessSemantics.thisProperty(); 529 return const DynamicAccess.thisProperty();
530 } else { 530 } else {
531 return new DynamicAccess.dynamicProperty(node.receiver); 531 return const DynamicAccess.dynamicProperty();
532 } 532 }
533 } else if (element != null && element.impliesType) { 533 } else if (element != null && element.impliesType) {
534 // TODO(johnniwinther): Provide an [ErroneousElement]. 534 // TODO(johnniwinther): Provide an [ErroneousElement].
535 // This happens for code like `C.this`. 535 // This happens for code like `C.this`.
536 return new StaticAccess.unresolved(null); 536 return new StaticAccess.unresolved(null);
537 } else { 537 } else {
538 return handleStaticallyResolvedAccess( 538 return handleStaticallyResolvedAccess(
539 node, element, getter, isCompound: isCompound); 539 node, element, getter, isCompound: isCompound);
540 } 540 }
541 } 541 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 return internalError(node, "Unexpected variable $element."); 985 return internalError(node, "Unexpected variable $element.");
986 } 986 }
987 if (element.isConst) { 987 if (element.isConst) {
988 ConstantExpression constant = elements.getConstant(element.initializer); 988 ConstantExpression constant = elements.getConstant(element.initializer);
989 return new ConstantVariableStructure(kind, node, element, constant); 989 return new ConstantVariableStructure(kind, node, element, constant);
990 } else { 990 } else {
991 return new NonConstantVariableStructure(kind, node, element); 991 return new NonConstantVariableStructure(kind, node, element);
992 } 992 }
993 } 993 }
994 } 994 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698