| 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/token_position.h" |
| 12 | 13 |
| 13 | 14 |
| 14 #define KERNEL_NODES_DO(M) \ | 15 #define KERNEL_NODES_DO(M) \ |
| 15 M(Name) \ | 16 M(Name) \ |
| 16 M(InferredValue) \ | 17 M(InferredValue) \ |
| 17 M(DartType) \ | 18 M(DartType) \ |
| 18 M(InvalidType) \ | 19 M(InvalidType) \ |
| 19 M(DynamicType) \ | 20 M(DynamicType) \ |
| 20 M(VoidType) \ | 21 M(VoidType) \ |
| 21 M(InterfaceType) \ | 22 M(InterfaceType) \ |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 friend class Program; | 302 friend class Program; |
| 302 | 303 |
| 303 List<String> strings_; | 304 List<String> strings_; |
| 304 | 305 |
| 305 DISALLOW_COPY_AND_ASSIGN(StringTable); | 306 DISALLOW_COPY_AND_ASSIGN(StringTable); |
| 306 }; | 307 }; |
| 307 | 308 |
| 308 | 309 |
| 309 class LineStartingTable { | 310 class LineStartingTable { |
| 310 public: | 311 public: |
| 311 void ReadFrom(Reader* reader, intptr_t length); | 312 void ReadFrom(Reader* reader); |
| 312 void WriteTo(Writer* writer); | 313 void WriteTo(Writer* writer); |
| 313 ~LineStartingTable() { | 314 ~LineStartingTable() { |
| 314 for (intptr_t i = 0; i < size_; ++i) { | 315 for (intptr_t i = 0; i < size_; ++i) { |
| 315 delete[] values_[i]; | 316 delete[] values_[i]; |
| 316 } | 317 } |
| 317 delete[] values_; | 318 delete[] values_; |
| 318 } | 319 } |
| 319 | 320 |
| 320 intptr_t size() { return size_; } | 321 intptr_t size() { return size_; } |
| 321 intptr_t* valuesFor(int i) { return values_[i]; } | 322 intptr_t* valuesFor(int i) { return values_[i]; } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void WriteTo(Writer* writer); | 407 void WriteTo(Writer* writer); |
| 407 | 408 |
| 408 virtual ~Library(); | 409 virtual ~Library(); |
| 409 | 410 |
| 410 DEFINE_CASTING_OPERATIONS(Library); | 411 DEFINE_CASTING_OPERATIONS(Library); |
| 411 | 412 |
| 412 virtual void AcceptTreeVisitor(TreeVisitor* visitor); | 413 virtual void AcceptTreeVisitor(TreeVisitor* visitor); |
| 413 virtual void VisitChildren(Visitor* visitor); | 414 virtual void VisitChildren(Visitor* visitor); |
| 414 | 415 |
| 415 String* import_uri() { return import_uri_; } | 416 String* import_uri() { return import_uri_; } |
| 417 intptr_t source_uri_index() { return source_uri_index_; } |
| 416 String* name() { return name_; } | 418 String* name() { return name_; } |
| 417 List<Class>& classes() { return classes_; } | 419 List<Class>& classes() { return classes_; } |
| 418 List<Field>& fields() { return fields_; } | 420 List<Field>& fields() { return fields_; } |
| 419 List<Procedure>& procedures() { return procedures_; } | 421 List<Procedure>& procedures() { return procedures_; } |
| 420 | 422 |
| 421 bool IsCorelibrary() { | 423 bool IsCorelibrary() { |
| 422 static const char* dart_library = "dart:"; | 424 static const char* dart_library = "dart:"; |
| 423 static intptr_t dart_library_length = strlen(dart_library); | 425 static intptr_t dart_library_length = strlen(dart_library); |
| 424 static const char* patch_library = "dart:_patch"; | 426 static const char* patch_library = "dart:_patch"; |
| 425 static intptr_t patch_library_length = strlen(patch_library); | 427 static intptr_t patch_library_length = strlen(patch_library); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 441 } | 443 } |
| 442 | 444 |
| 443 private: | 445 private: |
| 444 Library() : name_(NULL) {} | 446 Library() : name_(NULL) {} |
| 445 | 447 |
| 446 template <typename T> | 448 template <typename T> |
| 447 friend class List; | 449 friend class List; |
| 448 | 450 |
| 449 Ref<String> name_; | 451 Ref<String> name_; |
| 450 Ref<String> import_uri_; | 452 Ref<String> import_uri_; |
| 453 intptr_t source_uri_index_; |
| 451 List<Class> classes_; | 454 List<Class> classes_; |
| 452 List<Field> fields_; | 455 List<Field> fields_; |
| 453 List<Procedure> procedures_; | 456 List<Procedure> procedures_; |
| 454 | 457 |
| 455 DISALLOW_COPY_AND_ASSIGN(Library); | 458 DISALLOW_COPY_AND_ASSIGN(Library); |
| 456 }; | 459 }; |
| 457 | 460 |
| 458 | 461 |
| 459 class Class : public TreeNode { | 462 class Class : public TreeNode { |
| 460 public: | 463 public: |
| 461 Class* ReadFrom(Reader* reader); | 464 Class* ReadFrom(Reader* reader); |
| 462 void WriteTo(Writer* writer); | 465 void WriteTo(Writer* writer); |
| 463 | 466 |
| 464 virtual ~Class(); | 467 virtual ~Class(); |
| 465 | 468 |
| 466 DEFINE_CASTING_OPERATIONS(Class); | 469 DEFINE_CASTING_OPERATIONS(Class); |
| 467 | 470 |
| 468 virtual void AcceptTreeVisitor(TreeVisitor* visitor); | 471 virtual void AcceptTreeVisitor(TreeVisitor* visitor); |
| 469 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0; | 472 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0; |
| 470 virtual void AcceptReferenceVisitor(ClassReferenceVisitor* visitor) = 0; | 473 virtual void AcceptReferenceVisitor(ClassReferenceVisitor* visitor) = 0; |
| 471 | 474 |
| 472 Library* parent() { return parent_; } | 475 Library* parent() { return parent_; } |
| 473 String* name() { return name_; } | 476 String* name() { return name_; } |
| 477 intptr_t source_uri_index() { return source_uri_index_; } |
| 474 bool is_abstract() { return is_abstract_; } | 478 bool is_abstract() { return is_abstract_; } |
| 475 List<Expression>& annotations() { return annotations_; } | 479 List<Expression>& annotations() { return annotations_; } |
| 476 | 480 |
| 477 virtual List<TypeParameter>& type_parameters() = 0; | 481 virtual List<TypeParameter>& type_parameters() = 0; |
| 478 virtual List<InterfaceType>& implemented_classes() = 0; | 482 virtual List<InterfaceType>& implemented_classes() = 0; |
| 479 virtual List<Field>& fields() = 0; | 483 virtual List<Field>& fields() = 0; |
| 480 virtual List<Constructor>& constructors() = 0; | 484 virtual List<Constructor>& constructors() = 0; |
| 481 virtual List<Procedure>& procedures() = 0; | 485 virtual List<Procedure>& procedures() = 0; |
| 482 | 486 |
| 483 protected: | 487 protected: |
| 484 Class() : is_abstract_(false) {} | 488 Class() : is_abstract_(false) {} |
| 485 | 489 |
| 486 private: | 490 private: |
| 487 template <typename T> | 491 template <typename T> |
| 488 friend class List; | 492 friend class List; |
| 489 | 493 |
| 490 Ref<Library> parent_; | 494 Ref<Library> parent_; |
| 491 Ref<String> name_; | 495 Ref<String> name_; |
| 496 intptr_t source_uri_index_; |
| 492 bool is_abstract_; | 497 bool is_abstract_; |
| 493 List<Expression> annotations_; | 498 List<Expression> annotations_; |
| 494 | 499 |
| 495 DISALLOW_COPY_AND_ASSIGN(Class); | 500 DISALLOW_COPY_AND_ASSIGN(Class); |
| 496 }; | 501 }; |
| 497 | 502 |
| 498 | 503 |
| 499 class NormalClass : public Class { | 504 class NormalClass : public Class { |
| 500 public: | 505 public: |
| 501 NormalClass* ReadFrom(Reader* reader); | 506 NormalClass* ReadFrom(Reader* reader); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 627 |
| 623 DEFINE_CASTING_OPERATIONS(Field); | 628 DEFINE_CASTING_OPERATIONS(Field); |
| 624 | 629 |
| 625 virtual void AcceptMemberVisitor(MemberVisitor* visitor); | 630 virtual void AcceptMemberVisitor(MemberVisitor* visitor); |
| 626 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor); | 631 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor); |
| 627 virtual void VisitChildren(Visitor* visitor); | 632 virtual void VisitChildren(Visitor* visitor); |
| 628 | 633 |
| 629 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } | 634 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } |
| 630 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; } | 635 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; } |
| 631 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; } | 636 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; } |
| 637 intptr_t source_uri_index() { return source_uri_index_; } |
| 632 | 638 |
| 633 DartType* type() { return type_; } | 639 DartType* type() { return type_; } |
| 634 InferredValue* inferred_value() { return inferred_value_; } | 640 InferredValue* inferred_value() { return inferred_value_; } |
| 635 Expression* initializer() { return initializer_; } | 641 Expression* initializer() { return initializer_; } |
| 642 TokenPosition position() { return position_; } |
| 636 | 643 |
| 637 private: | 644 private: |
| 638 Field() {} | 645 Field() : position_(TokenPosition::kNoSource) {} |
| 639 | 646 |
| 640 template <typename T> | 647 template <typename T> |
| 641 friend class List; | 648 friend class List; |
| 642 | 649 |
| 643 word flags_; | 650 word flags_; |
| 651 intptr_t source_uri_index_; |
| 644 Child<DartType> type_; | 652 Child<DartType> type_; |
| 645 Child<InferredValue> inferred_value_; | 653 Child<InferredValue> inferred_value_; |
| 646 Child<Expression> initializer_; | 654 Child<Expression> initializer_; |
| 655 TokenPosition position_; |
| 647 | 656 |
| 648 DISALLOW_COPY_AND_ASSIGN(Field); | 657 DISALLOW_COPY_AND_ASSIGN(Field); |
| 649 }; | 658 }; |
| 650 | 659 |
| 651 | 660 |
| 652 class Constructor : public Member { | 661 class Constructor : public Member { |
| 653 public: | 662 public: |
| 654 enum Flags { | 663 enum Flags { |
| 655 kFlagConst = 1 << 0, | 664 kFlagConst = 1 << 0, |
| 656 kFlagExternal = 1 << 1, | 665 kFlagExternal = 1 << 1, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor); | 727 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor); |
| 719 virtual void VisitChildren(Visitor* visitor); | 728 virtual void VisitChildren(Visitor* visitor); |
| 720 | 729 |
| 721 ProcedureKind kind() { return kind_; } | 730 ProcedureKind kind() { return kind_; } |
| 722 FunctionNode* function() { return function_; } | 731 FunctionNode* function() { return function_; } |
| 723 | 732 |
| 724 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; } | 733 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; } |
| 725 bool IsAbstract() { return (flags_ & kFlagAbstract) == kFlagAbstract; } | 734 bool IsAbstract() { return (flags_ & kFlagAbstract) == kFlagAbstract; } |
| 726 bool IsExternal() { return (flags_ & kFlagExternal) == kFlagExternal; } | 735 bool IsExternal() { return (flags_ & kFlagExternal) == kFlagExternal; } |
| 727 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } | 736 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } |
| 737 intptr_t source_uri_index() { return source_uri_index_; } |
| 728 | 738 |
| 729 private: | 739 private: |
| 730 Procedure() : kind_(kIncompleteProcedure), flags_(0), function_(NULL) {} | 740 Procedure() : kind_(kIncompleteProcedure), flags_(0), function_(NULL) {} |
| 731 | 741 |
| 732 template <typename T> | 742 template <typename T> |
| 733 friend class List; | 743 friend class List; |
| 734 | 744 |
| 735 ProcedureKind kind_; | 745 ProcedureKind kind_; |
| 736 word flags_; | 746 word flags_; |
| 747 intptr_t source_uri_index_; |
| 737 Child<FunctionNode> function_; | 748 Child<FunctionNode> function_; |
| 738 | 749 |
| 739 DISALLOW_COPY_AND_ASSIGN(Procedure); | 750 DISALLOW_COPY_AND_ASSIGN(Procedure); |
| 740 }; | 751 }; |
| 741 | 752 |
| 742 | 753 |
| 743 class Initializer : public TreeNode { | 754 class Initializer : public TreeNode { |
| 744 public: | 755 public: |
| 745 static Initializer* ReadFrom(Reader* reader); | 756 static Initializer* ReadFrom(Reader* reader); |
| 746 virtual void WriteTo(Writer* writer) = 0; | 757 virtual void WriteTo(Writer* writer) = 0; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 public: | 938 public: |
| 928 static Expression* ReadFrom(Reader* reader); | 939 static Expression* ReadFrom(Reader* reader); |
| 929 virtual void WriteTo(Writer* writer) = 0; | 940 virtual void WriteTo(Writer* writer) = 0; |
| 930 | 941 |
| 931 virtual ~Expression(); | 942 virtual ~Expression(); |
| 932 | 943 |
| 933 DEFINE_CASTING_OPERATIONS(Expression); | 944 DEFINE_CASTING_OPERATIONS(Expression); |
| 934 | 945 |
| 935 virtual void AcceptTreeVisitor(TreeVisitor* visitor); | 946 virtual void AcceptTreeVisitor(TreeVisitor* visitor); |
| 936 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor) = 0; | 947 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor) = 0; |
| 948 TokenPosition position() { return position_; } |
| 937 | 949 |
| 938 protected: | 950 protected: |
| 939 Expression() {} | 951 Expression() : position_(TokenPosition::kNoSource) {} |
| 952 TokenPosition position_; |
| 940 | 953 |
| 941 private: | 954 private: |
| 942 DISALLOW_COPY_AND_ASSIGN(Expression); | 955 DISALLOW_COPY_AND_ASSIGN(Expression); |
| 943 }; | 956 }; |
| 944 | 957 |
| 945 | 958 |
| 946 class InvalidExpression : public Expression { | 959 class InvalidExpression : public Expression { |
| 947 public: | 960 public: |
| 948 static InvalidExpression* ReadFrom(Reader* reader); | 961 static InvalidExpression* ReadFrom(Reader* reader); |
| 949 virtual void WriteTo(Writer* writer); | 962 virtual void WriteTo(Writer* writer); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 Child<Arguments> arguments_; | 1287 Child<Arguments> arguments_; |
| 1275 | 1288 |
| 1276 DISALLOW_COPY_AND_ASSIGN(DirectMethodInvocation); | 1289 DISALLOW_COPY_AND_ASSIGN(DirectMethodInvocation); |
| 1277 }; | 1290 }; |
| 1278 | 1291 |
| 1279 | 1292 |
| 1280 class StaticInvocation : public Expression { | 1293 class StaticInvocation : public Expression { |
| 1281 public: | 1294 public: |
| 1282 static StaticInvocation* ReadFrom(Reader* reader, bool is_const); | 1295 static StaticInvocation* ReadFrom(Reader* reader, bool is_const); |
| 1283 virtual void WriteTo(Writer* writer); | 1296 virtual void WriteTo(Writer* writer); |
| 1284 | |
| 1285 explicit StaticInvocation(Procedure* procedure, | |
| 1286 Arguments* args, | |
| 1287 bool is_const) | |
| 1288 : procedure_(procedure), arguments_(args), is_const_(is_const) {} | |
| 1289 ~StaticInvocation(); | 1297 ~StaticInvocation(); |
| 1290 | 1298 |
| 1291 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); | 1299 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); |
| 1292 virtual void VisitChildren(Visitor* visitor); | 1300 virtual void VisitChildren(Visitor* visitor); |
| 1293 | 1301 |
| 1294 Procedure* procedure() { return procedure_; } | 1302 Procedure* procedure() { return procedure_; } |
| 1295 Arguments* arguments() { return arguments_; } | 1303 Arguments* arguments() { return arguments_; } |
| 1296 bool is_const() { return is_const_; } | 1304 bool is_const() { return is_const_; } |
| 1297 | 1305 |
| 1298 private: | 1306 private: |
| (...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2778 void WriteTo(Writer* writer); | 2786 void WriteTo(Writer* writer); |
| 2779 | 2787 |
| 2780 virtual ~Program(); | 2788 virtual ~Program(); |
| 2781 | 2789 |
| 2782 DEFINE_CASTING_OPERATIONS(Program); | 2790 DEFINE_CASTING_OPERATIONS(Program); |
| 2783 | 2791 |
| 2784 virtual void AcceptTreeVisitor(TreeVisitor* visitor); | 2792 virtual void AcceptTreeVisitor(TreeVisitor* visitor); |
| 2785 virtual void VisitChildren(Visitor* visitor); | 2793 virtual void VisitChildren(Visitor* visitor); |
| 2786 | 2794 |
| 2787 StringTable& string_table() { return string_table_; } | 2795 StringTable& string_table() { return string_table_; } |
| 2796 StringTable& source_uri_table() { return source_uri_table_; } |
| 2797 LineStartingTable& line_starting_table() { return line_starting_table_; } |
| 2788 List<Library>& libraries() { return libraries_; } | 2798 List<Library>& libraries() { return libraries_; } |
| 2789 Procedure* main_method() { return main_method_; } | 2799 Procedure* main_method() { return main_method_; } |
| 2790 | 2800 |
| 2791 private: | 2801 private: |
| 2792 Program() {} | 2802 Program() {} |
| 2793 | 2803 |
| 2794 List<Library> libraries_; | 2804 List<Library> libraries_; |
| 2795 Ref<Procedure> main_method_; | 2805 Ref<Procedure> main_method_; |
| 2796 StringTable string_table_; | 2806 StringTable string_table_; |
| 2807 StringTable source_uri_table_; |
| 2808 LineStartingTable line_starting_table_; |
| 2797 | 2809 |
| 2798 DISALLOW_COPY_AND_ASSIGN(Program); | 2810 DISALLOW_COPY_AND_ASSIGN(Program); |
| 2799 }; | 2811 }; |
| 2800 | 2812 |
| 2801 | 2813 |
| 2802 class Reference : public AllStatic { | 2814 class Reference : public AllStatic { |
| 2803 public: | 2815 public: |
| 2804 static Member* ReadMemberFrom(Reader* reader, bool allow_null = false); | 2816 static Member* ReadMemberFrom(Reader* reader, bool allow_null = false); |
| 2805 static void WriteMemberTo(Writer* writer, | 2817 static void WriteMemberTo(Writer* writer, |
| 2806 Member* member, | 2818 Member* member, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3240 }; | 3252 }; |
| 3241 | 3253 |
| 3242 | 3254 |
| 3243 void WritePrecompiledKernel(ByteWriter* out, kernel::Program* program); | 3255 void WritePrecompiledKernel(ByteWriter* out, kernel::Program* program); |
| 3244 | 3256 |
| 3245 | 3257 |
| 3246 } // namespace dart | 3258 } // namespace dart |
| 3247 | 3259 |
| 3248 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 3260 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 3249 #endif // RUNTIME_VM_KERNEL_H_ | 3261 #endif // RUNTIME_VM_KERNEL_H_ |
| OLD | NEW |