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

Side by Side Diff: frog/leg/elements/elements.dart

Issue 9632018: Switch-implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing handling of default in unparser. Created 8 years, 9 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
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | frog/leg/lib/js_helper.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 isBreakTarget = true; 840 isBreakTarget = true;
841 target.isBreakTarget = true; 841 target.isBreakTarget = true;
842 } 842 }
843 void setContinueTarget() { 843 void setContinueTarget() {
844 isContinueTarget = true; 844 isContinueTarget = true;
845 target.isContinueTarget = true; 845 target.isContinueTarget = true;
846 } 846 }
847 847
848 bool get isTarget() => isBreakTarget || isContinueTarget; 848 bool get isTarget() => isBreakTarget || isContinueTarget;
849 Node parseNode(DiagnosticListener l) => label; 849 Node parseNode(DiagnosticListener l) => label;
850
851 Token position() => label.token;
852 String toString() => "${labelName}:";
850 } 853 }
851 854
852 // Represents a reference to a statement, either a label or the 855 // Represents a reference to a statement, either a label or the
853 // default target of a break or continue. 856 // default target of a break or continue.
854 class StatementElement extends Element { 857 class StatementElement extends Element {
855 final Statement statement; 858 final Statement statement;
859 final int nestingLevel;
856 Link<LabelElement> labels = const EmptyLink<LabelElement>(); 860 Link<LabelElement> labels = const EmptyLink<LabelElement>();
857 bool isBreakTarget = false; 861 bool isBreakTarget = false;
858 bool isContinueTarget = false; 862 bool isContinueTarget = false;
859 863
860 StatementElement(this.statement, Element enclosingElement) 864 StatementElement(this.statement, this.nestingLevel, Element enclosingElement)
861 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement); 865 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement);
862 bool get isTarget() => isBreakTarget || isContinueTarget; 866 bool get isTarget() => isBreakTarget || isContinueTarget;
863 867
864 LabelElement addLabel(Identifier label, String labelName) { 868 LabelElement addLabel(Identifier label, String labelName) {
865 LabelElement result = new LabelElement(label, labelName, this, 869 LabelElement result = new LabelElement(label, labelName, this,
866 enclosingElement); 870 enclosingElement);
867 labels = labels.prepend(result); 871 labels = labels.prepend(result);
868 return result; 872 return result;
869 } 873 }
870 874
871 Node parseNode(DiagnosticListener l) => statement; 875 Node parseNode(DiagnosticListener l) => statement;
876
877 String implicitLabel() =>
878 (statement is SwitchStatement) ? '\$$nestingLevel' : null;
ahe 2012/03/13 10:17:15 I think this belongs in the SSA builder.
Lasse Reichstein Nielsen 2012/03/13 12:09:38 I'll move it somewhere else.
879
880 Token position() => statement.getBeginToken();
881 String toString() => statement.toString();
872 } 882 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | frog/leg/lib/js_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698