| 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 #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 Loading... |
| 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; |
| 879 |
| 880 Token position() => statement.getBeginToken(); |
| 881 String toString() => statement.toString(); |
| 872 } | 882 } |
| OLD | NEW |