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 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2743 return types.objectType; | 2743 return types.objectType; |
2744 } | 2744 } |
2745 | 2745 |
2746 accept(ExpressionVisitor v) => v.visitCheckLibraryIsLoaded(this); | 2746 accept(ExpressionVisitor v) => v.visitCheckLibraryIsLoaded(this); |
2747 accept1(ExpressionVisitor1 v, arg) => v.visitCheckLibraryIsLoaded(this, arg); | 2747 accept1(ExpressionVisitor1 v, arg) => v.visitCheckLibraryIsLoaded(this, arg); |
2748 | 2748 |
2749 visitChildren(Visitor v) {} | 2749 visitChildren(Visitor v) {} |
2750 transformChildren(Transformer v) {} | 2750 transformChildren(Transformer v) {} |
2751 } | 2751 } |
2752 | 2752 |
2753 /// Expression of the form `MakeVector(N)` where `N` is an integer literal. | |
asgerf
2017/03/23 11:53:50
`N` is no longer an integer literal. It would be m
Kevin Millikin (Google)
2017/03/23 12:01:03
'integer literal' ==> 'integer'.
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
Dmitry Stefantsov
2017/03/27 10:57:08
Yes. It makes sense. I put the detailed comment ne
| |
2754 class VectorCreation extends Expression { | |
2755 int length; | |
2756 | |
2757 VectorCreation(this.length); | |
2758 | |
2759 accept(ExpressionVisitor v) => v.visitVectorCreation(this); | |
2760 accept1(ExpressionVisitor1 v, arg) => v.visitVectorCreation(this, arg); | |
2761 | |
2762 visitChildren(Visitor v) {} | |
2763 | |
2764 transformChildren(Transformer v) {} | |
2765 | |
2766 DartType getStaticType(TypeEnvironment types) { | |
2767 return const VectorType(); | |
2768 } | |
2769 } | |
2770 | |
2771 /// Expression of the form `v[i]` where `v` is a vector expression, and `i` is | |
2772 /// an integer literal used as an index. | |
Kevin Millikin (Google)
2017/03/23 12:01:03
'integer literal' ==> 'integer'.
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
| |
2773 class VectorGet extends Expression { | |
2774 Expression vectorExpression; | |
2775 int index; | |
2776 | |
2777 VectorGet(this.vectorExpression, this.index) { | |
2778 vectorExpression?.parent = this; | |
2779 } | |
2780 | |
2781 accept(ExpressionVisitor v) => v.visitVectorGet(this); | |
2782 accept1(ExpressionVisitor1 v, arg) => v.visitVectorGet(this, arg); | |
2783 | |
2784 visitChildren(Visitor v) { | |
2785 vectorExpression.accept(v); | |
2786 } | |
2787 | |
2788 transformChildren(Transformer v) { | |
2789 if (vectorExpression != null) { | |
2790 vectorExpression = vectorExpression.accept(v); | |
2791 vectorExpression?.parent = this; | |
2792 } | |
2793 } | |
2794 | |
2795 DartType getStaticType(TypeEnvironment types) { | |
2796 return const DynamicType(); | |
2797 } | |
2798 } | |
2799 | |
2800 /// Expressoins of the form `v[i] = x` where `v` is a vector expression, `i` is | |
asgerf
2017/03/23 11:53:50
Expressoins -> Expression
Kevin Millikin (Google)
2017/03/23 12:01:03
'Expressoins' ==> 'Expressions'.
'integer literal'
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
| |
2801 /// an integer literal used as an index, and `x` is an arbitrary expression. | |
2802 class VectorSet extends Expression { | |
2803 Expression vectorExpression; | |
2804 int index; | |
2805 Expression value; | |
2806 | |
2807 VectorSet(this.vectorExpression, this.index, this.value) { | |
2808 vectorExpression?.parent = this; | |
2809 value?.parent = this; | |
2810 } | |
2811 | |
2812 accept(ExpressionVisitor v) => v.visitVectorSet(this); | |
2813 accept1(ExpressionVisitor1 v, arg) => v.visitVectorSet(this, arg); | |
2814 | |
2815 visitChildren(Visitor v) { | |
2816 vectorExpression.accept(v); | |
2817 value.accept(v); | |
2818 } | |
2819 | |
2820 transformChildren(Transformer v) { | |
2821 if (vectorExpression != null) { | |
2822 vectorExpression = vectorExpression.accept(v); | |
2823 vectorExpression?.parent = this; | |
2824 } | |
2825 if (value != null) { | |
2826 value = value.accept(v); | |
2827 value?.parent = this; | |
2828 } | |
2829 } | |
2830 | |
2831 DartType getStaticType(TypeEnvironment types) { | |
2832 return value.getStaticType(types); | |
2833 } | |
2834 } | |
2835 | |
2836 /// Expression of the form `CopyVector(v)` where `v` is a vector expressoin. | |
asgerf
2017/03/23 11:53:50
expressoin -> expression
Kevin Millikin (Google)
2017/03/23 12:01:03
'expressoin' ==> 'expression'.
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
Dmitry Stefantsov
2017/03/27 10:57:08
Done.
| |
2837 class VectorCopy extends Expression { | |
2838 Expression vectorExpression; | |
2839 | |
2840 VectorCopy(this.vectorExpression) { | |
2841 vectorExpression?.parent = this; | |
2842 } | |
2843 | |
2844 accept(ExpressionVisitor v) => v.visitVectorCopy(this); | |
2845 accept1(ExpressionVisitor1 v, arg) => v.visitVectorCopy(this, arg); | |
2846 | |
2847 visitChildren(Visitor v) { | |
2848 vectorExpression.accept(v); | |
2849 } | |
2850 | |
2851 transformChildren(Transformer v) { | |
2852 if (vectorExpression != null) { | |
2853 vectorExpression = vectorExpression.accept(v); | |
2854 vectorExpression?.parent = this; | |
2855 } | |
2856 } | |
2857 | |
2858 DartType getStaticType(TypeEnvironment types) { | |
2859 return const VectorType(); | |
2860 } | |
2861 } | |
2862 | |
2753 // ------------------------------------------------------------------------ | 2863 // ------------------------------------------------------------------------ |
2754 // STATEMENTS | 2864 // STATEMENTS |
2755 // ------------------------------------------------------------------------ | 2865 // ------------------------------------------------------------------------ |
2756 | 2866 |
2757 abstract class Statement extends TreeNode { | 2867 abstract class Statement extends TreeNode { |
2758 accept(StatementVisitor v); | 2868 accept(StatementVisitor v); |
2759 accept1(StatementVisitor1 v, arg); | 2869 accept1(StatementVisitor1 v, arg); |
2760 } | 2870 } |
2761 | 2871 |
2762 /// A statement with a compile-time error. | 2872 /// A statement with a compile-time error. |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3645 | 3755 |
3646 int get hashCode { | 3756 int get hashCode { |
3647 int hash = 0x3fffffff & className.hashCode; | 3757 int hash = 0x3fffffff & className.hashCode; |
3648 for (int i = 0; i < typeArguments.length; ++i) { | 3758 for (int i = 0; i < typeArguments.length; ++i) { |
3649 hash = 0x3fffffff & (hash * 31 + (hash ^ typeArguments[i].hashCode)); | 3759 hash = 0x3fffffff & (hash * 31 + (hash ^ typeArguments[i].hashCode)); |
3650 } | 3760 } |
3651 return hash; | 3761 return hash; |
3652 } | 3762 } |
3653 } | 3763 } |
3654 | 3764 |
3765 class VectorType extends DartType { | |
asgerf
2017/03/23 11:53:50
Please check all existing DartTypeVisitors and ove
Dmitry Stefantsov
2017/03/27 10:57:08
Thanks! Done.
| |
3766 const VectorType(); | |
3767 | |
3768 accept(DartTypeVisitor v) => v.visitVectorType(this); | |
3769 visitChildren(Visitor v) {} | |
3770 } | |
3771 | |
3655 /// A possibly generic function type. | 3772 /// A possibly generic function type. |
3656 class FunctionType extends DartType { | 3773 class FunctionType extends DartType { |
3657 final List<TypeParameter> typeParameters; | 3774 final List<TypeParameter> typeParameters; |
3658 final int requiredParameterCount; | 3775 final int requiredParameterCount; |
3659 final List<DartType> positionalParameters; | 3776 final List<DartType> positionalParameters; |
3660 final List<NamedType> namedParameters; // Must be sorted. | 3777 final List<NamedType> namedParameters; // Must be sorted. |
3661 final DartType returnType; | 3778 final DartType returnType; |
3662 int _hashCode; | 3779 int _hashCode; |
3663 | 3780 |
3664 FunctionType(List<DartType> positionalParameters, this.returnType, | 3781 FunctionType(List<DartType> positionalParameters, this.returnType, |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4100 /// library has not been assigned a canonical name yet. | 4217 /// library has not been assigned a canonical name yet. |
4101 /// | 4218 /// |
4102 /// Returns `null` if the library is `null`. | 4219 /// Returns `null` if the library is `null`. |
4103 CanonicalName getCanonicalNameOfLibrary(Library library) { | 4220 CanonicalName getCanonicalNameOfLibrary(Library library) { |
4104 if (library == null) return null; | 4221 if (library == null) return null; |
4105 if (library.canonicalName == null) { | 4222 if (library.canonicalName == null) { |
4106 throw '$library has no canonical name'; | 4223 throw '$library has no canonical name'; |
4107 } | 4224 } |
4108 return library.canonicalName; | 4225 return library.canonicalName; |
4109 } | 4226 } |
OLD | NEW |