| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 bool outer_scope_calls_eval_; | 363 bool outer_scope_calls_eval_; |
| 364 bool inner_scope_calls_eval_; | 364 bool inner_scope_calls_eval_; |
| 365 bool outer_scope_is_eval_scope_; | 365 bool outer_scope_is_eval_scope_; |
| 366 bool force_eager_compilation_; | 366 bool force_eager_compilation_; |
| 367 | 367 |
| 368 // Computed via AllocateVariables; function scopes only. | 368 // Computed via AllocateVariables; function scopes only. |
| 369 int num_stack_slots_; | 369 int num_stack_slots_; |
| 370 int num_heap_slots_; | 370 int num_heap_slots_; |
| 371 | 371 |
| 372 // Serialized scopes support. | 372 // Serialized scopes support. |
| 373 SerializedScopeInfo* scope_info_; | 373 Handle<SerializedScopeInfo> scope_info_; |
| 374 bool resolved() { return scope_info_ != NULL; } | 374 bool resolved() { return !scope_info_.is_null(); } |
| 375 | 375 |
| 376 // Create a non-local variable with a given name. | 376 // Create a non-local variable with a given name. |
| 377 // These variables are looked up dynamically at runtime. | 377 // These variables are looked up dynamically at runtime. |
| 378 Variable* NonLocal(Handle<String> name, Variable::Mode mode); | 378 Variable* NonLocal(Handle<String> name, Variable::Mode mode); |
| 379 | 379 |
| 380 // Variable resolution. | 380 // Variable resolution. |
| 381 Variable* LookupRecursive(Handle<String> name, | 381 Variable* LookupRecursive(Handle<String> name, |
| 382 bool inner_lookup, | 382 bool inner_lookup, |
| 383 Variable** invalidated_local); | 383 Variable** invalidated_local); |
| 384 void ResolveVariable(Scope* global_scope, | 384 void ResolveVariable(Scope* global_scope, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 399 | 399 |
| 400 // Variable allocation. | 400 // Variable allocation. |
| 401 void AllocateStackSlot(Variable* var); | 401 void AllocateStackSlot(Variable* var); |
| 402 void AllocateHeapSlot(Variable* var); | 402 void AllocateHeapSlot(Variable* var); |
| 403 void AllocateParameterLocals(); | 403 void AllocateParameterLocals(); |
| 404 void AllocateNonParameterLocal(Variable* var); | 404 void AllocateNonParameterLocal(Variable* var); |
| 405 void AllocateNonParameterLocals(); | 405 void AllocateNonParameterLocals(); |
| 406 void AllocateVariablesRecursively(); | 406 void AllocateVariablesRecursively(); |
| 407 | 407 |
| 408 private: | 408 private: |
| 409 Scope(Scope* inner_scope, SerializedScopeInfo* scope_info); | 409 Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info); |
| 410 | 410 |
| 411 void AddInnerScope(Scope* inner_scope) { | 411 void AddInnerScope(Scope* inner_scope) { |
| 412 if (inner_scope != NULL) { | 412 if (inner_scope != NULL) { |
| 413 inner_scopes_.Add(inner_scope); | 413 inner_scopes_.Add(inner_scope); |
| 414 inner_scope->outer_scope_ = this; | 414 inner_scope->outer_scope_ = this; |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 void SetDefaults(Type type, | 418 void SetDefaults(Type type, |
| 419 Scope* outer_scope, | 419 Scope* outer_scope, |
| 420 SerializedScopeInfo* scope_info) { | 420 Handle<SerializedScopeInfo> scope_info); |
| 421 outer_scope_ = outer_scope; | |
| 422 type_ = type; | |
| 423 scope_name_ = Factory::empty_symbol(); | |
| 424 dynamics_ = NULL; | |
| 425 receiver_ = NULL; | |
| 426 function_ = NULL; | |
| 427 arguments_ = NULL; | |
| 428 arguments_shadow_ = NULL; | |
| 429 illegal_redecl_ = NULL; | |
| 430 scope_inside_with_ = false; | |
| 431 scope_contains_with_ = false; | |
| 432 scope_calls_eval_ = false; | |
| 433 outer_scope_calls_eval_ = false; | |
| 434 inner_scope_calls_eval_ = false; | |
| 435 outer_scope_is_eval_scope_ = false; | |
| 436 force_eager_compilation_ = false; | |
| 437 num_stack_slots_ = 0; | |
| 438 num_heap_slots_ = 0; | |
| 439 scope_info_ = scope_info; | |
| 440 } | |
| 441 }; | 421 }; |
| 442 | 422 |
| 443 | 423 |
| 444 // Scope used during pre-parsing. | 424 // Scope used during pre-parsing. |
| 445 class DummyScope : public Scope { | 425 class DummyScope : public Scope { |
| 446 public: | 426 public: |
| 447 DummyScope() | 427 DummyScope() |
| 448 : Scope(GLOBAL_SCOPE), | 428 : Scope(GLOBAL_SCOPE), |
| 449 nesting_level_(1), // Allows us to Leave the initial scope. | 429 nesting_level_(1), // Allows us to Leave the initial scope. |
| 450 inside_with_level_(kNotInsideWith) { | 430 inside_with_level_(kNotInsideWith) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 int nesting_level_; | 467 int nesting_level_; |
| 488 // Nesting level of outermost scope that is contained in a with statement, | 468 // Nesting level of outermost scope that is contained in a with statement, |
| 489 // or kNotInsideWith if there are no with's around the current scope. | 469 // or kNotInsideWith if there are no with's around the current scope. |
| 490 int inside_with_level_; | 470 int inside_with_level_; |
| 491 }; | 471 }; |
| 492 | 472 |
| 493 | 473 |
| 494 } } // namespace v8::internal | 474 } } // namespace v8::internal |
| 495 | 475 |
| 496 #endif // V8_SCOPES_H_ | 476 #endif // V8_SCOPES_H_ |
| OLD | NEW |