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 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. | |
| 2754 class VectorCreation extends Expression { | |
| 2755 final IntLiteral length; | |
|
asgerf
2017/03/22 14:33:22
The kernel AST is mutable, only List fields should
Dmitry Stefantsov
2017/03/23 11:22:43
Thanks! Done.
| |
| 2756 | |
| 2757 VectorCreation(this.length) { | |
| 2758 length?.parent = this; | |
| 2759 } | |
| 2760 | |
| 2761 accept(ExpressionVisitor v) => v.visitVectorCreation(this); | |
| 2762 accept1(ExpressionVisitor1 v, arg) => v.visitVectorCreation(this, arg); | |
| 2763 | |
| 2764 visitChildren(Visitor v) { | |
| 2765 length.accept(v); | |
| 2766 } | |
| 2767 | |
| 2768 transformChildren(Transformer v) { | |
| 2769 length.accept(v); | |
|
asgerf
2017/03/22 14:33:22
transformChildren should replace the children, not
Dmitry Stefantsov
2017/03/23 11:22:43
Of course. Thanks! Fixed.
| |
| 2770 } | |
| 2771 | |
| 2772 DartType getStaticType(TypeEnvironment types) { | |
| 2773 return new VectorType(); | |
| 2774 } | |
| 2775 } | |
| 2776 | |
| 2777 /// Expression of the form `v[i]` where `v` is a vector expression, and `i` is | |
| 2778 /// an integer literal used as an index. | |
| 2779 class VectorGet extends Expression { | |
| 2780 final Expression vectorExpression; | |
| 2781 final IntLiteral index; | |
| 2782 | |
| 2783 VectorGet(this.vectorExpression, this.index) { | |
| 2784 vectorExpression?.parent = this; | |
| 2785 index?.parent = this; | |
| 2786 } | |
| 2787 | |
| 2788 accept(ExpressionVisitor v) => v.visitVectorGet(this); | |
| 2789 accept1(ExpressionVisitor1 v, arg) => v.visitVectorGet(this, arg); | |
| 2790 | |
| 2791 visitChildren(Visitor v) { | |
| 2792 vectorExpression.accept(v); | |
| 2793 index.accept(v); | |
| 2794 } | |
| 2795 | |
| 2796 transformChildren(Transformer v) { | |
| 2797 vectorExpression.accept(v); | |
| 2798 index.accept(v); | |
| 2799 } | |
| 2800 | |
| 2801 DartType getStaticType(TypeEnvironment types) { | |
| 2802 return const DynamicType(); | |
| 2803 } | |
| 2804 } | |
| 2805 | |
| 2806 /// Expressoins of the form `v[i] = x` where `v` is a vector expression, `i` is | |
| 2807 /// an integer literal used as an index, and `x` is an arbitrary expression. | |
| 2808 class VectorSet extends Expression { | |
| 2809 final Expression vectorExpression; | |
| 2810 final IntLiteral index; | |
| 2811 Expression value; | |
| 2812 | |
| 2813 VectorSet(this.vectorExpression, this.index, this.value) { | |
| 2814 vectorExpression?.parent = this; | |
| 2815 index?.parent = this; | |
| 2816 value?.parent = this; | |
| 2817 } | |
| 2818 | |
| 2819 accept(ExpressionVisitor v) => v.visitVectorSet(this); | |
| 2820 accept1(ExpressionVisitor1 v, arg) => v.visitVectorSet(this, arg); | |
| 2821 | |
| 2822 visitChildren(Visitor v) { | |
| 2823 vectorExpression.accept(v); | |
| 2824 index.accept(v); | |
| 2825 value.accept(v); | |
| 2826 } | |
| 2827 | |
| 2828 transformChildren(Transformer v) { | |
| 2829 vectorExpression.accept(v); | |
| 2830 index.accept(v); | |
| 2831 value.accept(v); | |
| 2832 } | |
| 2833 | |
| 2834 DartType getStaticType(TypeEnvironment types) { | |
| 2835 return value.getStaticType(types); | |
| 2836 } | |
| 2837 } | |
| 2838 | |
| 2839 /// Expression of the form `CopyVector(v)` where `v` is a vector expressoin. | |
| 2840 class VectorCopy extends Expression { | |
| 2841 final Expression vectorExpression; | |
| 2842 | |
| 2843 VectorCopy(this.vectorExpression) { | |
| 2844 vectorExpression?.parent = this; | |
| 2845 } | |
| 2846 | |
| 2847 accept(ExpressionVisitor v) => v.visitVectorCopy(this); | |
| 2848 accept1(ExpressionVisitor1 v, arg) => v.visitVectorCopy(this, arg); | |
| 2849 | |
| 2850 visitChildren(Visitor v) { | |
| 2851 vectorExpression.accept(v); | |
| 2852 } | |
| 2853 | |
| 2854 transformChildren(Transformer v) { | |
| 2855 vectorExpression.accept(v); | |
| 2856 } | |
| 2857 | |
| 2858 DartType getStaticType(TypeEnvironment types) { | |
| 2859 return new 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 { | |
| 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 |