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