| 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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
| 6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
| 7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
| 8 /// | 8 /// |
| 9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
| 10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 /// A mutable AST node with a parent pointer. | 85 /// A mutable AST node with a parent pointer. |
| 86 /// | 86 /// |
| 87 /// This is anything other than [Name] and [DartType] nodes. | 87 /// This is anything other than [Name] and [DartType] nodes. |
| 88 abstract class TreeNode extends Node { | 88 abstract class TreeNode extends Node { |
| 89 static int _hashCounter = 0; | 89 static int _hashCounter = 0; |
| 90 final int hashCode = _hashCounter = (_hashCounter + 1) & 0x3fffffff; | 90 final int hashCode = _hashCounter = (_hashCounter + 1) & 0x3fffffff; |
| 91 static const int noOffset = -1; | 91 static const int noOffset = -1; |
| 92 | 92 |
| 93 TreeNode parent; | 93 TreeNode parent; |
| 94 | 94 |
| 95 /// Offset in the source file it comes from. Valid values are from 0 and up, | 95 /// Offset in the source file it comes from. |
| 96 /// or -1 ([noOffset]) if the file offset is not available | 96 /// |
| 97 /// (this is the default if none is specifically set). | 97 /// Valid values are from 0 and up, or -1 ([noOffset]) if the file offset is |
| 98 /// not available (this is the default if none is specifically set). |
| 98 int fileOffset = noOffset; | 99 int fileOffset = noOffset; |
| 99 | 100 |
| 100 accept(TreeVisitor v); | 101 accept(TreeVisitor v); |
| 101 visitChildren(Visitor v); | 102 visitChildren(Visitor v); |
| 102 transformChildren(Transformer v); | 103 transformChildren(Transformer v); |
| 103 | 104 |
| 104 /// Replaces [child] with [replacement]. | 105 /// Replaces [child] with [replacement]. |
| 105 /// | 106 /// |
| 106 /// The caller is responsible for ensuring that the AST remains a tree. In | 107 /// The caller is responsible for ensuring that the AST remains a tree. In |
| 107 /// particular, [replacement] should be an orphan or be part of an orphaned | 108 /// particular, [replacement] should be an orphan or be part of an orphaned |
| (...skipping 2962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 | 3071 |
| 3071 /// Declaration of a local variable. | 3072 /// Declaration of a local variable. |
| 3072 /// | 3073 /// |
| 3073 /// This may occur as a statement, but is also used in several non-statement | 3074 /// This may occur as a statement, but is also used in several non-statement |
| 3074 /// contexts, such as in [ForStatement], [Catch], and [FunctionNode]. | 3075 /// contexts, such as in [ForStatement], [Catch], and [FunctionNode]. |
| 3075 /// | 3076 /// |
| 3076 /// When this occurs as a statement, it must be a direct child of a [Block]. | 3077 /// When this occurs as a statement, it must be a direct child of a [Block]. |
| 3077 // | 3078 // |
| 3078 // DESIGN TODO: Should we remove the 'final' modifier from variables? | 3079 // DESIGN TODO: Should we remove the 'final' modifier from variables? |
| 3079 class VariableDeclaration extends Statement { | 3080 class VariableDeclaration extends Statement { |
| 3081 /// Offset of the equals sign in the source file it comes from. |
| 3082 /// |
| 3083 /// Valid values are from 0 and up, or -1 ([TreeNode.noOffset]) |
| 3084 /// if the equals sign offset is not available (e.g. if not initialized) |
| 3085 /// (this is the default if none is specifically set). |
| 3086 int fileEqualsOffset = TreeNode.noOffset; |
| 3087 |
| 3080 /// For named parameters, this is the name of the parameter. No two named | 3088 /// For named parameters, this is the name of the parameter. No two named |
| 3081 /// parameters (in the same parameter list) can have the same name. | 3089 /// parameters (in the same parameter list) can have the same name. |
| 3082 /// | 3090 /// |
| 3083 /// In all other cases, the name is cosmetic, may be empty or null, | 3091 /// In all other cases, the name is cosmetic, may be empty or null, |
| 3084 /// and is not necessarily unique. | 3092 /// and is not necessarily unique. |
| 3085 String name; | 3093 String name; |
| 3086 int flags = 0; | 3094 int flags = 0; |
| 3087 DartType type; // Not null, defaults to dynamic. | 3095 DartType type; // Not null, defaults to dynamic. |
| 3088 InferredValue inferredValue; // May be null. | 3096 InferredValue inferredValue; // May be null. |
| 3089 | 3097 |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3745 } | 3753 } |
| 3746 } | 3754 } |
| 3747 } | 3755 } |
| 3748 | 3756 |
| 3749 class Source { | 3757 class Source { |
| 3750 final List<int> lineStarts; | 3758 final List<int> lineStarts; |
| 3751 final String source; | 3759 final String source; |
| 3752 | 3760 |
| 3753 Source(this.lineStarts, this.source); | 3761 Source(this.lineStarts, this.source); |
| 3754 } | 3762 } |
| OLD | NEW |