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