| OLD | NEW |
| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 LocalsHandler locals)); | 689 LocalsHandler locals)); |
| 690 void close(); | 690 void close(); |
| 691 final TargetElement target; | 691 final TargetElement target; |
| 692 List<LabelElement> labels(); | 692 List<LabelElement> labels(); |
| 693 } | 693 } |
| 694 | 694 |
| 695 // Insert break handler used to avoid null checks when a target isn't | 695 // Insert break handler used to avoid null checks when a target isn't |
| 696 // used as the target of a break, and therefore doesn't need a break | 696 // used as the target of a break, and therefore doesn't need a break |
| 697 // handler associated with it. | 697 // handler associated with it. |
| 698 class NullJumpHandler implements JumpHandler { | 698 class NullJumpHandler implements JumpHandler { |
| 699 const NullJumpHandler(); | 699 final Compiler compiler; |
| 700 NullJumpHandler(this.compiler); |
| 700 | 701 |
| 701 void generateBreak([LabelElement label]) { | 702 void generateBreak([LabelElement label]) { |
| 702 // TODO(lrn): Need a compiler object and a location. Since label | 703 // TODO(lrn): Need a compiler object and a location. Since label |
| 703 // is optional, it may be null so we also need a position. | 704 // is optional, it may be null so we also need a position. |
| 704 compiler.internalError('generateBreak should not be called', | 705 compiler.internalError('generateBreak should not be called'); |
| 705 missingPosition); | |
| 706 } | 706 } |
| 707 | 707 |
| 708 void generateContinue([LabelElement label]) { | 708 void generateContinue([LabelElement label]) { |
| 709 // TODO(lrn): Need a compiler object and a location. Since label | 709 // TODO(lrn): Need a compiler object and a location. Since label |
| 710 // is optional, it may be null so we also need a position. | 710 // is optional, it may be null so we also need a position. |
| 711 compiler.internalError('generateContinue should not be called', | 711 compiler.internalError('generateContinue should not be called'); |
| 712 missingPosition); | |
| 713 } | 712 } |
| 714 | 713 |
| 715 void forEachBreak(Function ignored) { } | 714 void forEachBreak(Function ignored) { } |
| 716 void forEachContinue(Function ignored) { } | 715 void forEachContinue(Function ignored) { } |
| 717 void close() { } | 716 void close() { } |
| 718 final TargetElement target = null; | 717 final TargetElement target = null; |
| 719 List<LabelElement> labels() => const <LabelElement>[]; | 718 List<LabelElement> labels() => const <LabelElement>[]; |
| 720 } | 719 } |
| 721 | 720 |
| 722 // Records breaks until a target block is available. | 721 // Records breaks until a target block is available. |
| (...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 | 2795 |
| 2797 /** | 2796 /** |
| 2798 * Creates a [JumpHandler] for a statement. The node must be a jump | 2797 * Creates a [JumpHandler] for a statement. The node must be a jump |
| 2799 * target. If there are no breaks or continues targeting the statement, | 2798 * target. If there are no breaks or continues targeting the statement, |
| 2800 * a special "null handler" is returned. | 2799 * a special "null handler" is returned. |
| 2801 */ | 2800 */ |
| 2802 JumpHandler createJumpHandler(Statement node) { | 2801 JumpHandler createJumpHandler(Statement node) { |
| 2803 TargetElement element = elements[node]; | 2802 TargetElement element = elements[node]; |
| 2804 if (element === null || element.statement !== node) { | 2803 if (element === null || element.statement !== node) { |
| 2805 // No breaks or continues to this node. | 2804 // No breaks or continues to this node. |
| 2806 return const NullJumpHandler(); | 2805 return new NullJumpHandler(compiler); |
| 2807 } | 2806 } |
| 2808 return new JumpHandler(this, element); | 2807 return new JumpHandler(this, element); |
| 2809 } | 2808 } |
| 2810 | 2809 |
| 2811 visitForIn(ForIn node) { | 2810 visitForIn(ForIn node) { |
| 2812 // Generate a structure equivalent to: | 2811 // Generate a structure equivalent to: |
| 2813 // Iterator<E> $iter = <iterable>.iterator() | 2812 // Iterator<E> $iter = <iterable>.iterator() |
| 2814 // while ($iter.hasNext()) { | 2813 // while ($iter.hasNext()) { |
| 2815 // E <declaredIdentifier> = $iter.next(); | 2814 // E <declaredIdentifier> = $iter.next(); |
| 2816 // <body> | 2815 // <body> |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3414 <HInstruction>[target, input], | 3413 <HInstruction>[target, input], |
| 3415 HType.STRING)); | 3414 HType.STRING)); |
| 3416 return builder.pop(); | 3415 return builder.pop(); |
| 3417 } | 3416 } |
| 3418 | 3417 |
| 3419 HInstruction result(Node node) { | 3418 HInstruction result(Node node) { |
| 3420 flushLiterals(node); | 3419 flushLiterals(node); |
| 3421 return prefix; | 3420 return prefix; |
| 3422 } | 3421 } |
| 3423 } | 3422 } |
| OLD | NEW |