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: lib/compiler/implementation/ssa/builder.dart

Issue 10917208: Change interfaces to abstract classes in dart2js compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Represents a single break/continue instruction. 702 // Represents a single break/continue instruction.
703 class JumpHandlerEntry { 703 class JumpHandlerEntry {
704 final HJump jumpInstruction; 704 final HJump jumpInstruction;
705 final LocalsHandler locals; 705 final LocalsHandler locals;
706 bool isBreak() => jumpInstruction is HBreak; 706 bool isBreak() => jumpInstruction is HBreak;
707 bool isContinue() => jumpInstruction is HContinue; 707 bool isContinue() => jumpInstruction is HContinue;
708 JumpHandlerEntry(this.jumpInstruction, this.locals); 708 JumpHandlerEntry(this.jumpInstruction, this.locals);
709 } 709 }
710 710
711 711
712 interface JumpHandler default JumpHandlerImpl { 712 abstract class JumpHandler {
713 JumpHandler(SsaBuilder builder, TargetElement target); 713 factory JumpHandler(SsaBuilder builder, TargetElement target) {
ngeoffray 2012/09/12 09:30:56 You know that this won't be valid after we switch
Lasse Reichstein Nielsen 2012/09/12 10:17:46 I think it'll still be valid. We still need normal
714 return new TargetJumpHandler(builder, target);
715 }
714 void generateBreak([LabelElement label]); 716 void generateBreak([LabelElement label]);
715 void generateContinue([LabelElement label]); 717 void generateContinue([LabelElement label]);
716 void forEachBreak(void action(HBreak instruction, LocalsHandler locals)); 718 void forEachBreak(void action(HBreak instruction, LocalsHandler locals));
717 void forEachContinue(void action(HContinue instruction, 719 void forEachContinue(void action(HContinue instruction,
718 LocalsHandler locals)); 720 LocalsHandler locals));
719 void close(); 721 void close();
720 final TargetElement target; 722 final TargetElement target;
721 List<LabelElement> labels(); 723 List<LabelElement> labels();
722 } 724 }
723 725
724 // Insert break handler used to avoid null checks when a target isn't 726 // Insert break handler used to avoid null checks when a target isn't
725 // used as the target of a break, and therefore doesn't need a break 727 // used as the target of a break, and therefore doesn't need a break
726 // handler associated with it. 728 // handler associated with it.
727 class NullJumpHandler implements JumpHandler { 729 class NullJumpHandler implements JumpHandler {
728 final Compiler compiler; 730 final Compiler compiler;
731
729 NullJumpHandler(this.compiler); 732 NullJumpHandler(this.compiler);
730 733
731 void generateBreak([LabelElement label]) { 734 void generateBreak([LabelElement label]) {
732 // TODO(lrn): Need a compiler object and a location. Since label
733 // is optional, it may be null so we also need a position.
734 compiler.internalError('generateBreak should not be called'); 735 compiler.internalError('generateBreak should not be called');
735 } 736 }
736 737
737 void generateContinue([LabelElement label]) { 738 void generateContinue([LabelElement label]) {
738 // TODO(lrn): Need a compiler object and a location. Since label
739 // is optional, it may be null so we also need a position.
740 compiler.internalError('generateContinue should not be called'); 739 compiler.internalError('generateContinue should not be called');
741 } 740 }
742 741
743 void forEachBreak(Function ignored) { } 742 void forEachBreak(Function ignored) { }
744 void forEachContinue(Function ignored) { } 743 void forEachContinue(Function ignored) { }
745 void close() { } 744 void close() { }
746 final TargetElement target = null; 745
747 List<LabelElement> labels() => const <LabelElement>[]; 746 List<LabelElement> labels() => const <LabelElement>[];
747 TargetElement get target => null;
748 } 748 }
749 749
750 // Records breaks until a target block is available. 750 // Records breaks until a target block is available.
751 // Breaks are always forward jumps. 751 // Breaks are always forward jumps.
752 // Continues in loops are implemented as breaks of the body. 752 // Continues in loops are implemented as breaks of the body.
753 // Continues in switches is currently not handled. 753 // Continues in switches is currently not handled.
754 class JumpHandlerImpl implements JumpHandler { 754 class TargetJumpHandler implements JumpHandler {
755 final SsaBuilder builder; 755 final SsaBuilder builder;
756 final TargetElement target; 756 final TargetElement target;
757 final List<JumpHandlerEntry> jumps; 757 final List<JumpHandlerEntry> jumps;
758 758
759 JumpHandlerImpl(SsaBuilder builder, this.target) 759 TargetJumpHandler(SsaBuilder builder, this.target)
760 : this.builder = builder, 760 : this.builder = builder,
761 jumps = <JumpHandlerEntry>[] { 761 jumps = <JumpHandlerEntry>[] {
762 assert(builder.jumpTargets[target] === null); 762 assert(builder.jumpTargets[target] === null);
763 builder.jumpTargets[target] = this; 763 builder.jumpTargets[target] = this;
764 } 764 }
765 765
766 void generateBreak([LabelElement label]) { 766 void generateBreak([LabelElement label]) {
767 HInstruction breakInstruction; 767 HInstruction breakInstruction;
768 if (label === null) { 768 if (label === null) {
769 breakInstruction = new HBreak(target); 769 breakInstruction = new HBreak(target);
(...skipping 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
4140 new HSubGraphBlockInformation(elseBranch.graph)); 4140 new HSubGraphBlockInformation(elseBranch.graph));
4141 4141
4142 HBasicBlock conditionStartBlock = conditionBranch.block; 4142 HBasicBlock conditionStartBlock = conditionBranch.block;
4143 conditionStartBlock.setBlockFlow(info, joinBlock); 4143 conditionStartBlock.setBlockFlow(info, joinBlock);
4144 SubGraph conditionGraph = conditionBranch.graph; 4144 SubGraph conditionGraph = conditionBranch.graph;
4145 HIf branch = conditionGraph.end.last; 4145 HIf branch = conditionGraph.end.last;
4146 assert(branch is HIf); 4146 assert(branch is HIf);
4147 branch.blockInformation = conditionStartBlock.blockFlow; 4147 branch.blockInformation = conditionStartBlock.blockFlow;
4148 } 4148 }
4149 } 4149 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/scanner.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698