| 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 "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| 11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/raw_object.h" | 13 #include "vm/raw_object.h" |
| 14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 #include "vm/token.h" | 15 #include "vm/token.h" |
| 16 | 16 |
| 17 namespace dart { | 17 namespace dart { |
| 18 | 18 |
| 19 class LocalScope; | 19 class LocalScope; |
| 20 | 20 |
| 21 | 21 |
| 22 class LocalVariable : public ZoneAllocated { | 22 class LocalVariable : public ZoneAllocated { |
| 23 public: | 23 public: |
| 24 LocalVariable(TokenPosition token_pos, | 24 LocalVariable(TokenPosition declaration_pos, |
| 25 TokenPosition token_pos, |
| 25 const String& name, | 26 const String& name, |
| 26 const AbstractType& type) | 27 const AbstractType& type) |
| 27 : token_pos_(token_pos), | 28 : declaration_pos_(declaration_pos), |
| 29 token_pos_(token_pos), |
| 28 name_(name), | 30 name_(name), |
| 29 owner_(NULL), | 31 owner_(NULL), |
| 30 type_(type), | 32 type_(type), |
| 31 const_value_(NULL), | 33 const_value_(NULL), |
| 32 is_final_(false), | 34 is_final_(false), |
| 33 is_captured_(false), | 35 is_captured_(false), |
| 34 is_invisible_(false), | 36 is_invisible_(false), |
| 35 is_captured_parameter_(false), | 37 is_captured_parameter_(false), |
| 36 is_forced_stack_(false), | 38 is_forced_stack_(false), |
| 37 index_(LocalVariable::kUninitializedIndex) { | 39 index_(LocalVariable::kUninitializedIndex) { |
| 38 ASSERT(type.IsZoneHandle() || type.IsReadOnlyHandle()); | 40 ASSERT(type.IsZoneHandle() || type.IsReadOnlyHandle()); |
| 39 ASSERT(type.IsFinalized()); | 41 ASSERT(type.IsFinalized()); |
| 40 ASSERT(name.IsSymbol()); | 42 ASSERT(name.IsSymbol()); |
| 41 } | 43 } |
| 42 | 44 |
| 43 TokenPosition token_pos() const { return token_pos_; } | 45 TokenPosition token_pos() const { return token_pos_; } |
| 46 TokenPosition declaration_token_pos() const { return declaration_pos_; } |
| 44 const String& name() const { return name_; } | 47 const String& name() const { return name_; } |
| 45 LocalScope* owner() const { return owner_; } | 48 LocalScope* owner() const { return owner_; } |
| 46 void set_owner(LocalScope* owner) { | 49 void set_owner(LocalScope* owner) { |
| 47 ASSERT(owner_ == NULL); | 50 ASSERT(owner_ == NULL); |
| 48 owner_ = owner; | 51 owner_ = owner; |
| 49 } | 52 } |
| 50 | 53 |
| 51 const AbstractType& type() const { return type_; } | 54 const AbstractType& type() const { return type_; } |
| 52 | 55 |
| 53 bool is_final() const { return is_final_; } | 56 bool is_final() const { return is_final_; } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 113 |
| 111 // Map the frame index to a bit-vector index. Assumes the variable is | 114 // Map the frame index to a bit-vector index. Assumes the variable is |
| 112 // allocated to the frame. | 115 // allocated to the frame. |
| 113 // var_count is the total number of stack-allocated variables including | 116 // var_count is the total number of stack-allocated variables including |
| 114 // all parameters. | 117 // all parameters. |
| 115 int BitIndexIn(intptr_t var_count) const; | 118 int BitIndexIn(intptr_t var_count) const; |
| 116 | 119 |
| 117 private: | 120 private: |
| 118 static const int kUninitializedIndex = INT_MIN; | 121 static const int kUninitializedIndex = INT_MIN; |
| 119 | 122 |
| 123 const TokenPosition declaration_pos_; |
| 120 const TokenPosition token_pos_; | 124 const TokenPosition token_pos_; |
| 121 const String& name_; | 125 const String& name_; |
| 122 LocalScope* owner_; // Local scope declaring this variable. | 126 LocalScope* owner_; // Local scope declaring this variable. |
| 123 | 127 |
| 124 const AbstractType& type_; // Declaration type of local variable. | 128 const AbstractType& type_; // Declaration type of local variable. |
| 125 | 129 |
| 126 const Instance* const_value_; // NULL or compile-time const value. | 130 const Instance* const_value_; // NULL or compile-time const value. |
| 127 | 131 |
| 128 bool is_final_; // If true, this variable is readonly. | 132 bool is_final_; // If true, this variable is readonly. |
| 129 bool is_captured_; // If true, this variable lives in the context, otherwise | 133 bool is_captured_; // If true, this variable lives in the context, otherwise |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // List of names referenced in this scope and its children that | 391 // List of names referenced in this scope and its children that |
| 388 // are not resolved to local variables. | 392 // are not resolved to local variables. |
| 389 GrowableArray<NameReference*> referenced_; | 393 GrowableArray<NameReference*> referenced_; |
| 390 | 394 |
| 391 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 395 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 392 }; | 396 }; |
| 393 | 397 |
| 394 } // namespace dart | 398 } // namespace dart |
| 395 | 399 |
| 396 #endif // VM_SCOPES_H_ | 400 #endif // VM_SCOPES_H_ |
| OLD | NEW |