OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 VM_SCOPES_H_ | 5 #ifndef VM_SCOPES_H_ |
6 #define VM_SCOPES_H_ | 6 #define VM_SCOPES_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| 11 #include "vm/symbols.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 class BitVector; | 15 class BitVector; |
15 class JoinEntryInstr; | 16 class JoinEntryInstr; |
16 class LocalScope; | 17 class LocalScope; |
17 class LocalVariable; | 18 class LocalVariable; |
18 class SourceLabel; | 19 class SourceLabel; |
19 | 20 |
20 | 21 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 72 } |
72 | 73 |
73 bool Equals(const LocalVariable& other) const; | 74 bool Equals(const LocalVariable& other) const; |
74 | 75 |
75 // Map the frame index to a bit-vector index. Assumes the variable is | 76 // Map the frame index to a bit-vector index. Assumes the variable is |
76 // allocated to the frame. | 77 // allocated to the frame. |
77 // var_count is the total number of stack-allocated variables including | 78 // var_count is the total number of stack-allocated variables including |
78 // all parameters. | 79 // all parameters. |
79 int BitIndexIn(intptr_t var_count) const; | 80 int BitIndexIn(intptr_t var_count) const; |
80 | 81 |
81 // Name of the internal variable that is used to save the context chain | |
82 // on function entry. | |
83 static const char* kSavedContextVarName; | |
84 | |
85 private: | 82 private: |
86 static const int kUnitializedIndex = INT_MIN; | 83 static const int kUnitializedIndex = INT_MIN; |
87 | 84 |
88 const intptr_t token_pos_; | 85 const intptr_t token_pos_; |
89 const String& name_; | 86 const String& name_; |
90 LocalScope* owner_; // Local scope declaring this variable. | 87 LocalScope* owner_; // Local scope declaring this variable. |
91 | 88 |
92 const AbstractType& type_; // Declaration type of local variable. | 89 const AbstractType& type_; // Declaration type of local variable. |
93 | 90 |
94 bool is_final_; // If true, this variable is readonly. | 91 bool is_final_; // If true, this variable is readonly. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 join_for_break_(NULL), | 124 join_for_break_(NULL), |
128 join_for_continue_(NULL), | 125 join_for_continue_(NULL), |
129 is_continue_target_(false) { | 126 is_continue_target_(false) { |
130 } | 127 } |
131 | 128 |
132 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { | 129 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { |
133 if (name != NULL) { | 130 if (name != NULL) { |
134 return new SourceLabel(token_pos, *name, kind); | 131 return new SourceLabel(token_pos, *name, kind); |
135 } else { | 132 } else { |
136 return new SourceLabel(token_pos, | 133 return new SourceLabel(token_pos, |
137 String::ZoneHandle(String::New(kDefaultLabelName)), | 134 String::ZoneHandle(Symbols::DefaultLabel()), |
138 kind); | 135 kind); |
139 } | 136 } |
140 } | 137 } |
141 | 138 |
142 intptr_t token_pos() const { return token_pos_; } | 139 intptr_t token_pos() const { return token_pos_; } |
143 const String& name() const { return name_; } | 140 const String& name() const { return name_; } |
144 LocalScope* owner() const { return owner_; } | 141 LocalScope* owner() const { return owner_; } |
145 void set_owner(LocalScope* owner) { | 142 void set_owner(LocalScope* owner) { |
146 ASSERT(owner_ == NULL); | 143 ASSERT(owner_ == NULL); |
147 owner_ = owner; | 144 owner_ = owner; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const intptr_t token_pos_; | 178 const intptr_t token_pos_; |
182 const String& name_; | 179 const String& name_; |
183 LocalScope* owner_; // Local scope declaring this label. | 180 LocalScope* owner_; // Local scope declaring this label. |
184 | 181 |
185 Kind kind_; | 182 Kind kind_; |
186 Label continue_label_; | 183 Label continue_label_; |
187 Label break_label_; | 184 Label break_label_; |
188 JoinEntryInstr* join_for_break_; | 185 JoinEntryInstr* join_for_break_; |
189 JoinEntryInstr* join_for_continue_; | 186 JoinEntryInstr* join_for_continue_; |
190 bool is_continue_target_; // Needed for CaseNode. | 187 bool is_continue_target_; // Needed for CaseNode. |
191 static const char* kDefaultLabelName; | |
192 | 188 |
193 DISALLOW_COPY_AND_ASSIGN(SourceLabel); | 189 DISALLOW_COPY_AND_ASSIGN(SourceLabel); |
194 }; | 190 }; |
195 | 191 |
196 | 192 |
197 class LocalScope : public ZoneAllocated { | 193 class LocalScope : public ZoneAllocated { |
198 public: | 194 public: |
199 LocalScope(LocalScope* parent, int function_level, int loop_level); | 195 LocalScope(LocalScope* parent, int function_level, int loop_level); |
200 | 196 |
201 LocalScope* parent() const { return parent_; } | 197 LocalScope* parent() const { return parent_; } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 intptr_t end_token_pos_; // Token index of end of scope. | 340 intptr_t end_token_pos_; // Token index of end of scope. |
345 GrowableArray<LocalVariable*> variables_; | 341 GrowableArray<LocalVariable*> variables_; |
346 GrowableArray<SourceLabel*> labels_; | 342 GrowableArray<SourceLabel*> labels_; |
347 | 343 |
348 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 344 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
349 }; | 345 }; |
350 | 346 |
351 } // namespace dart | 347 } // namespace dart |
352 | 348 |
353 #endif // VM_SCOPES_H_ | 349 #endif // VM_SCOPES_H_ |
OLD | NEW |