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_TO_IL_H_ | 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ |
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ | 6 #define RUNTIME_VM_KERNEL_TO_IL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } else { | 74 } else { |
75 return pair->value; | 75 return pair->value; |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 inline Pair* LookupPair(const Key& key) { | 79 inline Pair* LookupPair(const Key& key) { |
80 return DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); | 80 return DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 | |
85 template <typename V> | |
86 class IntKeyRawPointerValueTrait { | |
87 public: | |
88 typedef int64_t Key; | |
Kevin Millikin (Google)
2017/03/28 12:30:12
intptr_t?
| |
89 typedef V Value; | |
90 | |
91 struct Pair { | |
92 Key key; | |
93 Value value; | |
94 Pair() : key(NULL), value() {} | |
95 Pair(const Key key, const Value& value) : key(key), value(value) {} | |
96 Pair(const Pair& other) : key(other.key), value(other.value) {} | |
97 }; | |
98 | |
99 static Key KeyOf(Pair kv) { return kv.key; } | |
100 static Value ValueOf(Pair kv) { return kv.value; } | |
101 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); } | |
102 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; } | |
103 }; | |
104 | |
105 template <typename V> | |
106 class IntMap : public DirectChainedHashMap<IntKeyRawPointerValueTrait<V> > { | |
107 public: | |
108 typedef typename IntKeyRawPointerValueTrait<V>::Key Key; | |
109 typedef typename IntKeyRawPointerValueTrait<V>::Value Value; | |
110 typedef typename IntKeyRawPointerValueTrait<V>::Pair Pair; | |
111 | |
112 inline void Insert(const Key& key, const Value& value) { | |
113 Pair pair(key, value); | |
114 DirectChainedHashMap<IntKeyRawPointerValueTrait<V> >::Insert(pair); | |
115 } | |
116 | |
117 inline V Lookup(const Key& key) { | |
118 Pair* pair = | |
119 DirectChainedHashMap<IntKeyRawPointerValueTrait<V> >::Lookup(key); | |
120 if (pair == NULL) { | |
121 return V(); | |
122 } else { | |
123 return pair->value; | |
124 } | |
125 } | |
126 | |
127 inline Pair* LookupPair(const Key& key) { | |
128 return DirectChainedHashMap<IntKeyRawPointerValueTrait<V> >::Lookup(key); | |
129 } | |
130 }; | |
131 | |
84 template <typename K, typename V> | 132 template <typename K, typename V> |
85 class MallocMap | 133 class MallocMap |
86 : public MallocDirectChainedHashMap<RawPointerKeyValueTrait<K, V> > { | 134 : public MallocDirectChainedHashMap<RawPointerKeyValueTrait<K, V> > { |
87 public: | 135 public: |
88 typedef typename RawPointerKeyValueTrait<K, V>::Key Key; | 136 typedef typename RawPointerKeyValueTrait<K, V>::Key Key; |
89 typedef typename RawPointerKeyValueTrait<K, V>::Value Value; | 137 typedef typename RawPointerKeyValueTrait<K, V>::Value Value; |
90 typedef typename RawPointerKeyValueTrait<K, V>::Pair Pair; | 138 typedef typename RawPointerKeyValueTrait<K, V>::Pair Pair; |
91 | 139 |
92 inline void Insert(const Key& key, const Value& value) { | 140 inline void Insert(const Key& key, const Value& value) { |
93 Pair pair(key, value); | 141 Pair pair(key, value); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 Zone* zone_; | 543 Zone* zone_; |
496 TranslationHelper& translation_helper_; | 544 TranslationHelper& translation_helper_; |
497 DartTypeTranslator& type_translator_; | 545 DartTypeTranslator& type_translator_; |
498 | 546 |
499 Script& script_; | 547 Script& script_; |
500 Instance& result_; | 548 Instance& result_; |
501 }; | 549 }; |
502 | 550 |
503 | 551 |
504 struct FunctionScope { | 552 struct FunctionScope { |
505 FunctionNode* function; | 553 int64_t kernel_offset; |
Kevin Millikin (Google)
2017/03/28 12:30:12
intptr_t?
| |
506 LocalScope* scope; | 554 LocalScope* scope; |
507 }; | 555 }; |
508 | 556 |
509 | 557 |
510 class ScopeBuildingResult : public ZoneAllocated { | 558 class ScopeBuildingResult : public ZoneAllocated { |
511 public: | 559 public: |
512 ScopeBuildingResult() | 560 ScopeBuildingResult() |
513 : this_variable(NULL), | 561 : this_variable(NULL), |
514 type_arguments_variable(NULL), | 562 type_arguments_variable(NULL), |
515 switch_variable(NULL), | 563 switch_variable(NULL), |
516 finally_return_variable(NULL), | 564 finally_return_variable(NULL), |
517 setter_value(NULL), | 565 setter_value(NULL), |
518 yield_jump_variable(NULL), | 566 yield_jump_variable(NULL), |
519 yield_context_variable(NULL) {} | 567 yield_context_variable(NULL) {} |
520 | 568 |
521 Map<VariableDeclaration, LocalVariable*> locals; | 569 IntMap<LocalVariable*> locals; |
522 Map<TreeNode, LocalScope*> scopes; | 570 IntMap<LocalScope*> scopes; |
523 GrowableArray<FunctionScope> function_scopes; | 571 GrowableArray<FunctionScope> function_scopes; |
524 | 572 |
525 // Only non-NULL for instance functions. | 573 // Only non-NULL for instance functions. |
526 LocalVariable* this_variable; | 574 LocalVariable* this_variable; |
527 | 575 |
528 // Only non-NULL for factory constructor functions. | 576 // Only non-NULL for factory constructor functions. |
529 LocalVariable* type_arguments_variable; | 577 LocalVariable* type_arguments_variable; |
530 | 578 |
531 // Non-NULL when the function contains a switch statement. | 579 // Non-NULL when the function contains a switch statement. |
532 LocalVariable* switch_variable; | 580 LocalVariable* switch_variable; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 namespace kernel { | 1077 namespace kernel { |
1030 | 1078 |
1031 RawObject* EvaluateMetadata(TreeNode* const kernel_node); | 1079 RawObject* EvaluateMetadata(TreeNode* const kernel_node); |
1032 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node); | 1080 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node); |
1033 | 1081 |
1034 } // namespace kernel | 1082 } // namespace kernel |
1035 } // namespace dart | 1083 } // namespace dart |
1036 | 1084 |
1037 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1085 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1038 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 1086 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
OLD | NEW |