OLD | NEW |
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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:js_runtime/shared/embedded_names.dart'; | 5 import 'package:js_runtime/shared/embedded_names.dart'; |
6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
7 | 7 |
8 import '../closure.dart'; | 8 import '../closure.dart'; |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 437 |
438 @override | 438 @override |
439 bool isBreakTarget = false; | 439 bool isBreakTarget = false; |
440 | 440 |
441 @override | 441 @override |
442 bool isContinueTarget = false; | 442 bool isContinueTarget = false; |
443 | 443 |
444 KernelJumpTarget(this.targetStatement, KernelAstAdapter adapter, | 444 KernelJumpTarget(this.targetStatement, KernelAstAdapter adapter, |
445 {bool makeContinueLabel = false}) { | 445 {bool makeContinueLabel = false}) { |
446 originalStatement = targetStatement; | 446 originalStatement = targetStatement; |
447 this.labels = <LabelDefinition>[]; | 447 this.labels = <LabelDefinition<ast.Node>>[]; |
448 if (targetStatement is ir.WhileStatement || | 448 if (targetStatement is ir.WhileStatement || |
449 targetStatement is ir.DoStatement || | 449 targetStatement is ir.DoStatement || |
450 targetStatement is ir.ForStatement || | 450 targetStatement is ir.ForStatement || |
451 targetStatement is ir.ForInStatement) { | 451 targetStatement is ir.ForInStatement) { |
452 // Currently these labels are set at resolution on the element itself. | 452 // Currently these labels are set at resolution on the element itself. |
453 // Once that gets updated, this logic can change downstream. | 453 // Once that gets updated, this logic can change downstream. |
454 JumpTarget target = adapter.elements | 454 JumpTarget<ast.Node> target = adapter.elements |
455 .getTargetDefinition(adapter.getNode(targetStatement)); | 455 .getTargetDefinition(adapter.getNode(targetStatement)); |
456 if (target != null) { | 456 if (target != null) { |
457 labels.addAll(target.labels); | 457 labels.addAll(target.labels); |
458 isBreakTarget = target.isBreakTarget; | 458 isBreakTarget = target.isBreakTarget; |
459 isContinueTarget = target.isContinueTarget; | 459 isContinueTarget = target.isContinueTarget; |
460 } | 460 } |
461 } else if (targetStatement is ir.LabeledStatement) { | 461 } else if (targetStatement is ir.LabeledStatement) { |
462 targetStatement = (targetStatement as ir.LabeledStatement).body; | 462 targetStatement = (targetStatement as ir.LabeledStatement).body; |
463 labels.add( | 463 labels.add( |
464 new LabelDefinitionX(null, 'L${index++}', this)..setBreakTarget()); | 464 new LabelDefinitionX(null, 'L${index++}', this)..setBreakTarget()); |
465 isBreakTarget = true; | 465 isBreakTarget = true; |
466 } | 466 } |
467 var originalNode = adapter.getNode(originalStatement); | 467 var originalNode = adapter.getNode(originalStatement); |
468 var originalTarget = adapter.elements.getTargetDefinition(originalNode); | 468 var originalTarget = adapter.elements.getTargetDefinition(originalNode); |
469 if (originalTarget != null) { | 469 if (originalTarget != null) { |
470 nestingLevel = originalTarget.nestingLevel; | 470 nestingLevel = originalTarget.nestingLevel; |
471 } else { | 471 } else { |
472 nestingLevel = 0; | 472 nestingLevel = 0; |
473 } | 473 } |
474 | 474 |
475 if (makeContinueLabel) { | 475 if (makeContinueLabel) { |
476 labels.add( | 476 labels.add( |
477 new LabelDefinitionX(null, 'L${index++}', this)..setContinueTarget()); | 477 new LabelDefinitionX(null, 'L${index++}', this)..setContinueTarget()); |
478 isContinueTarget = true; | 478 isContinueTarget = true; |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 @override | 482 @override |
483 LabelDefinition addLabel(ast.Label label, String labelName) { | 483 LabelDefinition<ast.Node> addLabel(ast.Label label, String labelName) { |
484 LabelDefinition result = new LabelDefinitionX(label, labelName, this); | 484 LabelDefinition result = new LabelDefinitionX(label, labelName, this); |
485 labels.add(result); | 485 labels.add(result); |
486 return result; | 486 return result; |
487 } | 487 } |
488 | 488 |
489 @override | 489 @override |
490 ExecutableElement get executableContext => null; | 490 ExecutableElement get executableContext => null; |
491 | 491 |
492 @override | 492 @override |
493 MemberElement get memberContext => null; | 493 MemberElement get memberContext => null; |
494 | 494 |
495 @override | 495 @override |
496 bool get isSwitch => targetStatement is ir.SwitchStatement; | 496 bool get isSwitch => targetStatement is ir.SwitchStatement; |
497 | 497 |
498 @override | 498 @override |
499 bool get isTarget => isBreakTarget || isContinueTarget; | 499 bool get isTarget => isBreakTarget || isContinueTarget; |
500 | 500 |
501 @override | 501 @override |
502 List<LabelDefinition> labels; | 502 List<LabelDefinition<ast.Node>> labels; |
503 | 503 |
504 @override | 504 @override |
505 String get name => 'target'; | 505 String get name => 'target'; |
506 | 506 |
507 @override | 507 @override |
508 ast.Node get statement => null; | 508 ast.Label get statement => null; |
509 | 509 |
510 String toString() => 'Target:$targetStatement'; | 510 String toString() => 'Target:$targetStatement'; |
511 } | 511 } |
512 | 512 |
513 /// Special [JumpHandler] implementation used to handle continue statements | 513 /// Special [JumpHandler] implementation used to handle continue statements |
514 /// targeting switch cases. | 514 /// targeting switch cases. |
515 class KernelSwitchCaseJumpHandler extends SwitchCaseJumpHandler { | 515 class KernelSwitchCaseJumpHandler extends SwitchCaseJumpHandler { |
516 KernelSwitchCaseJumpHandler(GraphBuilder builder, JumpTarget target, | 516 KernelSwitchCaseJumpHandler(GraphBuilder builder, JumpTarget target, |
517 ir.SwitchStatement switchStatement, KernelToLocalsMap localsMap) | 517 ir.SwitchStatement switchStatement, KernelToLocalsMap localsMap) |
518 : super(builder, target) { | 518 : super(builder, target) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { | 643 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { |
644 return TypeMaskFactory.inferredTypeForSelector( | 644 return TypeMaskFactory.inferredTypeForSelector( |
645 selector, mask, _globalInferenceResults); | 645 selector, mask, _globalInferenceResults); |
646 } | 646 } |
647 | 647 |
648 TypeMask typeFromNativeBehavior( | 648 TypeMask typeFromNativeBehavior( |
649 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { | 649 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { |
650 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); | 650 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); |
651 } | 651 } |
652 } | 652 } |
OLD | NEW |