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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 | 160 |
161 // --------------------------------------------------------------------------- | 161 // --------------------------------------------------------------------------- |
162 // Predicates. | 162 // Predicates. |
163 | 163 |
164 // Specific scope types. | 164 // Specific scope types. |
165 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } | 165 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } |
166 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } | 166 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } |
167 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } | 167 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } |
168 | 168 |
169 // Information about which scopes calls eval. | |
170 bool calls_eval() const { return scope_calls_eval_; } | |
171 bool outer_scope_calls_eval() const { return outer_scope_calls_eval_; } | |
172 | |
173 // The scope immediately surrounding this scope, or NULL. | 169 // The scope immediately surrounding this scope, or NULL. |
174 Scope* outer_scope() const { return outer_scope_; } | 170 Scope* outer_scope() const { return outer_scope_; } |
175 | 171 |
| 172 |
176 // --------------------------------------------------------------------------- | 173 // --------------------------------------------------------------------------- |
177 // Accessors. | 174 // Accessors. |
178 | 175 |
179 // The variable corresponding to the (function) receiver. | 176 // The variable corresponding to the (function) receiver. |
180 VariableProxy* receiver() const { return receiver_; } | 177 VariableProxy* receiver() const { return receiver_; } |
181 | 178 |
182 // The variable holding the function literal for named function | 179 // The variable holding the function literal for named function |
183 // literals, or NULL. | 180 // literals, or NULL. |
184 // Only valid for function scopes. | 181 // Only valid for function scopes. |
185 Variable* function() const { | 182 Variable* function() const { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Expression* illegal_redecl_; | 283 Expression* illegal_redecl_; |
287 | 284 |
288 // Scope-specific information. | 285 // Scope-specific information. |
289 bool scope_inside_with_; // this scope is inside a 'with' of some outer scope | 286 bool scope_inside_with_; // this scope is inside a 'with' of some outer scope |
290 bool scope_contains_with_; // this scope contains a 'with' statement | 287 bool scope_contains_with_; // this scope contains a 'with' statement |
291 bool scope_calls_eval_; // this scope contains an 'eval' call | 288 bool scope_calls_eval_; // this scope contains an 'eval' call |
292 | 289 |
293 // Computed via PropagateScopeInfo. | 290 // Computed via PropagateScopeInfo. |
294 bool outer_scope_calls_eval_; | 291 bool outer_scope_calls_eval_; |
295 bool inner_scope_calls_eval_; | 292 bool inner_scope_calls_eval_; |
296 bool outer_scope_is_eval_scope_; | |
297 bool force_eager_compilation_; | 293 bool force_eager_compilation_; |
298 | 294 |
299 // Computed via AllocateVariables; function scopes only. | 295 // Computed via AllocateVariables; function scopes only. |
300 int num_stack_slots_; | 296 int num_stack_slots_; |
301 int num_heap_slots_; | 297 int num_heap_slots_; |
302 | 298 |
303 // Create a non-local variable with a given name. | 299 // Create a non-local variable with a given name. |
304 // These variables are looked up dynamically at runtime. | 300 // These variables are looked up dynamically at runtime. |
305 Variable* NonLocal(Handle<String> name, Variable::Mode mode); | 301 Variable* NonLocal(Handle<String> name); |
306 | 302 |
307 // Variable resolution. | 303 // Variable resolution. |
308 Variable* LookupRecursive(Handle<String> name, | 304 Variable* LookupRecursive(Handle<String> name, bool inner_lookup); |
309 bool inner_lookup, | |
310 Variable** invalidated_local); | |
311 void ResolveVariable(Scope* global_scope, VariableProxy* proxy); | 305 void ResolveVariable(Scope* global_scope, VariableProxy* proxy); |
312 void ResolveVariablesRecursively(Scope* global_scope); | 306 void ResolveVariablesRecursively(Scope* global_scope); |
313 | 307 |
314 // Scope analysis. | 308 // Scope analysis. |
315 bool PropagateScopeInfo(bool outer_scope_calls_eval, | 309 bool PropagateScopeInfo(bool outer_scope_calls_eval); |
316 bool outer_scope_is_eval_scope); | |
317 bool HasTrivialContext() const; | 310 bool HasTrivialContext() const; |
318 | 311 |
319 // Predicates. | 312 // Predicates. |
320 bool MustAllocate(Variable* var); | 313 bool MustAllocate(Variable* var); |
321 bool MustAllocateInContext(Variable* var); | 314 bool MustAllocateInContext(Variable* var); |
322 bool HasArgumentsParameter(); | 315 bool HasArgumentsParameter(); |
323 | 316 |
324 // Variable allocation. | 317 // Variable allocation. |
325 void AllocateStackSlot(Variable* var); | 318 void AllocateStackSlot(Variable* var); |
326 void AllocateHeapSlot(Variable* var); | 319 void AllocateHeapSlot(Variable* var); |
(...skipping 17 matching lines...) Expand all Loading... |
344 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { | 337 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { |
345 return NULL; | 338 return NULL; |
346 } | 339 } |
347 virtual VariableProxy* NewTemporary(Handle<String> name) { return NULL; } | 340 virtual VariableProxy* NewTemporary(Handle<String> name) { return NULL; } |
348 }; | 341 }; |
349 | 342 |
350 | 343 |
351 } } // namespace v8::internal | 344 } } // namespace v8::internal |
352 | 345 |
353 #endif // V8_SCOPES_H_ | 346 #endif // V8_SCOPES_H_ |
OLD | NEW |