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

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

Issue 2780513004: [Kernel] Remove code from the old type propagation. (Closed)
Patch Set: Remove empty status file section 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 | « pkg/pkg.status ('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(InferredValue) \
19 M(DartType) \ 18 M(DartType) \
20 M(InvalidType) \ 19 M(InvalidType) \
21 M(DynamicType) \ 20 M(DynamicType) \
22 M(VoidType) \ 21 M(VoidType) \
23 M(InterfaceType) \ 22 M(InterfaceType) \
24 M(FunctionType) \ 23 M(FunctionType) \
25 M(TypeParameterType) 24 M(TypeParameterType)
26 25
27 #define KERNEL_TREE_NODES_DO(M) \ 26 #define KERNEL_TREE_NODES_DO(M) \
28 M(Library) \ 27 M(Library) \
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 virtual void AcceptMemberVisitor(MemberVisitor* visitor); 693 virtual void AcceptMemberVisitor(MemberVisitor* visitor);
695 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor); 694 virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor);
696 virtual void VisitChildren(Visitor* visitor); 695 virtual void VisitChildren(Visitor* visitor);
697 696
698 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } 697 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; }
699 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; } 698 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; }
700 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; } 699 bool IsStatic() { return (flags_ & kFlagStatic) == kFlagStatic; }
701 intptr_t source_uri_index() { return source_uri_index_; } 700 intptr_t source_uri_index() { return source_uri_index_; }
702 701
703 DartType* type() { return type_; } 702 DartType* type() { return type_; }
704 InferredValue* inferred_value() { return inferred_value_; }
705 Expression* initializer() { return initializer_; } 703 Expression* initializer() { return initializer_; }
706 704
707 private: 705 private:
708 Field() {} 706 Field() {}
709 707
710 template <typename T> 708 template <typename T>
711 friend class List; 709 friend class List;
712 710
713 word flags_; 711 word flags_;
714 intptr_t source_uri_index_; 712 intptr_t source_uri_index_;
715 Child<DartType> type_; 713 Child<DartType> type_;
716 Child<InferredValue> inferred_value_;
717 Child<Expression> initializer_; 714 Child<Expression> initializer_;
718 715
719 DISALLOW_COPY_AND_ASSIGN(Field); 716 DISALLOW_COPY_AND_ASSIGN(Field);
720 }; 717 };
721 718
722 719
723 class Constructor : public Member { 720 class Constructor : public Member {
724 public: 721 public:
725 enum Flags { 722 enum Flags {
726 kFlagConst = 1 << 0, 723 kFlagConst = 1 << 0,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 959
963 AsyncMarker async_marker() { return async_marker_; } 960 AsyncMarker async_marker() { return async_marker_; }
964 AsyncMarker dart_async_marker() { return dart_async_marker_; } 961 AsyncMarker dart_async_marker() { return dart_async_marker_; }
965 TypeParameterList& type_parameters() { return type_parameters_; } 962 TypeParameterList& type_parameters() { return type_parameters_; }
966 int required_parameter_count() { return required_parameter_count_; } 963 int required_parameter_count() { return required_parameter_count_; }
967 List<VariableDeclaration>& positional_parameters() { 964 List<VariableDeclaration>& positional_parameters() {
968 return positional_parameters_; 965 return positional_parameters_;
969 } 966 }
970 List<VariableDeclaration>& named_parameters() { return named_parameters_; } 967 List<VariableDeclaration>& named_parameters() { return named_parameters_; }
971 DartType* return_type() { return return_type_; } 968 DartType* return_type() { return return_type_; }
972 InferredValue* inferred_return_value() { return inferred_return_value_; }
973 Statement* body() { return body_; } 969 Statement* body() { return body_; }
974 TokenPosition position() { return position_; } 970 TokenPosition position() { return position_; }
975 TokenPosition end_position() { return end_position_; } 971 TokenPosition end_position() { return end_position_; }
976 972
977 private: 973 private:
978 FunctionNode() 974 FunctionNode()
979 : position_(TokenPosition::kNoSource), 975 : position_(TokenPosition::kNoSource),
980 end_position_(TokenPosition::kNoSource) {} 976 end_position_(TokenPosition::kNoSource) {}
981 977
982 AsyncMarker async_marker_; 978 AsyncMarker async_marker_;
983 AsyncMarker dart_async_marker_; 979 AsyncMarker dart_async_marker_;
984 TypeParameterList type_parameters_; 980 TypeParameterList type_parameters_;
985 int required_parameter_count_; 981 int required_parameter_count_;
986 List<VariableDeclaration> positional_parameters_; 982 List<VariableDeclaration> positional_parameters_;
987 List<VariableDeclaration> named_parameters_; 983 List<VariableDeclaration> named_parameters_;
988 Child<DartType> return_type_; 984 Child<DartType> return_type_;
989 Child<InferredValue> inferred_return_value_;
990 Child<Statement> body_; 985 Child<Statement> body_;
991 TokenPosition position_; 986 TokenPosition position_;
992 TokenPosition end_position_; 987 TokenPosition end_position_;
993 988
994 DISALLOW_COPY_AND_ASSIGN(FunctionNode); 989 DISALLOW_COPY_AND_ASSIGN(FunctionNode);
995 }; 990 };
996 991
997 992
998 class Expression : public TreeNode { 993 class Expression : public TreeNode {
999 public: 994 public:
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 DEFINE_CASTING_OPERATIONS(VariableDeclaration); 2457 DEFINE_CASTING_OPERATIONS(VariableDeclaration);
2463 2458
2464 virtual void AcceptStatementVisitor(StatementVisitor* visitor); 2459 virtual void AcceptStatementVisitor(StatementVisitor* visitor);
2465 virtual void VisitChildren(Visitor* visitor); 2460 virtual void VisitChildren(Visitor* visitor);
2466 2461
2467 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } 2462 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; }
2468 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; } 2463 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; }
2469 2464
2470 String* name() { return name_; } 2465 String* name() { return name_; }
2471 DartType* type() { return type_; } 2466 DartType* type() { return type_; }
2472 InferredValue* inferred_value() { return inferred_value_; }
2473 Expression* initializer() { return initializer_; } 2467 Expression* initializer() { return initializer_; }
2474 TokenPosition equals_position() { return equals_position_; } 2468 TokenPosition equals_position() { return equals_position_; }
2475 TokenPosition end_position() { return end_position_; } 2469 TokenPosition end_position() { return end_position_; }
2476 void set_end_position(TokenPosition position) { end_position_ = position; } 2470 void set_end_position(TokenPosition position) { end_position_ = position; }
2477 2471
2478 private: 2472 private:
2479 VariableDeclaration() 2473 VariableDeclaration()
2480 : equals_position_(TokenPosition::kNoSourcePos), 2474 : equals_position_(TokenPosition::kNoSourcePos),
2481 end_position_(TokenPosition::kNoSource) {} 2475 end_position_(TokenPosition::kNoSource) {}
2482 2476
2483 template <typename T> 2477 template <typename T>
2484 friend class List; 2478 friend class List;
2485 2479
2486 word flags_; 2480 word flags_;
2487 Ref<String> name_; 2481 Ref<String> name_;
2488 Child<DartType> type_; 2482 Child<DartType> type_;
2489 Child<InferredValue> inferred_value_;
2490 Child<Expression> initializer_; 2483 Child<Expression> initializer_;
2491 TokenPosition equals_position_; 2484 TokenPosition equals_position_;
2492 TokenPosition end_position_; 2485 TokenPosition end_position_;
2493 2486
2494 DISALLOW_COPY_AND_ASSIGN(VariableDeclaration); 2487 DISALLOW_COPY_AND_ASSIGN(VariableDeclaration);
2495 }; 2488 };
2496 2489
2497 2490
2498 class FunctionDeclaration : public Statement { 2491 class FunctionDeclaration : public Statement {
2499 public: 2492 public:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 Name(String* string, CanonicalName* library_reference) 2534 Name(String* string, CanonicalName* library_reference)
2542 : string_(string), library_reference_(library_reference) {} // NOLINT 2535 : string_(string), library_reference_(library_reference) {} // NOLINT
2543 2536
2544 Ref<String> string_; 2537 Ref<String> string_;
2545 Ref<CanonicalName> library_reference_; 2538 Ref<CanonicalName> library_reference_;
2546 2539
2547 DISALLOW_COPY_AND_ASSIGN(Name); 2540 DISALLOW_COPY_AND_ASSIGN(Name);
2548 }; 2541 };
2549 2542
2550 2543
2551 class InferredValue : public Node {
2552 public:
2553 static const uint8_t kNull = 1 << 0;
2554 static const uint8_t kInteger = 1 << 1;
2555 static const uint8_t kDouble = 1 << 2;
2556 static const uint8_t kString = 1 << 3;
2557 static const uint8_t kOther = 1 << 4;
2558
2559 enum BaseClassKind {
2560 kNone,
2561 kExact,
2562 kSubclass,
2563 kSubtype,
2564 };
2565
2566 static InferredValue* ReadFrom(Reader* reader);
2567
2568 virtual ~InferredValue();
2569
2570 DEFINE_CASTING_OPERATIONS(InferredValue);
2571
2572 virtual void AcceptVisitor(Visitor* visitor);
2573 virtual void VisitChildren(Visitor* visitor);
2574
2575 bool IsInterfaceType() { return kind_ == kSubtype; }
2576 bool IsExactClass() { return kind_ == kExact; }
2577 bool IsSubclass() { return kind_ == kSubclass; }
2578
2579 bool CanBeNull() { return (value_bits_ & kNull) != 0; }
2580 bool CanBeInteger() { return (value_bits_ & kInteger) != 0; }
2581 bool CanBeDouble() { return (value_bits_ & kDouble) != 0; }
2582 bool CanBeString() { return (value_bits_ & kString) != 0; }
2583
2584 bool IsAlwaysNull() { return value_bits_ == kNull; }
2585 bool IsAlwaysInteger() { return value_bits_ == kInteger; }
2586 bool IsAlwaysDouble() { return value_bits_ == kDouble; }
2587 bool IsAlwaysString() { return value_bits_ == kString; }
2588
2589 Class* klass() { return klass_reference_->AsClass(); }
2590 BaseClassKind kind() { return kind_; }
2591 uint8_t value_bits() { return value_bits_; }
2592
2593 private:
2594 InferredValue() {}
2595
2596 Ref<CanonicalName> klass_reference_;
2597 BaseClassKind kind_;
2598 uint8_t value_bits_;
2599
2600 DISALLOW_COPY_AND_ASSIGN(InferredValue);
2601 };
2602
2603
2604 class DartType : public Node { 2544 class DartType : public Node {
2605 public: 2545 public:
2606 static DartType* ReadFrom(Reader* reader); 2546 static DartType* ReadFrom(Reader* reader);
2607 2547
2608 virtual ~DartType(); 2548 virtual ~DartType();
2609 2549
2610 DEFINE_CASTING_OPERATIONS(DartType); 2550 DEFINE_CASTING_OPERATIONS(DartType);
2611 2551
2612 virtual void AcceptVisitor(Visitor* visitor); 2552 virtual void AcceptVisitor(Visitor* visitor);
2613 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor) = 0; 2553 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor) = 0;
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 3079
3140 3080
3141 class Visitor : public TreeVisitor, 3081 class Visitor : public TreeVisitor,
3142 public DartTypeVisitor, 3082 public DartTypeVisitor,
3143 public ClassReferenceVisitor, 3083 public ClassReferenceVisitor,
3144 public MemberReferenceVisitor { 3084 public MemberReferenceVisitor {
3145 public: 3085 public:
3146 virtual ~Visitor() {} 3086 virtual ~Visitor() {}
3147 3087
3148 virtual void VisitDefaultNode(Node* node) = 0; 3088 virtual void VisitDefaultNode(Node* node) = 0;
3149 virtual void VisitInferredValue(InferredValue* node) {
3150 VisitDefaultNode(node);
3151 }
3152 virtual void VisitDefaultTreeNode(TreeNode* node) { VisitDefaultNode(node); } 3089 virtual void VisitDefaultTreeNode(TreeNode* node) { VisitDefaultNode(node); }
3153 virtual void VisitDefaultDartType(DartType* node) { VisitDefaultNode(node); } 3090 virtual void VisitDefaultDartType(DartType* node) { VisitDefaultNode(node); }
3154 virtual void VisitName(Name* node) { VisitDefaultNode(node); } 3091 virtual void VisitName(Name* node) { VisitDefaultNode(node); }
3155 virtual void VisitDefaultClassReference(Class* node) { 3092 virtual void VisitDefaultClassReference(Class* node) {
3156 VisitDefaultNode(node); 3093 VisitDefaultNode(node);
3157 } 3094 }
3158 virtual void VisitDefaultMemberReference(Member* node) { 3095 virtual void VisitDefaultMemberReference(Member* node) {
3159 VisitDefaultNode(node); 3096 VisitDefaultNode(node);
3160 } 3097 }
3161 }; 3098 };
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 3182
3246 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 3183 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
3247 intptr_t buffer_length); 3184 intptr_t buffer_length);
3248 3185
3249 3186
3250 3187
3251 } // namespace dart 3188 } // namespace dart
3252 3189
3253 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3190 #endif // !defined(DART_PRECOMPILED_RUNTIME)
3254 #endif // RUNTIME_VM_KERNEL_H_ 3191 #endif // RUNTIME_VM_KERNEL_H_
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698