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

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

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor Created 3 years, 7 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 | « pkg/kernel/test/verify_test.dart ('k') | 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 M(VectorType) \
26 M(TypedefType)
26 27
27 #define KERNEL_TREE_NODES_DO(M) \ 28 #define KERNEL_TREE_NODES_DO(M) \
28 M(Library) \ 29 M(Library) \
30 M(Typedef) \
29 M(Class) \ 31 M(Class) \
30 M(NormalClass) \ 32 M(NormalClass) \
31 M(MixinClass) \ 33 M(MixinClass) \
32 M(Member) \ 34 M(Member) \
33 M(Field) \ 35 M(Field) \
34 M(Constructor) \ 36 M(Constructor) \
35 M(Procedure) \ 37 M(Procedure) \
36 M(Initializer) \ 38 M(Initializer) \
37 M(InvalidInitializer) \ 39 M(InvalidInitializer) \
38 M(FieldInitializer) \ 40 M(FieldInitializer) \
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 virtual Node::NodeType Type() { return Node::kType##klass; } 370 virtual Node::NodeType Type() { return Node::kType##klass; }
369 371
370 #define DEFINE_IS_OPERATION(klass) \ 372 #define DEFINE_IS_OPERATION(klass) \
371 virtual bool Is##klass() { return false; } 373 virtual bool Is##klass() { return false; }
372 374
373 #define DEFINE_ALL_IS_OPERATIONS() \ 375 #define DEFINE_ALL_IS_OPERATIONS() \
374 KERNEL_NODES_DO(DEFINE_IS_OPERATION) \ 376 KERNEL_NODES_DO(DEFINE_IS_OPERATION) \
375 DEFINE_IS_OPERATION(TreeNode) \ 377 DEFINE_IS_OPERATION(TreeNode) \
376 KERNEL_TREE_NODES_DO(DEFINE_IS_OPERATION) 378 KERNEL_TREE_NODES_DO(DEFINE_IS_OPERATION)
377 379
380 class Typedef;
378 class Class; 381 class Class;
379 class Constructor; 382 class Constructor;
380 class Field; 383 class Field;
381 class Library; 384 class Library;
382 class LinkedNode; 385 class LinkedNode;
383 class Member; 386 class Member;
384 class Procedure; 387 class Procedure;
385 388
386 class CanonicalName { 389 class CanonicalName {
387 public: 390 public:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 virtual ~Library(); 484 virtual ~Library();
482 485
483 DEFINE_CASTING_OPERATIONS(Library); 486 DEFINE_CASTING_OPERATIONS(Library);
484 487
485 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 488 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
486 virtual void VisitChildren(Visitor* visitor); 489 virtual void VisitChildren(Visitor* visitor);
487 490
488 String* import_uri() { return import_uri_; } 491 String* import_uri() { return import_uri_; }
489 intptr_t source_uri_index() { return source_uri_index_; } 492 intptr_t source_uri_index() { return source_uri_index_; }
490 String* name() { return name_; } 493 String* name() { return name_; }
494 List<Typedef>& typedefs() { return typedefs_; }
491 List<Class>& classes() { return classes_; } 495 List<Class>& classes() { return classes_; }
492 List<Field>& fields() { return fields_; } 496 List<Field>& fields() { return fields_; }
493 List<Procedure>& procedures() { return procedures_; } 497 List<Procedure>& procedures() { return procedures_; }
494 498
495 const uint8_t* kernel_data() { return kernel_data_; } 499 const uint8_t* kernel_data() { return kernel_data_; }
496 intptr_t kernel_data_size() { return kernel_data_size_; } 500 intptr_t kernel_data_size() { return kernel_data_size_; }
497 501
498 private: 502 private:
499 Library() : name_(NULL), kernel_data_(NULL), kernel_data_size_(-1) {} 503 Library() : name_(NULL), kernel_data_(NULL), kernel_data_size_(-1) {}
500 504
501 template <typename T> 505 template <typename T>
502 friend class List; 506 friend class List;
503 507
504 Ref<String> name_; 508 Ref<String> name_;
505 Ref<String> import_uri_; 509 Ref<String> import_uri_;
506 intptr_t source_uri_index_; 510 intptr_t source_uri_index_;
511 List<Typedef> typedefs_;
507 List<Class> classes_; 512 List<Class> classes_;
508 List<Field> fields_; 513 List<Field> fields_;
509 List<Procedure> procedures_; 514 List<Procedure> procedures_;
510 const uint8_t* kernel_data_; 515 const uint8_t* kernel_data_;
511 intptr_t kernel_data_size_; 516 intptr_t kernel_data_size_;
512 517
513 DISALLOW_COPY_AND_ASSIGN(Library); 518 DISALLOW_COPY_AND_ASSIGN(Library);
514 }; 519 };
515 520
516 521
522 class Typedef : public LinkedNode {
523 public:
524 Typedef* ReadFrom(Reader* reader);
525
526 virtual ~Typedef();
527
528 DEFINE_CASTING_OPERATIONS(Typedef);
529
530 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
531 virtual void VisitChildren(Visitor* visitor);
532
533 Library* parent() { return parent_; }
534 String* name() { return name_; }
535 intptr_t source_uri_index() { return source_uri_index_; }
536 TokenPosition position() { return position_; }
537 TypeParameterList& type_parameters() { return type_parameters_; }
538 DartType* type() { return type_; }
539
540 protected:
541 Typedef() : position_(TokenPosition::kNoSource) {}
542
543 private:
544 template <typename T>
545 friend class List;
546
547 Ref<Library> parent_;
548 Ref<String> name_;
549 intptr_t source_uri_index_;
550 TokenPosition position_;
551 TypeParameterList type_parameters_;
552 Child<DartType> type_;
553 };
554
555
517 class Class : public LinkedNode { 556 class Class : public LinkedNode {
518 public: 557 public:
519 Class* ReadFrom(Reader* reader); 558 Class* ReadFrom(Reader* reader);
520 559
521 virtual ~Class(); 560 virtual ~Class();
522 561
523 DEFINE_CASTING_OPERATIONS(Class); 562 DEFINE_CASTING_OPERATIONS(Class);
524 563
525 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 564 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
526 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0; 565 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0;
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 private: 2787 private:
2749 InterfaceType() {} 2788 InterfaceType() {}
2750 2789
2751 Ref<CanonicalName> class_reference_; // Class. 2790 Ref<CanonicalName> class_reference_; // Class.
2752 List<DartType> type_arguments_; 2791 List<DartType> type_arguments_;
2753 2792
2754 DISALLOW_COPY_AND_ASSIGN(InterfaceType); 2793 DISALLOW_COPY_AND_ASSIGN(InterfaceType);
2755 }; 2794 };
2756 2795
2757 2796
2797 class TypedefType : public DartType {
2798 public:
2799 static TypedefType* ReadFrom(Reader* reader);
2800
2801 explicit TypedefType(CanonicalName* class_reference)
2802 : typedef_reference_(class_reference) {}
2803 virtual ~TypedefType();
2804
2805 DEFINE_CASTING_OPERATIONS(TypedefType);
2806
2807 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
2808 virtual void VisitChildren(Visitor* visitor);
2809
2810 CanonicalName* typedef_reference() { return typedef_reference_; }
2811 List<DartType>& type_arguments() { return type_arguments_; }
2812
2813 private:
2814 TypedefType() {}
2815
2816 Ref<CanonicalName> typedef_reference_; // Typedef.
2817 List<DartType> type_arguments_;
2818
2819 DISALLOW_COPY_AND_ASSIGN(TypedefType);
2820 };
2821
2822
2758 class FunctionType : public DartType { 2823 class FunctionType : public DartType {
2759 public: 2824 public:
2760 static FunctionType* ReadFrom(Reader* reader); 2825 static FunctionType* ReadFrom(Reader* reader);
2761 static FunctionType* ReadFrom(Reader* reader, bool _without_type_arguments_); 2826 static FunctionType* ReadFrom(Reader* reader, bool _without_type_arguments_);
2762 2827
2763 virtual ~FunctionType(); 2828 virtual ~FunctionType();
2764 2829
2765 DEFINE_CASTING_OPERATIONS(FunctionType); 2830 DEFINE_CASTING_OPERATIONS(FunctionType);
2766 2831
2767 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor); 2832 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 DISALLOW_COPY_AND_ASSIGN(Program); 2957 DISALLOW_COPY_AND_ASSIGN(Program);
2893 }; 2958 };
2894 2959
2895 2960
2896 class Reference : public AllStatic { 2961 class Reference : public AllStatic {
2897 public: 2962 public:
2898 static CanonicalName* ReadMemberFrom(Reader* reader, bool allow_null = false); 2963 static CanonicalName* ReadMemberFrom(Reader* reader, bool allow_null = false);
2899 2964
2900 static CanonicalName* ReadClassFrom(Reader* reader, bool allow_null = false); 2965 static CanonicalName* ReadClassFrom(Reader* reader, bool allow_null = false);
2901 2966
2967 static CanonicalName* ReadTypedefFrom(Reader* reader);
2968
2902 static String* ReadStringFrom(Reader* reader); 2969 static String* ReadStringFrom(Reader* reader);
2903 }; 2970 };
2904 2971
2905 2972
2906 class ExpressionVisitor { 2973 class ExpressionVisitor {
2907 public: 2974 public:
2908 virtual ~ExpressionVisitor() {} 2975 virtual ~ExpressionVisitor() {}
2909 2976
2910 virtual void VisitDefaultExpression(Expression* node) = 0; 2977 virtual void VisitDefaultExpression(Expression* node) = 0;
2911 virtual void VisitDefaultBasicLiteral(BasicLiteral* node) { 2978 virtual void VisitDefaultBasicLiteral(BasicLiteral* node) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 virtual void VisitInterfaceType(InterfaceType* node) { 3208 virtual void VisitInterfaceType(InterfaceType* node) {
3142 VisitDefaultDartType(node); 3209 VisitDefaultDartType(node);
3143 } 3210 }
3144 virtual void VisitFunctionType(FunctionType* node) { 3211 virtual void VisitFunctionType(FunctionType* node) {
3145 VisitDefaultDartType(node); 3212 VisitDefaultDartType(node);
3146 } 3213 }
3147 virtual void VisitTypeParameterType(TypeParameterType* node) { 3214 virtual void VisitTypeParameterType(TypeParameterType* node) {
3148 VisitDefaultDartType(node); 3215 VisitDefaultDartType(node);
3149 } 3216 }
3150 virtual void VisitVectorType(VectorType* node) { VisitDefaultDartType(node); } 3217 virtual void VisitVectorType(VectorType* node) { VisitDefaultDartType(node); }
3218 virtual void VisitTypedefType(TypedefType* node) {
3219 VisitDefaultDartType(node);
3220 }
3151 }; 3221 };
3152 3222
3153 3223
3154 class TreeVisitor : public ExpressionVisitor, 3224 class TreeVisitor : public ExpressionVisitor,
3155 public StatementVisitor, 3225 public StatementVisitor,
3156 public MemberVisitor, 3226 public MemberVisitor,
3157 public ClassVisitor, 3227 public ClassVisitor,
3158 public InitializerVisitor { 3228 public InitializerVisitor {
3159 public: 3229 public:
3160 virtual ~TreeVisitor() {} 3230 virtual ~TreeVisitor() {}
(...skipping 19 matching lines...) Expand all
3180 VisitDefaultTreeNode(node); 3250 VisitDefaultTreeNode(node);
3181 } 3251 }
3182 virtual void VisitArguments(Arguments* node) { VisitDefaultTreeNode(node); } 3252 virtual void VisitArguments(Arguments* node) { VisitDefaultTreeNode(node); }
3183 virtual void VisitNamedExpression(NamedExpression* node) { 3253 virtual void VisitNamedExpression(NamedExpression* node) {
3184 VisitDefaultTreeNode(node); 3254 VisitDefaultTreeNode(node);
3185 } 3255 }
3186 virtual void VisitSwitchCase(SwitchCase* node) { VisitDefaultTreeNode(node); } 3256 virtual void VisitSwitchCase(SwitchCase* node) { VisitDefaultTreeNode(node); }
3187 virtual void VisitCatch(Catch* node) { VisitDefaultTreeNode(node); } 3257 virtual void VisitCatch(Catch* node) { VisitDefaultTreeNode(node); }
3188 virtual void VisitMapEntry(MapEntry* node) { VisitDefaultTreeNode(node); } 3258 virtual void VisitMapEntry(MapEntry* node) { VisitDefaultTreeNode(node); }
3189 virtual void VisitProgram(Program* node) { VisitDefaultTreeNode(node); } 3259 virtual void VisitProgram(Program* node) { VisitDefaultTreeNode(node); }
3260 virtual void VisitTypedef(Typedef* node) { VisitDefaultTreeNode(node); }
3190 }; 3261 };
3191 3262
3192 3263
3193 class Visitor : public TreeVisitor, public DartTypeVisitor { 3264 class Visitor : public TreeVisitor, public DartTypeVisitor {
3194 public: 3265 public:
3195 virtual ~Visitor() {} 3266 virtual ~Visitor() {}
3196 3267
3197 virtual void VisitDefaultNode(Node* node) = 0; 3268 virtual void VisitDefaultNode(Node* node) = 0;
3198 virtual void VisitDefaultTreeNode(TreeNode* node) { VisitDefaultNode(node); } 3269 virtual void VisitDefaultTreeNode(TreeNode* node) { VisitDefaultNode(node); }
3199 virtual void VisitDefaultDartType(DartType* node) { VisitDefaultNode(node); } 3270 virtual void VisitDefaultDartType(DartType* node) { VisitDefaultNode(node); }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3290 } // namespace kernel 3361 } // namespace kernel
3291 3362
3292 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 3363 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
3293 intptr_t buffer_length); 3364 intptr_t buffer_length);
3294 3365
3295 3366
3296 } // namespace dart 3367 } // namespace dart
3297 3368
3298 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3369 #endif // !defined(DART_PRECOMPILED_RUNTIME)
3299 #endif // RUNTIME_VM_KERNEL_H_ 3370 #endif // RUNTIME_VM_KERNEL_H_
OLDNEW
« no previous file with comments | « pkg/kernel/test/verify_test.dart ('k') | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698