| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // in an outer scope about which we don't know anything (it may not | 131 // in an outer scope about which we don't know anything (it may not |
| 132 // be the global scope). scope() is NULL in that case. Currently the | 132 // be the global scope). scope() is NULL in that case. Currently the |
| 133 // scope is only used to follow the context chain length. | 133 // scope is only used to follow the context chain length. |
| 134 Scope* scope() const { return scope_; } | 134 Scope* scope() const { return scope_; } |
| 135 | 135 |
| 136 Handle<String> name() const { return name_; } | 136 Handle<String> name() const { return name_; } |
| 137 Mode mode() const { return mode_; } | 137 Mode mode() const { return mode_; } |
| 138 bool is_accessed_from_inner_scope() const { | 138 bool is_accessed_from_inner_scope() const { |
| 139 return is_accessed_from_inner_scope_; | 139 return is_accessed_from_inner_scope_; |
| 140 } | 140 } |
| 141 void MarkAsAccessedFromInnerScope() { |
| 142 is_accessed_from_inner_scope_ = true; |
| 143 } |
| 141 bool is_used() { return is_used_; } | 144 bool is_used() { return is_used_; } |
| 142 void set_is_used(bool flag) { is_used_ = flag; } | 145 void set_is_used(bool flag) { is_used_ = flag; } |
| 143 | 146 |
| 144 bool IsVariable(Handle<String> n) const { | 147 bool IsVariable(Handle<String> n) const { |
| 145 return !is_this() && name().is_identical_to(n); | 148 return !is_this() && name().is_identical_to(n); |
| 146 } | 149 } |
| 147 | 150 |
| 148 bool IsStackAllocated() const; | 151 bool IsStackAllocated() const; |
| 149 bool IsParameter() const; // Includes 'this'. | 152 bool IsParameter() const; // Includes 'this'. |
| 150 bool IsStackLocal() const; | 153 bool IsStackLocal() const; |
| 154 bool IsContextSlot() const; |
| 151 | 155 |
| 152 bool is_dynamic() const { | 156 bool is_dynamic() const { |
| 153 return (mode_ == DYNAMIC || | 157 return (mode_ == DYNAMIC || |
| 154 mode_ == DYNAMIC_GLOBAL || | 158 mode_ == DYNAMIC_GLOBAL || |
| 155 mode_ == DYNAMIC_LOCAL); | 159 mode_ == DYNAMIC_LOCAL); |
| 156 } | 160 } |
| 157 | 161 |
| 158 bool is_global() const; | 162 bool is_global() const; |
| 159 bool is_this() const { return kind_ == THIS; } | 163 bool is_this() const { return kind_ == THIS; } |
| 160 bool is_arguments() const { return kind_ == ARGUMENTS; } | 164 bool is_arguments() const { return kind_ == ARGUMENTS; } |
| 161 | 165 |
| 162 // True if the variable is named eval and not known to be shadowed. | 166 // True if the variable is named eval and not known to be shadowed. |
| 163 bool is_possibly_eval() const { | 167 bool is_possibly_eval() const { |
| 164 return IsVariable(Factory::eval_symbol()) && | 168 return IsVariable(Factory::eval_symbol()) && |
| 165 (mode_ == DYNAMIC || mode_ == DYNAMIC_GLOBAL); | 169 (mode_ == DYNAMIC || mode_ == DYNAMIC_GLOBAL); |
| 166 } | 170 } |
| 167 | 171 |
| 168 Variable* local_if_not_shadowed() const { | 172 Variable* local_if_not_shadowed() const { |
| 169 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL); | 173 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL); |
| 170 return local_if_not_shadowed_; | 174 return local_if_not_shadowed_; |
| 171 } | 175 } |
| 172 | 176 |
| 173 void set_local_if_not_shadowed(Variable* local) { | 177 void set_local_if_not_shadowed(Variable* local) { |
| 174 local_if_not_shadowed_ = local; | 178 local_if_not_shadowed_ = local; |
| 175 } | 179 } |
| 176 | 180 |
| 177 Expression* rewrite() const { return rewrite_; } | 181 Expression* rewrite() const { return rewrite_; } |
| 182 void set_rewrite(Expression* expr) { rewrite_ = expr; } |
| 178 | 183 |
| 179 StaticType* type() { return &type_; } | 184 StaticType* type() { return &type_; } |
| 180 | 185 |
| 181 private: | 186 private: |
| 182 Scope* scope_; | 187 Scope* scope_; |
| 183 Handle<String> name_; | 188 Handle<String> name_; |
| 184 Mode mode_; | 189 Mode mode_; |
| 185 bool is_valid_LHS_; | 190 bool is_valid_LHS_; |
| 186 Kind kind_; | 191 Kind kind_; |
| 187 | 192 |
| 188 Variable* local_if_not_shadowed_; | 193 Variable* local_if_not_shadowed_; |
| 189 | 194 |
| 190 // Usage info. | 195 // Usage info. |
| 191 bool is_accessed_from_inner_scope_; // set by variable resolver | 196 bool is_accessed_from_inner_scope_; // set by variable resolver |
| 192 bool is_used_; | 197 bool is_used_; |
| 193 | 198 |
| 194 // Static type information | 199 // Static type information |
| 195 StaticType type_; | 200 StaticType type_; |
| 196 | 201 |
| 197 // Code generation. | 202 // Code generation. |
| 198 // rewrite_ is usually a Slot or a Property, but may be any expression. | 203 // rewrite_ is usually a Slot or a Property, but may be any expression. |
| 199 Expression* rewrite_; | 204 Expression* rewrite_; |
| 200 | |
| 201 friend class Scope; // Has explicit access to rewrite_. | |
| 202 }; | 205 }; |
| 203 | 206 |
| 204 | 207 |
| 205 } } // namespace v8::internal | 208 } } // namespace v8::internal |
| 206 | 209 |
| 207 #endif // V8_VARIABLES_H_ | 210 #endif // V8_VARIABLES_H_ |
| OLD | NEW |