| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; | 63 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; |
| 64 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; | 64 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; |
| 65 case INTERNAL: return "INTERNAL"; | 65 case INTERNAL: return "INTERNAL"; |
| 66 case TEMPORARY: return "TEMPORARY"; | 66 case TEMPORARY: return "TEMPORARY"; |
| 67 } | 67 } |
| 68 UNREACHABLE(); | 68 UNREACHABLE(); |
| 69 return NULL; | 69 return NULL; |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 Property* Variable::AsProperty() { | 73 Property* Variable::AsProperty() const { |
| 74 return rewrite_ == NULL ? NULL : rewrite_->AsProperty(); | 74 return rewrite_ == NULL ? NULL : rewrite_->AsProperty(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 Variable* Variable::AsVariable() { | 78 Slot* Variable::AsSlot() const { |
| 79 return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL; | 79 return rewrite_ == NULL ? NULL : rewrite_->AsSlot(); |
| 80 } | |
| 81 | |
| 82 | |
| 83 Slot* Variable::slot() const { | |
| 84 return rewrite_ != NULL ? rewrite_->AsSlot() : NULL; | |
| 85 } | 80 } |
| 86 | 81 |
| 87 | 82 |
| 88 bool Variable::IsStackAllocated() const { | 83 bool Variable::IsStackAllocated() const { |
| 89 Slot* s = slot(); | 84 Slot* slot = AsSlot(); |
| 90 return s != NULL && s->IsStackAllocated(); | 85 return slot != NULL && slot->IsStackAllocated(); |
| 91 } | 86 } |
| 92 | 87 |
| 93 | 88 |
| 94 Variable::Variable(Scope* scope, | 89 Variable::Variable(Scope* scope, |
| 95 Handle<String> name, | 90 Handle<String> name, |
| 96 Mode mode, | 91 Mode mode, |
| 97 bool is_valid_LHS, | 92 bool is_valid_LHS, |
| 98 Kind kind) | 93 Kind kind) |
| 99 : scope_(scope), | 94 : scope_(scope), |
| 100 name_(name), | 95 name_(name), |
| 101 mode_(mode), | 96 mode_(mode), |
| 102 is_valid_LHS_(is_valid_LHS), | 97 is_valid_LHS_(is_valid_LHS), |
| 103 kind_(kind), | 98 kind_(kind), |
| 104 local_if_not_shadowed_(NULL), | 99 local_if_not_shadowed_(NULL), |
| 105 is_accessed_from_inner_scope_(false), | 100 is_accessed_from_inner_scope_(false), |
| 106 is_used_(false), | 101 is_used_(false), |
| 107 rewrite_(NULL) { | 102 rewrite_(NULL) { |
| 108 // names must be canonicalized for fast equality checks | 103 // names must be canonicalized for fast equality checks |
| 109 ASSERT(name->IsSymbol()); | 104 ASSERT(name->IsSymbol()); |
| 110 } | 105 } |
| 111 | 106 |
| 112 | 107 |
| 113 bool Variable::is_global() const { | 108 bool Variable::is_global() const { |
| 114 // Temporaries are never global, they must always be allocated in the | 109 // Temporaries are never global, they must always be allocated in the |
| 115 // activation frame. | 110 // activation frame. |
| 116 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); | 111 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); |
| 117 } | 112 } |
| 118 | 113 |
| 119 } } // namespace v8::internal | 114 } } // namespace v8::internal |
| OLD | NEW |