| 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 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2993 | 2994 |
| 2994 /// Declaration of a local variable. | 2995 /// Declaration of a local variable. |
| 2995 /// | 2996 /// |
| 2996 /// This may occur as a statement, but is also used in several non-statement | 2997 /// This may occur as a statement, but is also used in several non-statement |
| 2997 /// contexts, such as in [ForStatement], [Catch], and [FunctionNode]. | 2998 /// contexts, such as in [ForStatement], [Catch], and [FunctionNode]. |
| 2998 /// | 2999 /// |
| 2999 /// When this occurs as a statement, it must be a direct child of a [Block]. | 3000 /// When this occurs as a statement, it must be a direct child of a [Block]. |
| 3000 // | 3001 // |
| 3001 // DESIGN TODO: Should we remove the 'final' modifier from variables? | 3002 // DESIGN TODO: Should we remove the 'final' modifier from variables? |
| 3002 class VariableDeclaration extends Statement { | 3003 class VariableDeclaration extends Statement { |
| 3004 /// Offset of the equals sign in the source file it comes from. |
| 3005 /// |
| 3006 /// Valid values are from 0 and up, or -1 ([TreeNode.noOffset]) |
| 3007 /// if the equals sign offset is not available (e.g. if not initialized) |
| 3008 /// (this is the default if none is specifically set). |
| 3009 int fileEqualsOffset = TreeNode.noOffset; |
| 3010 |
| 3003 /// For named parameters, this is the name of the parameter. No two named | 3011 /// For named parameters, this is the name of the parameter. No two named |
| 3004 /// parameters (in the same parameter list) can have the same name. | 3012 /// parameters (in the same parameter list) can have the same name. |
| 3005 /// | 3013 /// |
| 3006 /// In all other cases, the name is cosmetic, may be empty or null, | 3014 /// In all other cases, the name is cosmetic, may be empty or null, |
| 3007 /// and is not necessarily unique. | 3015 /// and is not necessarily unique. |
| 3008 String name; | 3016 String name; |
| 3009 int flags = 0; | 3017 int flags = 0; |
| 3010 DartType type; // Not null, defaults to dynamic. | 3018 DartType type; // Not null, defaults to dynamic. |
| 3011 InferredValue inferredValue; // May be null. | 3019 InferredValue inferredValue; // May be null. |
| 3012 | 3020 |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3668 } | 3676 } |
| 3669 } | 3677 } |
| 3670 } | 3678 } |
| 3671 | 3679 |
| 3672 class Source { | 3680 class Source { |
| 3673 final List<int> lineStarts; | 3681 final List<int> lineStarts; |
| 3674 final String source; | 3682 final String source; |
| 3675 | 3683 |
| 3676 Source(this.lineStarts, this.source); | 3684 Source(this.lineStarts, this.source); |
| 3677 } | 3685 } |
| OLD | NEW |