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

Side by Side Diff: lib/kernel_visitor.dart

Issue 2059733002: More bad for-in loop variables. (Closed) Base URL: git@github.com:dart-lang/rasta.git@parser_crash
Patch Set: Created 4 years, 6 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 | « no previous file | submodules.txt » ('j') | 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library rasta.kernel_visitor; 5 library rasta.kernel_visitor;
6 6
7 import 'package:kernel/ast.dart' as ir; 7 import 'package:kernel/ast.dart' as ir;
8 8
9 import 'package:kernel/accessors.dart' show 9 import 'package:kernel/accessors.dart' show
10 Accessor, 10 Accessor,
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ForIn node, 415 ForIn node,
416 VariableDefinitions declaration, 416 VariableDefinitions declaration,
417 {bool isAsync}) { 417 {bool isAsync}) {
418 ir.VariableDeclaration variable = buildStatementInBlock(declaration); 418 ir.VariableDeclaration variable = buildStatementInBlock(declaration);
419 return buildForInCommon( 419 return buildForInCommon(
420 node, variable, buildStatementInBlock(node.body), isAsync: isAsync); 420 node, variable, buildStatementInBlock(node.body), isAsync: isAsync);
421 } 421 }
422 422
423 Accessor computeAccessor(ForIn node, Element element) { 423 Accessor computeAccessor(ForIn node, Element element) {
424 if (element == null) { 424 if (element == null) {
425 Send send = node.declaredIdentifier.asSend();
426 if (send == null) {
427 return new StaticAccessor(null, null);
428 }
425 // This should be the situation where `node.declaredIdentifier` is 429 // This should be the situation where `node.declaredIdentifier` is
426 // unresolved, but in an instance method context. If it is some different 430 // unresolved, but in an instance method context. If it is some different
427 // situation, the assignment to [ir.PropertyGet] should act as an 431 // situation, the assignment to [ir.PropertyGet] should act as an
428 // assertion. 432 // assertion.
429 ir.PropertyGet expression = node.declaredIdentifier.accept(this); 433 ir.PropertyGet expression = send.accept(this);
430 return PropertyAccessor.make(expression.receiver, expression.name); 434 return PropertyAccessor.make(expression.receiver, expression.name);
431 } else if (kernel.isSyntheticError(element)) { 435 } else if (kernel.isSyntheticError(element)) {
432 return new StaticAccessor(null, null); 436 return new StaticAccessor(null, null);
433 } else if (element.isGetter) { 437 } else if (element.isGetter) {
434 if (element.isInstanceMember) { 438 if (element.isInstanceMember) {
435 return new ThisPropertyAccessor(kernel.irName(element.name, element)); 439 return new ThisPropertyAccessor(kernel.irName(element.name, element));
436 } else { 440 } else {
437 GetterElement getter = element; 441 GetterElement getter = element;
438 Element setter = getter.setter; 442 Element setter = getter.setter;
439 return new StaticAccessor( 443 return new StaticAccessor(
440 kernel.elementToIr(element), 444 kernel.elementToIr(element),
441 setter == null ? null : kernel.elementToIr(element)); 445 setter == null ? null : kernel.elementToIr(element));
442 } 446 }
443 } else if (element.isLocal) { 447 } else if (element.isLocal) {
444 return new VariableAccessor(getLocal(element)); 448 return new VariableAccessor(getLocal(element));
445 } else if (element.isField) { 449 } else if (element.isField) {
446 ir.Member member = kernel.elementToIr(element); 450 ir.Member member = kernel.elementToIr(element);
447 return new StaticAccessor( 451 return new StaticAccessor(
448 member, (element.isFinal || element.isConst) ? null : member); 452 member, (element.isFinal || element.isConst) ? null : member);
449 } else { 453 } else {
450 throw internalError(node, "Unhandled for-in variable: $element"); 454 return new StaticAccessor(null, null);
451 } 455 }
452 } 456 }
453 457
454 /// Builds a for-in statement for this case: 458 /// Builds a for-in statement for this case:
455 /// 459 ///
456 /// for (element in expression) body 460 /// for (element in expression) body
457 /// 461 ///
458 /// This is normalized to: 462 /// This is normalized to:
459 /// 463 ///
460 /// for (final #t in expression) { 464 /// for (final #t in expression) {
(...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 : this(null, true, node, initializers); 3016 : this(null, true, node, initializers);
3013 3017
3014 accept(ir.Visitor v) => throw "unsupported"; 3018 accept(ir.Visitor v) => throw "unsupported";
3015 3019
3016 visitChildren(ir.Visitor v) => throw "unsupported"; 3020 visitChildren(ir.Visitor v) => throw "unsupported";
3017 3021
3018 String toString() { 3022 String toString() {
3019 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 3023 return "IrFunction($kind, $isConstructor, $node, $initializers)";
3020 } 3024 }
3021 } 3025 }
OLDNEW
« no previous file with comments | « no previous file | submodules.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698