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

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: Update with Johnni's comments. 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_test.dart » ('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) 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 // In the case of multiple declarations (and some definitions) on the same
751 closeAndGotoExit(new HReturn(value, 751 // line, the source pointer needs to point to the right initialized
752 sourceInformationBuilder.buildReturn(sendSet.assignmentOperator))); 752 // variable. So find the specific initialized variable we are referring to.
753 return closeFunction(); 753 ast.Node sourceInfoNode = initializer;
754 for (var definition in node.definitions) {
755 if (definition is ast.SendSet &&
756 definition.selector.toString() == variable.name) {
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 toString is mainly something we use for debugging
Emily Fortuna 2016/11/02 18:24:58 Done.
757 sourceInfoNode = definition.assignmentOperator;
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 let's add a break here as well (it doesn't change
Emily Fortuna 2016/11/02 18:24:58 Done.
758 }
759 }
760
761 closeAndGotoExit(new HReturn(value, sourceInformationBuilder.buildReturn(
762 sourceInfoNode)));
763 return closeFunction(); // token or source
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 remove trailing comment?
Emily Fortuna 2016/11/02 18:24:58 whoops thanks.
754 } 764 }
755 765
756 /** 766 /**
757 * Returns the constructor body associated with the given constructor or 767 * Returns the constructor body associated with the given constructor or
758 * creates a new constructor body, if none can be found. 768 * creates a new constructor body, if none can be found.
759 * 769 *
760 * Returns [:null:] if the constructor does not have a body. 770 * Returns [:null:] if the constructor does not have a body.
761 */ 771 */
762 ConstructorBodyElement getConstructorBody( 772 ConstructorBodyElement getConstructorBody(
763 ResolvedAst constructorResolvedAst) { 773 ResolvedAst constructorResolvedAst) {
(...skipping 6282 matching lines...) Expand 10 before | Expand all | Expand 10 after
7046 if (unaliased is TypedefType) throw 'unable to unalias $type'; 7056 if (unaliased is TypedefType) throw 'unable to unalias $type';
7047 unaliased.accept(this, builder); 7057 unaliased.accept(this, builder);
7048 } 7058 }
7049 7059
7050 void visitDynamicType(DynamicType type, SsaBuilder builder) { 7060 void visitDynamicType(DynamicType type, SsaBuilder builder) {
7051 JavaScriptBackend backend = builder.compiler.backend; 7061 JavaScriptBackend backend = builder.compiler.backend;
7052 ClassElement cls = backend.helpers.DynamicRuntimeType; 7062 ClassElement cls = backend.helpers.DynamicRuntimeType;
7053 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); 7063 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld)));
7054 } 7064 }
7055 } 7065 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698