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