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 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2848 vectorExpression = vectorExpression.accept(v); | 2848 vectorExpression = vectorExpression.accept(v); |
2849 vectorExpression?.parent = this; | 2849 vectorExpression?.parent = this; |
2850 } | 2850 } |
2851 } | 2851 } |
2852 | 2852 |
2853 DartType getStaticType(TypeEnvironment types) { | 2853 DartType getStaticType(TypeEnvironment types) { |
2854 return const VectorType(); | 2854 return const VectorType(); |
2855 } | 2855 } |
2856 } | 2856 } |
2857 | 2857 |
2858 /// Expression of the form `MakeClosure(f, c, t)` where `f` is a name of a | |
2859 /// closed top-level function, `c` is a Vector representing closure context, and | |
2860 /// `t` is the type of the resulting closure. | |
2861 class ClosureCreation extends Expression { | |
2862 Reference topLevelFunctionReference; | |
asgerf
2017/03/31 12:08:43
Great!
To be consistent with the other AST nodes:
Dmitry Stefantsov
2017/03/31 12:40:18
Good idea! Obviously, I didn't payed attention to
| |
2863 Expression contextVector; | |
2864 FunctionType functionType; | |
2865 | |
2866 ClosureCreation( | |
2867 this.topLevelFunctionReference, this.contextVector, this.functionType) { | |
2868 contextVector?.parent = this; | |
2869 } | |
2870 | |
2871 accept(ExpressionVisitor v) => v.visitClosureCreation(this); | |
2872 accept1(ExpressionVisitor1 v, arg) => v.visitClosureCreation(this, arg); | |
2873 | |
2874 visitChildren(Visitor v) { | |
2875 contextVector?.accept(v); | |
2876 } | |
2877 | |
2878 transformChildren(Transformer v) { | |
2879 if (contextVector != null) { | |
2880 contextVector = contextVector.accept(v); | |
2881 contextVector?.parent = this; | |
2882 } | |
2883 } | |
2884 | |
2885 DartType getStaticType(TypeEnvironment types) { | |
2886 return functionType; | |
2887 } | |
2888 } | |
2889 | |
2858 // ------------------------------------------------------------------------ | 2890 // ------------------------------------------------------------------------ |
2859 // STATEMENTS | 2891 // STATEMENTS |
2860 // ------------------------------------------------------------------------ | 2892 // ------------------------------------------------------------------------ |
2861 | 2893 |
2862 abstract class Statement extends TreeNode { | 2894 abstract class Statement extends TreeNode { |
2863 accept(StatementVisitor v); | 2895 accept(StatementVisitor v); |
2864 accept1(StatementVisitor1 v, arg); | 2896 accept1(StatementVisitor1 v, arg); |
2865 } | 2897 } |
2866 | 2898 |
2867 /// A statement with a compile-time error. | 2899 /// A statement with a compile-time error. |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4232 /// library has not been assigned a canonical name yet. | 4264 /// library has not been assigned a canonical name yet. |
4233 /// | 4265 /// |
4234 /// Returns `null` if the library is `null`. | 4266 /// Returns `null` if the library is `null`. |
4235 CanonicalName getCanonicalNameOfLibrary(Library library) { | 4267 CanonicalName getCanonicalNameOfLibrary(Library library) { |
4236 if (library == null) return null; | 4268 if (library == null) return null; |
4237 if (library.canonicalName == null) { | 4269 if (library.canonicalName == null) { |
4238 throw '$library has no canonical name'; | 4270 throw '$library has no canonical name'; |
4239 } | 4271 } |
4240 return library.canonicalName; | 4272 return library.canonicalName; |
4241 } | 4273 } |
OLD | NEW |