Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: runtime/vm/kernel.h

Issue 2792333002: Add Kernel AST nodes for Vector and Closure primitives in VM (Closed)
Patch Set: Remove PositionScopes and static_cast for UInts Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef RUNTIME_VM_KERNEL_H_ 5 #ifndef RUNTIME_VM_KERNEL_H_
6 #define RUNTIME_VM_KERNEL_H_ 6 #define RUNTIME_VM_KERNEL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/growable_array.h" 12 #include "vm/growable_array.h"
13 #include "vm/token_position.h" 13 #include "vm/token_position.h"
14 14
15 15
16 #define KERNEL_NODES_DO(M) \ 16 #define KERNEL_NODES_DO(M) \
17 M(Name) \ 17 M(Name) \
18 M(DartType) \ 18 M(DartType) \
19 M(InvalidType) \ 19 M(InvalidType) \
20 M(DynamicType) \ 20 M(DynamicType) \
21 M(VoidType) \ 21 M(VoidType) \
22 M(InterfaceType) \ 22 M(InterfaceType) \
23 M(FunctionType) \ 23 M(FunctionType) \
24 M(TypeParameterType) 24 M(TypeParameterType) \
25 M(VectorType)
25 26
26 #define KERNEL_TREE_NODES_DO(M) \ 27 #define KERNEL_TREE_NODES_DO(M) \
27 M(Library) \ 28 M(Library) \
28 M(Class) \ 29 M(Class) \
29 M(NormalClass) \ 30 M(NormalClass) \
30 M(MixinClass) \ 31 M(MixinClass) \
31 M(Member) \ 32 M(Member) \
32 M(Field) \ 33 M(Field) \
33 M(Constructor) \ 34 M(Constructor) \
34 M(Procedure) \ 35 M(Procedure) \
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 M(TypeLiteral) \ 73 M(TypeLiteral) \
73 M(ThisExpression) \ 74 M(ThisExpression) \
74 M(Rethrow) \ 75 M(Rethrow) \
75 M(Throw) \ 76 M(Throw) \
76 M(ListLiteral) \ 77 M(ListLiteral) \
77 M(MapLiteral) \ 78 M(MapLiteral) \
78 M(MapEntry) \ 79 M(MapEntry) \
79 M(AwaitExpression) \ 80 M(AwaitExpression) \
80 M(FunctionExpression) \ 81 M(FunctionExpression) \
81 M(Let) \ 82 M(Let) \
83 M(VectorCreation) \
84 M(VectorGet) \
85 M(VectorSet) \
86 M(VectorCopy) \
87 M(ClosureCreation) \
82 M(Statement) \ 88 M(Statement) \
83 M(InvalidStatement) \ 89 M(InvalidStatement) \
84 M(ExpressionStatement) \ 90 M(ExpressionStatement) \
85 M(Block) \ 91 M(Block) \
86 M(EmptyStatement) \ 92 M(EmptyStatement) \
87 M(AssertStatement) \ 93 M(AssertStatement) \
88 M(LabeledStatement) \ 94 M(LabeledStatement) \
89 M(BreakStatement) \ 95 M(BreakStatement) \
90 M(WhileStatement) \ 96 M(WhileStatement) \
91 M(DoStatement) \ 97 M(DoStatement) \
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 1934
1929 Child<VariableDeclaration> variable_; 1935 Child<VariableDeclaration> variable_;
1930 Child<Expression> body_; 1936 Child<Expression> body_;
1931 TokenPosition position_; 1937 TokenPosition position_;
1932 TokenPosition end_position_; 1938 TokenPosition end_position_;
1933 1939
1934 DISALLOW_COPY_AND_ASSIGN(Let); 1940 DISALLOW_COPY_AND_ASSIGN(Let);
1935 }; 1941 };
1936 1942
1937 1943
1944 class VectorCreation : public Expression {
1945 public:
1946 static VectorCreation* ReadFrom(Reader* reader);
1947
1948 virtual ~VectorCreation();
1949
1950 DEFINE_CASTING_OPERATIONS(VectorCreation);
1951
1952 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1953 virtual void VisitChildren(Visitor* visitor);
1954
1955 intptr_t value() { return value_; }
1956
1957 private:
1958 VectorCreation() {}
1959
1960 intptr_t value_;
1961
1962 DISALLOW_COPY_AND_ASSIGN(VectorCreation);
1963 };
1964
1965
1966 class VectorGet : public Expression {
1967 public:
1968 static VectorGet* ReadFrom(Reader* reader);
1969
1970 virtual ~VectorGet();
1971
1972 DEFINE_CASTING_OPERATIONS(VectorGet);
1973
1974 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1975 virtual void VisitChildren(Visitor* visitor);
1976
1977 Expression* vector_expression() { return vector_expression_; }
1978 intptr_t index() { return index_; }
1979
1980 private:
1981 VectorGet() {}
1982
1983 Child<Expression> vector_expression_;
1984 intptr_t index_;
1985
1986 DISALLOW_COPY_AND_ASSIGN(VectorGet);
1987 };
1988
1989
1990 class VectorSet : public Expression {
1991 public:
1992 static VectorSet* ReadFrom(Reader* reader);
1993
1994 virtual ~VectorSet();
1995
1996 DEFINE_CASTING_OPERATIONS(VectorSet);
1997
1998 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1999 virtual void VisitChildren(Visitor* visitor);
2000
2001 Expression* vector_expression() { return vector_expression_; }
2002 intptr_t index() { return index_; }
2003 Expression* value() { return value_; }
2004
2005 private:
2006 VectorSet() {}
2007
2008 Child<Expression> vector_expression_;
2009 intptr_t index_;
2010 Child<Expression> value_;
2011
2012 DISALLOW_COPY_AND_ASSIGN(VectorSet);
2013 };
2014
2015
2016 class VectorCopy : public Expression {
2017 public:
2018 static VectorCopy* ReadFrom(Reader* reader);
2019
2020 virtual ~VectorCopy();
2021
2022 DEFINE_CASTING_OPERATIONS(VectorCopy);
2023
2024 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
2025 virtual void VisitChildren(Visitor* visitor);
2026
2027 Expression* vector_expression() { return vector_expression_; }
2028
2029 private:
2030 VectorCopy() {}
2031
2032 Child<Expression> vector_expression_;
2033
2034 DISALLOW_COPY_AND_ASSIGN(VectorCopy);
2035 };
2036
2037
2038 class ClosureCreation : public Expression {
2039 public:
2040 static ClosureCreation* ReadFrom(Reader* reader);
2041
2042 virtual ~ClosureCreation();
2043
2044 DEFINE_CASTING_OPERATIONS(ClosureCreation);
2045
2046 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
2047 virtual void VisitChildren(Visitor* visitor);
2048
2049 CanonicalName* top_level_function() { return top_level_function_reference_; }
2050 Expression* context_vector() { return context_vector_; }
2051 FunctionType* function_type() { return function_type_; }
2052
2053 private:
2054 ClosureCreation() {}
2055
2056 Ref<CanonicalName> top_level_function_reference_; // Procedure.
2057 Child<Expression> context_vector_;
2058 Child<FunctionType> function_type_;
2059
2060 DISALLOW_COPY_AND_ASSIGN(ClosureCreation);
2061 };
2062
2063
1938 class Statement : public TreeNode { 2064 class Statement : public TreeNode {
1939 public: 2065 public:
1940 static Statement* ReadFrom(Reader* reader); 2066 static Statement* ReadFrom(Reader* reader);
1941 2067
1942 virtual ~Statement(); 2068 virtual ~Statement();
1943 2069
1944 DEFINE_CASTING_OPERATIONS(Statement); 2070 DEFINE_CASTING_OPERATIONS(Statement);
1945 2071
1946 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2072 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
1947 virtual void AcceptStatementVisitor(StatementVisitor* visitor) = 0; 2073 virtual void AcceptStatementVisitor(StatementVisitor* visitor) = 0;
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 2829
2704 private: 2830 private:
2705 TypeParameterType() {} 2831 TypeParameterType() {}
2706 2832
2707 Ref<TypeParameter> parameter_; 2833 Ref<TypeParameter> parameter_;
2708 2834
2709 DISALLOW_COPY_AND_ASSIGN(TypeParameterType); 2835 DISALLOW_COPY_AND_ASSIGN(TypeParameterType);
2710 }; 2836 };
2711 2837
2712 2838
2839 class VectorType : public DartType {
2840 public:
2841 static VectorType* ReadFrom(Reader* reader);
2842
2843 virtual ~VectorType();
2844
2845 DEFINE_CASTING_OPERATIONS(VectorType);
2846
2847 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
2848 virtual void VisitChildren(Visitor* visitor);
2849
2850 private:
2851 VectorType() {}
2852
2853 DISALLOW_COPY_AND_ASSIGN(VectorType);
2854 };
2855
2856
2713 class TypeParameter : public TreeNode { 2857 class TypeParameter : public TreeNode {
2714 public: 2858 public:
2715 TypeParameter* ReadFrom(Reader* reader); 2859 TypeParameter* ReadFrom(Reader* reader);
2716 2860
2717 virtual ~TypeParameter(); 2861 virtual ~TypeParameter();
2718 2862
2719 DEFINE_CASTING_OPERATIONS(TypeParameter); 2863 DEFINE_CASTING_OPERATIONS(TypeParameter);
2720 2864
2721 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2865 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
2722 virtual void VisitChildren(Visitor* visitor); 2866 virtual void VisitChildren(Visitor* visitor);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 virtual void VisitDoubleLiteral(DoubleLiteral* node) { 3020 virtual void VisitDoubleLiteral(DoubleLiteral* node) {
2877 VisitDefaultBasicLiteral(node); 3021 VisitDefaultBasicLiteral(node);
2878 } 3022 }
2879 virtual void VisitBoolLiteral(BoolLiteral* node) { 3023 virtual void VisitBoolLiteral(BoolLiteral* node) {
2880 VisitDefaultBasicLiteral(node); 3024 VisitDefaultBasicLiteral(node);
2881 } 3025 }
2882 virtual void VisitNullLiteral(NullLiteral* node) { 3026 virtual void VisitNullLiteral(NullLiteral* node) {
2883 VisitDefaultBasicLiteral(node); 3027 VisitDefaultBasicLiteral(node);
2884 } 3028 }
2885 virtual void VisitLet(Let* node) { VisitDefaultExpression(node); } 3029 virtual void VisitLet(Let* node) { VisitDefaultExpression(node); }
3030 virtual void VisitVectorCreation(VectorCreation* node) {
3031 VisitDefaultExpression(node);
3032 }
3033 virtual void VisitVectorGet(VectorGet* node) { VisitDefaultExpression(node); }
3034 virtual void VisitVectorSet(VectorSet* node) { VisitDefaultExpression(node); }
3035 virtual void VisitVectorCopy(VectorCopy* node) {
3036 VisitDefaultExpression(node);
3037 }
3038 virtual void VisitClosureCreation(ClosureCreation* node) {
3039 VisitDefaultExpression(node);
3040 }
2886 }; 3041 };
2887 3042
2888 3043
2889 class StatementVisitor { 3044 class StatementVisitor {
2890 public: 3045 public:
2891 virtual ~StatementVisitor() {} 3046 virtual ~StatementVisitor() {}
2892 3047
2893 virtual void VisitDefaultStatement(Statement* node) = 0; 3048 virtual void VisitDefaultStatement(Statement* node) = 0;
2894 virtual void VisitInvalidStatement(InvalidStatement* node) { 3049 virtual void VisitInvalidStatement(InvalidStatement* node) {
2895 VisitDefaultStatement(node); 3050 VisitDefaultStatement(node);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 virtual void VisitVoidType(VoidType* node) { VisitDefaultDartType(node); } 3163 virtual void VisitVoidType(VoidType* node) { VisitDefaultDartType(node); }
3009 virtual void VisitInterfaceType(InterfaceType* node) { 3164 virtual void VisitInterfaceType(InterfaceType* node) {
3010 VisitDefaultDartType(node); 3165 VisitDefaultDartType(node);
3011 } 3166 }
3012 virtual void VisitFunctionType(FunctionType* node) { 3167 virtual void VisitFunctionType(FunctionType* node) {
3013 VisitDefaultDartType(node); 3168 VisitDefaultDartType(node);
3014 } 3169 }
3015 virtual void VisitTypeParameterType(TypeParameterType* node) { 3170 virtual void VisitTypeParameterType(TypeParameterType* node) {
3016 VisitDefaultDartType(node); 3171 VisitDefaultDartType(node);
3017 } 3172 }
3173 virtual void VisitVectorType(VectorType* node) { VisitDefaultDartType(node); }
3018 }; 3174 };
3019 3175
3020 3176
3021 class TreeVisitor : public ExpressionVisitor, 3177 class TreeVisitor : public ExpressionVisitor,
3022 public StatementVisitor, 3178 public StatementVisitor,
3023 public MemberVisitor, 3179 public MemberVisitor,
3024 public ClassVisitor, 3180 public ClassVisitor,
3025 public InitializerVisitor { 3181 public InitializerVisitor {
3026 public: 3182 public:
3027 virtual ~TreeVisitor() {} 3183 virtual ~TreeVisitor() {}
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 3309
3154 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, 3310 ParsedFunction* ParseStaticFieldInitializer(Zone* zone,
3155 const dart::Field& field); 3311 const dart::Field& field);
3156 3312
3157 } // namespace kernel 3313 } // namespace kernel
3158 3314
3159 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 3315 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
3160 intptr_t buffer_length); 3316 intptr_t buffer_length);
3161 3317
3162 3318
3163
3164 } // namespace dart 3319 } // namespace dart
3165 3320
3166 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3321 #endif // !defined(DART_PRECOMPILED_RUNTIME)
3167 #endif // RUNTIME_VM_KERNEL_H_ 3322 #endif // RUNTIME_VM_KERNEL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698