Chromium Code Reviews| 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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1143 /// A function declares parameters and has a body. | 1143 /// A function declares parameters and has a body. |
| 1144 /// | 1144 /// |
| 1145 /// This may occur in a procedure, constructor, function expression, or local | 1145 /// This may occur in a procedure, constructor, function expression, or local |
| 1146 /// function declaration. | 1146 /// function declaration. |
| 1147 class FunctionNode extends TreeNode { | 1147 class FunctionNode extends TreeNode { |
| 1148 /// End offset in the source file it comes from. Valid values are from 0 and | 1148 /// End offset in the source file it comes from. Valid values are from 0 and |
| 1149 /// up, or -1 ([TreeNode.noOffset]) if the file end offset is not available | 1149 /// up, or -1 ([TreeNode.noOffset]) if the file end offset is not available |
| 1150 /// (this is the default if none is specifically set). | 1150 /// (this is the default if none is specifically set). |
| 1151 int fileEndOffset = TreeNode.noOffset; | 1151 int fileEndOffset = TreeNode.noOffset; |
| 1152 | 1152 |
| 1153 /// Current async marker for the function. | |
| 1153 AsyncMarker asyncMarker; | 1154 AsyncMarker asyncMarker; |
| 1154 bool debuggable = true; | 1155 |
| 1156 /// Original async marker for the function. | |
| 1157 /// | |
| 1158 /// In source code, a function can for instance be marked as async. | |
|
Kevin Millikin (Google)
2017/02/22 07:59:59
I wouldn't discuss all these imperative details (s
jensj
2017/02/22 10:36:45
Done.
| |
| 1159 /// This will make the async marker be [Async]. A kernel transformation can | |
| 1160 /// however transform this code at mark it as [Sync]. Such a transformation | |
| 1161 /// should update this field to indicate the original async status. | |
| 1162 /// This way, for instance, the VM, can still behave slightly different | |
| 1163 /// (e.g. make stacktraces more readable). | |
| 1164 AsyncMarker originalAsyncMarker; | |
| 1155 List<TypeParameter> typeParameters; | 1165 List<TypeParameter> typeParameters; |
| 1156 int requiredParameterCount; | 1166 int requiredParameterCount; |
| 1157 List<VariableDeclaration> positionalParameters; | 1167 List<VariableDeclaration> positionalParameters; |
| 1158 List<VariableDeclaration> namedParameters; | 1168 List<VariableDeclaration> namedParameters; |
| 1159 InferredValue inferredReturnValue; // May be null. | 1169 InferredValue inferredReturnValue; // May be null. |
| 1160 DartType returnType; // Not null. | 1170 DartType returnType; // Not null. |
| 1161 Statement body; | 1171 Statement body; |
| 1162 | 1172 |
| 1163 FunctionNode(this.body, | 1173 FunctionNode(this.body, |
| 1164 {List<TypeParameter> typeParameters, | 1174 {List<TypeParameter> typeParameters, |
| 1165 List<VariableDeclaration> positionalParameters, | 1175 List<VariableDeclaration> positionalParameters, |
| 1166 List<VariableDeclaration> namedParameters, | 1176 List<VariableDeclaration> namedParameters, |
| 1167 int requiredParameterCount, | 1177 int requiredParameterCount, |
| 1168 this.returnType: const DynamicType(), | 1178 this.returnType: const DynamicType(), |
| 1169 this.inferredReturnValue, | 1179 this.inferredReturnValue, |
| 1170 this.asyncMarker: AsyncMarker.Sync}) | 1180 this.asyncMarker: AsyncMarker.Sync, |
| 1181 this.originalAsyncMarker: AsyncMarker.Sync}) | |
| 1171 : this.positionalParameters = | 1182 : this.positionalParameters = |
| 1172 positionalParameters ?? <VariableDeclaration>[], | 1183 positionalParameters ?? <VariableDeclaration>[], |
| 1173 this.requiredParameterCount = | 1184 this.requiredParameterCount = |
| 1174 requiredParameterCount ?? positionalParameters?.length ?? 0, | 1185 requiredParameterCount ?? positionalParameters?.length ?? 0, |
| 1175 this.namedParameters = namedParameters ?? <VariableDeclaration>[], | 1186 this.namedParameters = namedParameters ?? <VariableDeclaration>[], |
| 1176 this.typeParameters = typeParameters ?? <TypeParameter>[] { | 1187 this.typeParameters = typeParameters ?? <TypeParameter>[] { |
| 1177 assert(returnType != null); | 1188 assert(returnType != null); |
| 1178 setParents(this.typeParameters, this); | 1189 setParents(this.typeParameters, this); |
| 1179 setParents(this.positionalParameters, this); | 1190 setParents(this.positionalParameters, this); |
| 1180 setParents(this.namedParameters, this); | 1191 setParents(this.namedParameters, this); |
| (...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3745 } | 3756 } |
| 3746 } | 3757 } |
| 3747 } | 3758 } |
| 3748 | 3759 |
| 3749 class Source { | 3760 class Source { |
| 3750 final List<int> lineStarts; | 3761 final List<int> lineStarts; |
| 3751 final String source; | 3762 final String source; |
| 3752 | 3763 |
| 3753 Source(this.lineStarts, this.source); | 3764 Source(this.lineStarts, this.source); |
| 3754 } | 3765 } |
| OLD | NEW |