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

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

Issue 1842033004: Add *IndexSetIfNull methods to SemanticSendVisitor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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) 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 library dart2js.resolution.send_structure; 5 library dart2js.resolution.send_structure;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 // This is not a valid case. 1983 // This is not a valid case.
1984 break; 1984 break;
1985 } 1985 }
1986 throw new SpannableAssertionFailure( 1986 throw new SpannableAssertionFailure(
1987 node, "Invalid compound index set: ${semantics}"); 1987 node, "Invalid compound index set: ${semantics}");
1988 } 1988 }
1989 1989
1990 String toString() => 'compound []=($operator,$semantics)'; 1990 String toString() => 'compound []=($operator,$semantics)';
1991 } 1991 }
1992 1992
1993 /// The structure for a [Send] that is a if-null assignment on the index
1994 /// operator. For instance `a[b] ??= c`.
1995 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> {
1996 /// The target of the index operations.
1997 final AccessSemantics semantics;
1998
1999 IndexSetIfNullStructure(this.semantics);
2000
2001 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
2002 switch (semantics.kind) {
2003 case AccessKind.EXPRESSION:
2004 return visitor.visitIndexSetIfNull(
2005 node,
2006 node.receiver,
2007 node.arguments.first,
2008 node.arguments.tail.head,
2009 arg);
2010 case AccessKind.UNRESOLVED_SUPER:
2011 return visitor.visitUnresolvedSuperIndexSetIfNull(
2012 node,
2013 semantics.element,
2014 node.arguments.first,
2015 node.arguments.tail.head,
2016 arg);
2017 case AccessKind.INVALID:
2018 return visitor.errorInvalidIndexSetIfNull(
2019 node,
2020 semantics.element,
2021 node.arguments.first,
2022 node.arguments.tail.head,
2023 arg);
2024 case AccessKind.COMPOUND:
2025 CompoundAccessSemantics compoundSemantics = semantics;
2026 switch (compoundSemantics.compoundAccessKind) {
2027 case CompoundAccessKind.SUPER_GETTER_SETTER:
2028 return visitor.visitSuperIndexSetIfNull(
2029 node,
2030 compoundSemantics.getter,
2031 compoundSemantics.setter,
2032 node.arguments.first,
2033 node.arguments.tail.head,
2034 arg);
2035 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
2036 return visitor.visitUnresolvedSuperGetterIndexSetIfNull(
2037 node,
2038 compoundSemantics.getter,
2039 compoundSemantics.setter,
2040 node.arguments.first,
2041 node.arguments.tail.head,
2042 arg);
2043 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
2044 return visitor.visitUnresolvedSuperSetterIndexSetIfNull(
2045 node,
2046 compoundSemantics.getter,
2047 compoundSemantics.setter,
2048 node.arguments.first,
2049 node.arguments.tail.head,
2050 arg);
2051 default:
2052 // This is not a valid case.
2053 break;
2054 }
2055 break;
2056 default:
2057 // This is not a valid case.
2058 break;
2059 }
2060 throw new SpannableAssertionFailure(
2061 node, "Invalid index set if-null: ${semantics}");
2062 }
2063
2064 String toString() => 'index set if-null []??=($semantics)';
2065 }
2066
1993 /// The structure for a [Send] that is a prefix operations. For instance 2067 /// The structure for a [Send] that is a prefix operations. For instance
1994 /// `++a`. 2068 /// `++a`.
1995 class PrefixStructure<R, A> implements SendStructure<R, A> { 2069 class PrefixStructure<R, A> implements SendStructure<R, A> {
1996 /// The target of the prefix operation. 2070 /// The target of the prefix operation.
1997 final AccessSemantics semantics; 2071 final AccessSemantics semantics;
1998 2072
1999 /// The `++` or `--` operator used in the operation. 2073 /// The `++` or `--` operator used in the operation.
2000 final IncDecOperator operator; 2074 final IncDecOperator operator;
2001 2075
2002 PrefixStructure(this.semantics, 2076 PrefixStructure(this.semantics,
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 ThisConstructorInvokeStructure( 3092 ThisConstructorInvokeStructure(
3019 this.node, this.constructor, this.callStructure); 3093 this.node, this.constructor, this.callStructure);
3020 3094
3021 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { 3095 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
3022 return visitor.visitThisConstructorInvoke( 3096 return visitor.visitThisConstructorInvoke(
3023 node, constructor, node.argumentsNode, callStructure, arg); 3097 node, constructor, node.argumentsNode, callStructure, arg);
3024 } 3098 }
3025 3099
3026 bool get isConstructorInvoke => true; 3100 bool get isConstructorInvoke => true;
3027 } 3101 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698