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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1278463005: dart2js CPS: Fix an incorrect assertion. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 visitSend(ast.Send node) { 2140 visitSend(ast.Send node) {
2141 handleSend(node); 2141 handleSend(node);
2142 node.visitChildren(this); 2142 node.visitChildren(this);
2143 } 2143 }
2144 2144
2145 visitSendSet(ast.SendSet node) { 2145 visitSendSet(ast.SendSet node) {
2146 handleSend(node); 2146 handleSend(node);
2147 Element element = elements[node]; 2147 Element element = elements[node];
2148 if (Elements.isLocal(element)) { 2148 if (Elements.isLocal(element)) {
2149 LocalElement local = element; 2149 LocalElement local = element;
2150 if (insideInitializer) { 2150 if (insideInitializer &&
2151 assert(local.isParameter); 2151 local.isParameter &&
2152 local.enclosingElement == currentFunction) {
2153 assert(local.enclosingElement.isConstructor);
2152 // Initializers in an initializer-list can communicate via parameters. 2154 // Initializers in an initializer-list can communicate via parameters.
2153 // If a parameter is stored in an initializer list we box it. 2155 // If a parameter is stored in an initializer list we box it.
2154 // TODO(sigurdm): Fix this. 2156 // TODO(sigurdm): Fix this.
2155 // Though these variables do not outlive the activation of the 2157 // Though these variables do not outlive the activation of the
2156 // function, they still need to be boxed. As a simplification, we 2158 // function, they still need to be boxed. As a simplification, we
2157 // treat them as if they are captured by a closure (i.e., they do 2159 // treat them as if they are captured by a closure (i.e., they do
2158 // outlive the activation of the function). 2160 // outlive the activation of the function).
2159 markAsCaptured(local); 2161 markAsCaptured(local);
2160 } else if (inTryStatement) { 2162 } else if (inTryStatement) {
2161 assert(local.isParameter || local.isVariable); 2163 assert(local.isParameter || local.isVariable);
2162 // Search for the position of the try block containing the variable 2164 // Search for the position of the try block containing the variable
2163 // declaration, or -1 if it is declared outside the outermost try. 2165 // declaration, or -1 if it is declared outside the outermost try.
2164 int i = tryNestingStack.length - 1; 2166 int i = tryNestingStack.length - 1;
2165 while (i >= 0 && !tryNestingStack[i].declared.contains(local)) { 2167 while (i >= 0 && !tryNestingStack[i].declared.contains(local)) {
2166 --i; 2168 --i;
2167 } 2169 }
2168 // If there is a next inner try, then the variable should be boxed on 2170 // If there is a next inner try, then the variable should be boxed on
2169 // entry to it. 2171 // entry to it.
2170 if (i + 1 < tryNestingStack.length) { 2172 if (i + 1 < tryNestingStack.length) {
2171 tryNestingStack[i + 1].boxedOnEntry.add(local); 2173 tryNestingStack[i + 1].boxedOnEntry.add(local);
2172 } 2174 }
2173 } 2175 }
2174 } 2176 }
2175 node.visitChildren(this); 2177 node.visitChildren(this);
2176 } 2178 }
2177 2179
2178 visitFunctionExpression(ast.FunctionExpression node) { 2180 visitFunctionExpression(ast.FunctionExpression node) {
2179 FunctionElement oldFunction = currentFunction; 2181 FunctionElement savedFunction = currentFunction;
2180 currentFunction = elements[node]; 2182 currentFunction = elements[node];
2181 if (currentFunction.asyncMarker != AsyncMarker.SYNC) { 2183 if (currentFunction.asyncMarker != AsyncMarker.SYNC) {
2182 giveup(node, "cannot handle async/sync*/async* functions"); 2184 giveup(node, "cannot handle async/sync*/async* functions");
2183 } 2185 }
2186 bool savedInsideInitializer = insideInitializer;
karlklose 2015/08/07 06:00:54 insideInitializers is always false here, isn't it?
Kevin Millikin (Google) 2015/08/07 08:37:13 Yeah, it should be true (that it's always false :)
2184 if (node.initializers != null) { 2187 if (node.initializers != null) {
2185 insideInitializer = true; 2188 insideInitializer = true;
2186 visit(node.initializers); 2189 visit(node.initializers);
2187 insideInitializer = false;
2188 } 2190 }
2191 insideInitializer = false;
2189 visit(node.body); 2192 visit(node.body);
2190 currentFunction = oldFunction; 2193 currentFunction = savedFunction;
2194 insideInitializer = savedInsideInitializer;
2191 } 2195 }
2192 2196
2193 visitTryStatement(ast.TryStatement node) { 2197 visitTryStatement(ast.TryStatement node) {
2194 // Try/catch/finally is treated as two simpler constructs: try/catch and 2198 // Try/catch/finally is treated as two simpler constructs: try/catch and
2195 // try/finally. The encoding is: 2199 // try/finally. The encoding is:
2196 // 2200 //
2197 // try S0 catch (ex, st) S1 finally S2 2201 // try S0 catch (ex, st) S1 finally S2
2198 // ==> 2202 // ==>
2199 // try { try S0 catch (ex, st) S1 } finally S2 2203 // try { try S0 catch (ex, st) S1 } finally S2
2200 // 2204 //
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 if (compiler.backend.isForeign(function)) { 3339 if (compiler.backend.isForeign(function)) {
3336 return handleForeignCode(node, function, argumentList, callStructure); 3340 return handleForeignCode(node, function, argumentList, callStructure);
3337 } else { 3341 } else {
3338 return irBuilder.buildStaticFunctionInvocation(function, callStructure, 3342 return irBuilder.buildStaticFunctionInvocation(function, callStructure,
3339 translateStaticArguments(argumentList, function, callStructure), 3343 translateStaticArguments(argumentList, function, callStructure),
3340 sourceInformation: 3344 sourceInformation:
3341 sourceInformationBuilder.buildCall(node, node.selector)); 3345 sourceInformationBuilder.buildCall(node, node.selector));
3342 } 3346 }
3343 } 3347 }
3344 } 3348 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698