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

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

Issue 2471543004: Fix compiler crash when we declare several (global) variables, but only define some of them. (Closed)
Patch Set: cleanup Created 4 years, 1 month 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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 message: "Unexpected variable $variable for $resolvedAst.")); 740 message: "Unexpected variable $variable for $resolvedAst."));
741 inLazyInitializerExpression = true; 741 inLazyInitializerExpression = true;
742 ast.VariableDefinitions node = resolvedAst.node; 742 ast.VariableDefinitions node = resolvedAst.node;
743 ast.Node initializer = resolvedAst.body; 743 ast.Node initializer = resolvedAst.body;
744 assert(invariant(variable, initializer != null, 744 assert(invariant(variable, initializer != null,
745 message: "Non-constant variable $variable has no initializer.")); 745 message: "Non-constant variable $variable has no initializer."));
746 openFunction(variable, node); 746 openFunction(variable, node);
747 visit(initializer); 747 visit(initializer);
748 HInstruction value = pop(); 748 HInstruction value = pop();
749 value = potentiallyCheckOrTrustType(value, variable.type); 749 value = potentiallyCheckOrTrustType(value, variable.type);
750 ast.SendSet sendSet = node.definitions.nodes.head; 750 ast.Node sendSet;
751 closeAndGotoExit(new HReturn(value, 751 var iterator = node.definitions.nodes.iterator;
752 sourceInformationBuilder.buildReturn(sendSet.assignmentOperator))); 752 while (iterator.current is! ast.SendSet) {
753 return closeFunction(); 753 iterator.moveNext();
Johnni Winther 2016/11/02 10:41:31 To find the right node you need to check `if (iter
Emily Fortuna 2016/11/02 18:09:21 Thanks for helping me understand how this works. I
754 }
755
756 closeAndGotoExit(new HReturn(value, sourceInformationBuilder.buildReturn(
757 iterator.current.assignmentOperator)));
758 return closeFunction(); // token or source
754 } 759 }
755 760
756 /** 761 /**
757 * Returns the constructor body associated with the given constructor or 762 * Returns the constructor body associated with the given constructor or
758 * creates a new constructor body, if none can be found. 763 * creates a new constructor body, if none can be found.
759 * 764 *
760 * Returns [:null:] if the constructor does not have a body. 765 * Returns [:null:] if the constructor does not have a body.
761 */ 766 */
762 ConstructorBodyElement getConstructorBody( 767 ConstructorBodyElement getConstructorBody(
763 ResolvedAst constructorResolvedAst) { 768 ResolvedAst constructorResolvedAst) {
(...skipping 6282 matching lines...) Expand 10 before | Expand all | Expand 10 after
7046 if (unaliased is TypedefType) throw 'unable to unalias $type'; 7051 if (unaliased is TypedefType) throw 'unable to unalias $type';
7047 unaliased.accept(this, builder); 7052 unaliased.accept(this, builder);
7048 } 7053 }
7049 7054
7050 void visitDynamicType(DynamicType type, SsaBuilder builder) { 7055 void visitDynamicType(DynamicType type, SsaBuilder builder) {
7051 JavaScriptBackend backend = builder.compiler.backend; 7056 JavaScriptBackend backend = builder.compiler.backend;
7052 ClassElement cls = backend.helpers.DynamicRuntimeType; 7057 ClassElement cls = backend.helpers.DynamicRuntimeType;
7053 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); 7058 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld)));
7054 } 7059 }
7055 } 7060 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698