| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 169 // Information about which scopes calls eval. |
| 170 bool calls_eval() const { return scope_calls_eval_; } | 170 bool calls_eval() const { return scope_calls_eval_; } |
| 171 bool outer_scope_calls_eval() const { return outer_scope_calls_eval_; } | 171 bool outer_scope_calls_eval() const { return outer_scope_calls_eval_; } |
| 172 | 172 |
| 173 // Is this scope inside a with statement. |
| 174 bool inside_with() const { return scope_inside_with_; } |
| 175 // Does this scope contain a with statement. |
| 176 bool contains_with() const { return scope_contains_with_; } |
| 177 |
| 173 // The scope immediately surrounding this scope, or NULL. | 178 // The scope immediately surrounding this scope, or NULL. |
| 174 Scope* outer_scope() const { return outer_scope_; } | 179 Scope* outer_scope() const { return outer_scope_; } |
| 175 | 180 |
| 176 // --------------------------------------------------------------------------- | 181 // --------------------------------------------------------------------------- |
| 177 // Accessors. | 182 // Accessors. |
| 178 | 183 |
| 179 // The variable corresponding to the (function) receiver. | 184 // The variable corresponding to the (function) receiver. |
| 180 VariableProxy* receiver() const { return receiver_; } | 185 VariableProxy* receiver() const { return receiver_; } |
| 181 | 186 |
| 182 // The variable holding the function literal for named function | 187 // The variable holding the function literal for named function |
| (...skipping 26 matching lines...) Expand all Loading... |
| 209 | 214 |
| 210 | 215 |
| 211 | 216 |
| 212 // --------------------------------------------------------------------------- | 217 // --------------------------------------------------------------------------- |
| 213 // Variable allocation. | 218 // Variable allocation. |
| 214 | 219 |
| 215 // Collect all used locals in this scope. | 220 // Collect all used locals in this scope. |
| 216 template<class Allocator> | 221 template<class Allocator> |
| 217 void CollectUsedVariables(List<Variable*, Allocator>* locals); | 222 void CollectUsedVariables(List<Variable*, Allocator>* locals); |
| 218 | 223 |
| 219 // Resolve and fill in the allocation information for all variables in | 224 // Resolve and fill in the allocation information for all variables |
| 220 // this scopes. Must be called *after* all scopes have been processed | 225 // in this scopes. Must be called *after* all scopes have been |
| 221 // (parsed) to ensure that unresolved variables can be resolved properly. | 226 // processed (parsed) to ensure that unresolved variables can be |
| 222 void AllocateVariables(); | 227 // resolved properly. |
| 228 // |
| 229 // In the case of code compiled and run using 'eval', the context |
| 230 // parameter is the context in which eval was called. In all other |
| 231 // cases the context parameter is an empty handle. |
| 232 void AllocateVariables(Handle<Context> context); |
| 223 | 233 |
| 224 // Result of variable allocation. | 234 // Result of variable allocation. |
| 225 int num_stack_slots() const { return num_stack_slots_; } | 235 int num_stack_slots() const { return num_stack_slots_; } |
| 226 int num_heap_slots() const { return num_heap_slots_; } | 236 int num_heap_slots() const { return num_heap_slots_; } |
| 227 | 237 |
| 228 // Make sure this scope and all outer scopes are eagerly compiled. | 238 // Make sure this scope and all outer scopes are eagerly compiled. |
| 229 void ForceEagerCompilation() { force_eager_compilation_ = true; } | 239 void ForceEagerCompilation() { force_eager_compilation_ = true; } |
| 230 | 240 |
| 231 // Determine if we can use lazy compilation for this scope. | 241 // Determine if we can use lazy compilation for this scope. |
| 232 bool AllowsLazyCompilation() const; | 242 bool AllowsLazyCompilation() const; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 int num_heap_slots_; | 311 int num_heap_slots_; |
| 302 | 312 |
| 303 // Create a non-local variable with a given name. | 313 // Create a non-local variable with a given name. |
| 304 // These variables are looked up dynamically at runtime. | 314 // These variables are looked up dynamically at runtime. |
| 305 Variable* NonLocal(Handle<String> name, Variable::Mode mode); | 315 Variable* NonLocal(Handle<String> name, Variable::Mode mode); |
| 306 | 316 |
| 307 // Variable resolution. | 317 // Variable resolution. |
| 308 Variable* LookupRecursive(Handle<String> name, | 318 Variable* LookupRecursive(Handle<String> name, |
| 309 bool inner_lookup, | 319 bool inner_lookup, |
| 310 Variable** invalidated_local); | 320 Variable** invalidated_local); |
| 311 void ResolveVariable(Scope* global_scope, VariableProxy* proxy); | 321 void ResolveVariable(Scope* global_scope, |
| 312 void ResolveVariablesRecursively(Scope* global_scope); | 322 Handle<Context> context, |
| 323 VariableProxy* proxy); |
| 324 void ResolveVariablesRecursively(Scope* global_scope, |
| 325 Handle<Context> context); |
| 313 | 326 |
| 314 // Scope analysis. | 327 // Scope analysis. |
| 315 bool PropagateScopeInfo(bool outer_scope_calls_eval, | 328 bool PropagateScopeInfo(bool outer_scope_calls_eval, |
| 316 bool outer_scope_is_eval_scope); | 329 bool outer_scope_is_eval_scope); |
| 317 bool HasTrivialContext() const; | 330 bool HasTrivialContext() const; |
| 318 | 331 |
| 319 // Predicates. | 332 // Predicates. |
| 320 bool MustAllocate(Variable* var); | 333 bool MustAllocate(Variable* var); |
| 321 bool MustAllocateInContext(Variable* var); | 334 bool MustAllocateInContext(Variable* var); |
| 322 bool HasArgumentsParameter(); | 335 bool HasArgumentsParameter(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 344 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { | 357 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { |
| 345 return NULL; | 358 return NULL; |
| 346 } | 359 } |
| 347 virtual VariableProxy* NewTemporary(Handle<String> name) { return NULL; } | 360 virtual VariableProxy* NewTemporary(Handle<String> name) { return NULL; } |
| 348 }; | 361 }; |
| 349 | 362 |
| 350 | 363 |
| 351 } } // namespace v8::internal | 364 } } // namespace v8::internal |
| 352 | 365 |
| 353 #endif // V8_SCOPES_H_ | 366 #endif // V8_SCOPES_H_ |
| OLD | NEW |