| 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 index_(LocalVariable::kUninitializedIndex) { | 38 index_(LocalVariable::kUninitializedIndex) { |
| 37 ASSERT(type.IsZoneHandle() || type.IsReadOnlyHandle()); | 39 ASSERT(type.IsZoneHandle() || type.IsReadOnlyHandle()); |
| 38 ASSERT(type.IsFinalized()); | 40 ASSERT(type.IsFinalized()); |
| 39 ASSERT(name.IsSymbol()); | 41 ASSERT(name.IsSymbol()); |
| 40 } | 42 } |
| 41 | 43 |
| 42 TokenPosition token_pos() const { return token_pos_; } | 44 TokenPosition token_pos() const { return token_pos_; } |
| 45 TokenPosition declaration_token_pos() const { return declaration_pos_; } |
| 43 const String& name() const { return name_; } | 46 const String& name() const { return name_; } |
| 44 LocalScope* owner() const { return owner_; } | 47 LocalScope* owner() const { return owner_; } |
| 45 void set_owner(LocalScope* owner) { | 48 void set_owner(LocalScope* owner) { |
| 46 ASSERT(owner_ == NULL); | 49 ASSERT(owner_ == NULL); |
| 47 owner_ = owner; | 50 owner_ = owner; |
| 48 } | 51 } |
| 49 | 52 |
| 50 const AbstractType& type() const { return type_; } | 53 const AbstractType& type() const { return type_; } |
| 51 | 54 |
| 52 bool is_final() const { return is_final_; } | 55 bool is_final() const { return is_final_; } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 105 |
| 103 // Map the frame index to a bit-vector index. Assumes the variable is | 106 // Map the frame index to a bit-vector index. Assumes the variable is |
| 104 // allocated to the frame. | 107 // allocated to the frame. |
| 105 // var_count is the total number of stack-allocated variables including | 108 // var_count is the total number of stack-allocated variables including |
| 106 // all parameters. | 109 // all parameters. |
| 107 int BitIndexIn(intptr_t var_count) const; | 110 int BitIndexIn(intptr_t var_count) const; |
| 108 | 111 |
| 109 private: | 112 private: |
| 110 static const int kUninitializedIndex = INT_MIN; | 113 static const int kUninitializedIndex = INT_MIN; |
| 111 | 114 |
| 115 const TokenPosition declaration_pos_; |
| 112 const TokenPosition token_pos_; | 116 const TokenPosition token_pos_; |
| 113 const String& name_; | 117 const String& name_; |
| 114 LocalScope* owner_; // Local scope declaring this variable. | 118 LocalScope* owner_; // Local scope declaring this variable. |
| 115 | 119 |
| 116 const AbstractType& type_; // Declaration type of local variable. | 120 const AbstractType& type_; // Declaration type of local variable. |
| 117 | 121 |
| 118 const Instance* const_value_; // NULL or compile-time const value. | 122 const Instance* const_value_; // NULL or compile-time const value. |
| 119 | 123 |
| 120 bool is_final_; // If true, this variable is readonly. | 124 bool is_final_; // If true, this variable is readonly. |
| 121 bool is_captured_; // If true, this variable lives in the context, otherwise | 125 bool is_captured_; // If true, this variable lives in the context, otherwise |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // List of names referenced in this scope and its children that | 382 // List of names referenced in this scope and its children that |
| 379 // are not resolved to local variables. | 383 // are not resolved to local variables. |
| 380 GrowableArray<NameReference*> referenced_; | 384 GrowableArray<NameReference*> referenced_; |
| 381 | 385 |
| 382 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 386 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 383 }; | 387 }; |
| 384 | 388 |
| 385 } // namespace dart | 389 } // namespace dart |
| 386 | 390 |
| 387 #endif // VM_SCOPES_H_ | 391 #endif // VM_SCOPES_H_ |
| OLD | NEW |