| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; | 46 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; |
| 47 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; | 47 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; |
| 48 case INTERNAL: return "INTERNAL"; | 48 case INTERNAL: return "INTERNAL"; |
| 49 case TEMPORARY: return "TEMPORARY"; | 49 case TEMPORARY: return "TEMPORARY"; |
| 50 } | 50 } |
| 51 UNREACHABLE(); | 51 UNREACHABLE(); |
| 52 return NULL; | 52 return NULL; |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 Property* Variable::AsProperty() const { | |
| 57 return rewrite_ == NULL ? NULL : rewrite_->AsProperty(); | |
| 58 } | |
| 59 | |
| 60 | |
| 61 Slot* Variable::AsSlot() const { return rewrite_; } | |
| 62 | |
| 63 | |
| 64 bool Variable::IsStackAllocated() const { | |
| 65 return rewrite_ != NULL && rewrite_->IsStackAllocated(); | |
| 66 } | |
| 67 | |
| 68 | |
| 69 bool Variable::IsParameter() const { | |
| 70 return rewrite_ != NULL && rewrite_->type() == Slot::PARAMETER; | |
| 71 } | |
| 72 | |
| 73 | |
| 74 bool Variable::IsStackLocal() const { | |
| 75 return rewrite_ != NULL && rewrite_->type() == Slot::LOCAL; | |
| 76 } | |
| 77 | |
| 78 | |
| 79 bool Variable::IsContextSlot() const { | |
| 80 return rewrite_ != NULL && rewrite_->type() == Slot::CONTEXT; | |
| 81 } | |
| 82 | |
| 83 | |
| 84 Variable::Variable(Scope* scope, | 56 Variable::Variable(Scope* scope, |
| 85 Handle<String> name, | 57 Handle<String> name, |
| 86 Mode mode, | 58 Mode mode, |
| 87 bool is_valid_LHS, | 59 bool is_valid_LHS, |
| 88 Kind kind) | 60 Kind kind) |
| 89 : scope_(scope), | 61 : scope_(scope), |
| 90 name_(name), | 62 name_(name), |
| 91 mode_(mode), | 63 mode_(mode), |
| 92 kind_(kind), | 64 kind_(kind), |
| 65 location_(UNALLOCATED), |
| 66 index_(-1), |
| 93 local_if_not_shadowed_(NULL), | 67 local_if_not_shadowed_(NULL), |
| 94 rewrite_(NULL), | |
| 95 is_valid_LHS_(is_valid_LHS), | 68 is_valid_LHS_(is_valid_LHS), |
| 96 is_accessed_from_inner_function_scope_(false), | 69 is_accessed_from_inner_function_scope_(false), |
| 97 is_used_(false) { | 70 is_used_(false) { |
| 98 // names must be canonicalized for fast equality checks | 71 // names must be canonicalized for fast equality checks |
| 99 ASSERT(name->IsSymbol()); | 72 ASSERT(name->IsSymbol()); |
| 100 } | 73 } |
| 101 | 74 |
| 102 | 75 |
| 103 bool Variable::is_global() const { | 76 bool Variable::is_global() const { |
| 104 // Temporaries are never global, they must always be allocated in the | 77 // Temporaries are never global, they must always be allocated in the |
| 105 // activation frame. | 78 // activation frame. |
| 106 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); | 79 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); |
| 107 } | 80 } |
| 108 | 81 |
| 109 } } // namespace v8::internal | 82 } } // namespace v8::internal |
| OLD | NEW |