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

Side by Side Diff: pkg/compiler/lib/src/inferrer/locals_handler.dart

Issue 2926663002: Reapply (plus add some more) Entity-ify some portions of LocalsHandler and Closure. (Closed)
Patch Set: a few more entity changes to make dartanalyzer happy. Created 3 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
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 locals_handler; 5 library locals_handler;
6 6
7 import 'dart:collection' show IterableMixin; 7 import 'dart:collection' show IterableMixin;
8 8
9 import '../options.dart' show CompilerOptions; 9 import '../options.dart' show CompilerOptions;
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 239
240 /** 240 /**
241 * Placeholder for inferred types of local variables. 241 * Placeholder for inferred types of local variables.
242 */ 242 */
243 class LocalsHandler { 243 class LocalsHandler {
244 final CompilerOptions options; 244 final CompilerOptions options;
245 final TypeSystem types; 245 final TypeSystem types;
246 final InferrerEngine inferrer; 246 final InferrerEngine inferrer;
247 final VariableScope locals; 247 final VariableScope locals;
248 final Map<Local, Element> captured; 248 final Map<Local, FieldEntity> captured;
249 final Map<Local, Element> capturedAndBoxed; 249 final Map<Local, FieldEntity> capturedAndBoxed;
250 final FieldInitializationScope fieldScope; 250 final FieldInitializationScope fieldScope;
251 LocalsHandler tryBlock; 251 LocalsHandler tryBlock;
252 bool seenReturnOrThrow = false; 252 bool seenReturnOrThrow = false;
253 bool seenBreakOrContinue = false; 253 bool seenBreakOrContinue = false;
254 254
255 bool get aborts { 255 bool get aborts {
256 return seenReturnOrThrow || seenBreakOrContinue; 256 return seenReturnOrThrow || seenBreakOrContinue;
257 } 257 }
258 258
259 bool get inTryBlock => tryBlock != null; 259 bool get inTryBlock => tryBlock != null;
260 260
261 LocalsHandler(this.inferrer, this.types, this.options, Node block, 261 LocalsHandler(this.inferrer, this.types, this.options, Node block,
262 [this.fieldScope]) 262 [this.fieldScope])
263 : locals = new VariableScope(block), 263 : locals = new VariableScope(block),
264 captured = new Map<Local, Element>(), 264 captured = new Map<Local, FieldEntity>(),
265 capturedAndBoxed = new Map<Local, Element>(), 265 capturedAndBoxed = new Map<Local, FieldEntity>(),
266 tryBlock = null; 266 tryBlock = null;
267 267
268 LocalsHandler.from(LocalsHandler other, Node block, 268 LocalsHandler.from(LocalsHandler other, Node block,
269 {bool useOtherTryBlock: true}) 269 {bool useOtherTryBlock: true})
270 : locals = new VariableScope(block, other.locals), 270 : locals = new VariableScope(block, other.locals),
271 fieldScope = new FieldInitializationScope.from(other.fieldScope), 271 fieldScope = new FieldInitializationScope.from(other.fieldScope),
272 captured = other.captured, 272 captured = other.captured,
273 capturedAndBoxed = other.capturedAndBoxed, 273 capturedAndBoxed = other.capturedAndBoxed,
274 types = other.types, 274 types = other.types,
275 inferrer = other.inferrer, 275 inferrer = other.inferrer,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 tryBlock.locals.parent[local] = inputType; 348 tryBlock.locals.parent[local] = inputType;
349 } 349 }
350 // Update the current handler unconditionnally with the new 350 // Update the current handler unconditionnally with the new
351 // type. 351 // type.
352 updateLocal(); 352 updateLocal();
353 } else { 353 } else {
354 updateLocal(); 354 updateLocal();
355 } 355 }
356 } 356 }
357 357
358 void setCaptured(Local local, Element field) { 358 void setCaptured(Local local, FieldEntity field) {
359 captured[local] = field; 359 captured[local] = field;
360 } 360 }
361 361
362 void setCapturedAndBoxed(Local local, Element field) { 362 void setCapturedAndBoxed(Local local, FieldEntity field) {
363 capturedAndBoxed[local] = field; 363 capturedAndBoxed[local] = field;
364 } 364 }
365 365
366 void mergeDiamondFlow(LocalsHandler thenBranch, LocalsHandler elseBranch) { 366 void mergeDiamondFlow(LocalsHandler thenBranch, LocalsHandler elseBranch) {
367 if (fieldScope != null && elseBranch != null) { 367 if (fieldScope != null && elseBranch != null) {
368 fieldScope.mergeDiamondFlow(thenBranch.fieldScope, elseBranch.fieldScope); 368 fieldScope.mergeDiamondFlow(thenBranch.fieldScope, elseBranch.fieldScope);
369 } 369 }
370 seenReturnOrThrow = thenBranch.seenReturnOrThrow && 370 seenReturnOrThrow = thenBranch.seenReturnOrThrow &&
371 elseBranch != null && 371 elseBranch != null &&
372 elseBranch.seenReturnOrThrow; 372 elseBranch.seenReturnOrThrow;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (newType != type) { 543 if (newType != type) {
544 locals[variable] = newType; 544 locals[variable] = newType;
545 } 545 }
546 }); 546 });
547 } 547 }
548 548
549 void updateField(Element element, TypeInformation type) { 549 void updateField(Element element, TypeInformation type) {
550 fieldScope.updateField(element, type); 550 fieldScope.updateField(element, type);
551 } 551 }
552 } 552 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/inferrer_engine.dart ('k') | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698