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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 bool IsStackLocal() const { return location_ == LOCAL; } | 111 bool IsStackLocal() const { return location_ == LOCAL; } |
112 bool IsStackAllocated() const { return IsParameter() || IsStackLocal(); } | 112 bool IsStackAllocated() const { return IsParameter() || IsStackLocal(); } |
113 bool IsContextSlot() const { return location_ == CONTEXT; } | 113 bool IsContextSlot() const { return location_ == CONTEXT; } |
114 bool IsLookupSlot() const { return location_ == LOOKUP; } | 114 bool IsLookupSlot() const { return location_ == LOOKUP; } |
115 | 115 |
116 bool is_dynamic() const { | 116 bool is_dynamic() const { |
117 return (mode_ == DYNAMIC || | 117 return (mode_ == DYNAMIC || |
118 mode_ == DYNAMIC_GLOBAL || | 118 mode_ == DYNAMIC_GLOBAL || |
119 mode_ == DYNAMIC_LOCAL); | 119 mode_ == DYNAMIC_LOCAL); |
120 } | 120 } |
| 121 bool is_const_mode() const { |
| 122 return (mode_ == CONST || |
| 123 mode_ == CONST_HARMONY); |
| 124 } |
| 125 bool binding_needs_init() const { |
| 126 return (mode_ == LET || |
| 127 mode_ == CONST || |
| 128 mode_ == CONST_HARMONY); |
| 129 } |
121 | 130 |
122 bool is_global() const; | 131 bool is_global() const; |
123 bool is_this() const { return kind_ == THIS; } | 132 bool is_this() const { return kind_ == THIS; } |
124 bool is_arguments() const { return kind_ == ARGUMENTS; } | 133 bool is_arguments() const { return kind_ == ARGUMENTS; } |
125 | 134 |
126 // True if the variable is named eval and not known to be shadowed. | 135 // True if the variable is named eval and not known to be shadowed. |
127 bool is_possibly_eval() const { | 136 bool is_possibly_eval() const { |
128 return IsVariable(FACTORY->eval_symbol()) && | 137 return IsVariable(FACTORY->eval_symbol()) && |
129 (mode_ == DYNAMIC || mode_ == DYNAMIC_GLOBAL); | 138 (mode_ == DYNAMIC || mode_ == DYNAMIC_GLOBAL); |
130 } | 139 } |
(...skipping 16 matching lines...) Expand all Loading... |
147 } | 156 } |
148 | 157 |
149 private: | 158 private: |
150 Scope* scope_; | 159 Scope* scope_; |
151 Handle<String> name_; | 160 Handle<String> name_; |
152 VariableMode mode_; | 161 VariableMode mode_; |
153 Kind kind_; | 162 Kind kind_; |
154 Location location_; | 163 Location location_; |
155 int index_; | 164 int index_; |
156 | 165 |
| 166 // If this field is set, this variable references the stored locally bound |
| 167 // variable, but it might be shadowed by variable bindings introduced by |
| 168 // non-strict 'eval' calls between the reference scope (inclusive) and the |
| 169 // binding scope (exclusive). |
157 Variable* local_if_not_shadowed_; | 170 Variable* local_if_not_shadowed_; |
158 | 171 |
159 // Valid as a LHS? (const and this are not valid LHS, for example) | 172 // Valid as a LHS? (const and this are not valid LHS, for example) |
160 bool is_valid_LHS_; | 173 bool is_valid_LHS_; |
161 | 174 |
162 // Usage info. | 175 // Usage info. |
163 bool is_accessed_from_inner_scope_; // set by variable resolver | 176 bool is_accessed_from_inner_scope_; // set by variable resolver |
164 bool is_used_; | 177 bool is_used_; |
165 }; | 178 }; |
166 | 179 |
167 | 180 |
168 } } // namespace v8::internal | 181 } } // namespace v8::internal |
169 | 182 |
170 #endif // V8_VARIABLES_H_ | 183 #endif // V8_VARIABLES_H_ |
OLD | NEW |