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

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2666803002: Add SuperPropertyGet. (Closed)
Patch Set: . Created 3 years, 10 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/ssa/builder_kernel.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../compiler.dart'; 10 import '../compiler.dart';
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Name getName(ir.Name name) { 195 Name getName(ir.Name name) {
196 return new Name( 196 return new Name(
197 name.name, name.isPrivate ? getElement(name.library) : null); 197 name.name, name.isPrivate ? getElement(name.library) : null);
198 } 198 }
199 199
200 ir.Field getFieldFromElement(FieldElement field) { 200 ir.Field getFieldFromElement(FieldElement field) {
201 return kernel.fields[field]; 201 return kernel.fields[field];
202 } 202 }
203 203
204 Selector getSelector(ir.Expression node) { 204 Selector getSelector(ir.Expression node) {
205 if (node is ir.PropertyGet) return getGetterSelector(node); 205 if (node is ir.PropertyGet || node is ir.SuperPropertyGet) {
206 if (node is ir.PropertySet) return getSetterSelector(node); 206 return getGetterSelector(node);
207 }
208 if (node is ir.PropertySet || node is ir.SuperPropertySet) {
209 return getSetterSelector(node);
210 }
207 if (node is ir.InvocationExpression) return getInvocationSelector(node); 211 if (node is ir.InvocationExpression) return getInvocationSelector(node);
208 _compiler.reporter.internalError(getNode(node), 212 _compiler.reporter.internalError(getNode(node),
209 "Can only get the selector for a property get or an invocation."); 213 "Can only get the selector for a property get or an invocation.");
210 return null; 214 return null;
211 } 215 }
212 216
213 Selector getInvocationSelector(ir.InvocationExpression invocation) { 217 Selector getInvocationSelector(ir.InvocationExpression invocation) {
214 Name name = getName(invocation.name); 218 Name name = getName(invocation.name);
215 SelectorKind kind; 219 SelectorKind kind;
216 if (Elements.isOperatorName(invocation.name.name)) { 220 if (Elements.isOperatorName(invocation.name.name)) {
217 if (name == Names.INDEX_NAME || name == Names.INDEX_SET_NAME) { 221 if (name == Names.INDEX_NAME || name == Names.INDEX_SET_NAME) {
218 kind = SelectorKind.INDEX; 222 kind = SelectorKind.INDEX;
219 } else { 223 } else {
220 kind = SelectorKind.OPERATOR; 224 kind = SelectorKind.OPERATOR;
221 } 225 }
222 } else { 226 } else {
223 kind = SelectorKind.CALL; 227 kind = SelectorKind.CALL;
224 } 228 }
225 229
226 CallStructure callStructure = getCallStructure(invocation.arguments); 230 CallStructure callStructure = getCallStructure(invocation.arguments);
227 return new Selector(kind, name, callStructure); 231 return new Selector(kind, name, callStructure);
228 } 232 }
229 233
230 Selector getGetterSelector(ir.PropertyGet getter) { 234 Selector getGetterSelector(ir.Expression getter) {
235 // Getter is a PropertyGet or SuperPropertyGet.
236 // TODO(efortuna): Common interface?
Emily Fortuna 2017/01/31 00:17:16 these are clearly screaming out for a common inter
231 ir.Name irName = getter.name; 237 ir.Name irName = getter.name;
232 Name name = new Name( 238 Name name = new Name(
233 irName.name, irName.isPrivate ? getElement(irName.library) : null); 239 irName.name, irName.isPrivate ? getElement(irName.library) : null);
234 return new Selector.getter(name); 240 return new Selector.getter(name);
235 } 241 }
236 242
237 Selector getSetterSelector(ir.PropertySet setter) { 243 Selector getSetterSelector(ir.Expression setter) {
244 // Getter is a PropertySet or SuperPropertySet.
245 // TODO(efortuna): Common interface?
238 ir.Name irName = setter.name; 246 ir.Name irName = setter.name;
239 Name name = new Name( 247 Name name = new Name(
240 irName.name, irName.isPrivate ? getElement(irName.library) : null); 248 irName.name, irName.isPrivate ? getElement(irName.library) : null);
241 return new Selector.setter(name); 249 return new Selector.setter(name);
242 } 250 }
243 251
244 TypeMask typeOfInvocation(ir.MethodInvocation send, ClosedWorld closedWorld) { 252 TypeMask typeOfInvocation(ir.MethodInvocation send, ClosedWorld closedWorld) {
245 ast.Node operatorNode = kernel.nodeToAstOperator[send]; 253 ast.Node operatorNode = kernel.nodeToAstOperator[send];
246 if (operatorNode != null) { 254 if (operatorNode != null) {
247 return _resultOf(_target).typeOfOperator(operatorNode); 255 return _resultOf(_target).typeOfOperator(operatorNode);
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 JumpTarget continueTarget = 1117 JumpTarget continueTarget =
1110 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); 1118 astAdapter.getJumpTarget(switchCase, isContinueTarget: true);
1111 assert(continueTarget is KernelJumpTarget); 1119 assert(continueTarget is KernelJumpTarget);
1112 targetIndexMap[continueTarget] = switchIndex; 1120 targetIndexMap[continueTarget] = switchIndex;
1113 assert(builder.jumpTargets[continueTarget] == null); 1121 assert(builder.jumpTargets[continueTarget] == null);
1114 builder.jumpTargets[continueTarget] = this; 1122 builder.jumpTargets[continueTarget] = this;
1115 switchIndex++; 1123 switchIndex++;
1116 } 1124 }
1117 } 1125 }
1118 } 1126 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698