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 #include "vm/symbols.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 class BitVector; | 15 class BitVector; |
16 class JoinEntryInstr; | 16 class JoinEntryInstr; |
17 class LocalScope; | 17 class LocalScope; |
18 class LocalVariable; | 18 class LocalVariable; |
19 class SourceLabel; | 19 class SourceLabel; |
20 | 20 |
21 | 21 |
22 class LocalVariable : public ZoneAllocated { | 22 class LocalVariable : public ZoneAllocated { |
23 public: | 23 public: |
24 LocalVariable(intptr_t token_pos, | 24 LocalVariable(intptr_t token_pos, |
25 const String& name, | 25 const String& name, |
26 const AbstractType& type) | 26 const AbstractType& type) |
27 : token_pos_(token_pos), | 27 : token_pos_(token_pos), |
28 name_(name), | 28 name_(name), |
29 owner_(NULL), | 29 owner_(NULL), |
30 type_(type), | 30 type_(&type), |
regis
2013/10/22 23:17:20
Why change this now? We usually do not store a poi
hausner
2013/10/22 23:22:18
Because I have to change the type of a variable af
| |
31 const_value_(NULL), | 31 const_value_(NULL), |
32 is_final_(false), | 32 is_final_(false), |
33 is_captured_(false), | 33 is_captured_(false), |
34 is_invisible_(false), | 34 is_invisible_(false), |
35 index_(LocalVariable::kUninitializedIndex) { | 35 index_(LocalVariable::kUninitializedIndex) { |
36 ASSERT(type.IsZoneHandle()); | 36 ASSERT(type.IsZoneHandle()); |
37 ASSERT(type.IsFinalized()); | 37 ASSERT(type.IsFinalized()); |
38 } | 38 } |
39 | 39 |
40 intptr_t token_pos() const { return token_pos_; } | 40 intptr_t token_pos() const { return token_pos_; } |
41 const String& name() const { return name_; } | 41 const String& name() const { return name_; } |
42 LocalScope* owner() const { return owner_; } | 42 LocalScope* owner() const { return owner_; } |
43 void set_owner(LocalScope* owner) { | 43 void set_owner(LocalScope* owner) { |
44 ASSERT(owner_ == NULL); | 44 ASSERT(owner_ == NULL); |
45 owner_ = owner; | 45 owner_ = owner; |
46 } | 46 } |
47 | 47 |
48 const AbstractType& type() const { return type_; } | 48 const AbstractType& type() const { return *type_; } |
49 void set_type(const AbstractType& value) { | |
50 ASSERT(value.IsZoneHandle()); | |
51 type_ = &value; | |
52 } | |
49 | 53 |
50 bool is_final() const { return is_final_; } | 54 bool is_final() const { return is_final_; } |
51 void set_is_final() { is_final_ = true; } | 55 void set_is_final() { is_final_ = true; } |
52 | 56 |
53 bool is_captured() const { return is_captured_; } | 57 bool is_captured() const { return is_captured_; } |
54 void set_is_captured() { is_captured_ = true; } | 58 void set_is_captured() { is_captured_ = true; } |
55 | 59 |
56 bool HasIndex() const { | 60 bool HasIndex() const { |
57 return index_ != kUninitializedIndex; | 61 return index_ != kUninitializedIndex; |
58 } | 62 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 // all parameters. | 98 // all parameters. |
95 int BitIndexIn(intptr_t var_count) const; | 99 int BitIndexIn(intptr_t var_count) const; |
96 | 100 |
97 private: | 101 private: |
98 static const int kUninitializedIndex = INT_MIN; | 102 static const int kUninitializedIndex = INT_MIN; |
99 | 103 |
100 const intptr_t token_pos_; | 104 const intptr_t token_pos_; |
101 const String& name_; | 105 const String& name_; |
102 LocalScope* owner_; // Local scope declaring this variable. | 106 LocalScope* owner_; // Local scope declaring this variable. |
103 | 107 |
104 const AbstractType& type_; // Declaration type of local variable. | 108 const AbstractType* type_; // Declaration type of local variable. |
105 | 109 |
106 const Instance* const_value_; // NULL or compile-time const value. | 110 const Instance* const_value_; // NULL or compile-time const value. |
107 | 111 |
108 bool is_final_; // If true, this variable is readonly. | 112 bool is_final_; // If true, this variable is readonly. |
109 bool is_captured_; // If true, this variable lives in the context, otherwise | 113 bool is_captured_; // If true, this variable lives in the context, otherwise |
110 // in the stack frame. | 114 // in the stack frame. |
111 bool is_invisible_; | 115 bool is_invisible_; |
112 int index_; // Allocation index in words relative to frame pointer (if not | 116 int index_; // Allocation index in words relative to frame pointer (if not |
113 // captured), or relative to the context pointer (if captured). | 117 // captured), or relative to the context pointer (if captured). |
114 | 118 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 intptr_t end_token_pos_; // Token index of end of scope. | 370 intptr_t end_token_pos_; // Token index of end of scope. |
367 GrowableArray<LocalVariable*> variables_; | 371 GrowableArray<LocalVariable*> variables_; |
368 GrowableArray<SourceLabel*> labels_; | 372 GrowableArray<SourceLabel*> labels_; |
369 | 373 |
370 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 374 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
371 }; | 375 }; |
372 | 376 |
373 } // namespace dart | 377 } // namespace dart |
374 | 378 |
375 #endif // VM_SCOPES_H_ | 379 #endif // VM_SCOPES_H_ |
OLD | NEW |