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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 bool scope_calls_eval_; // this scope contains an 'eval' call | 357 bool scope_calls_eval_; // this scope contains an 'eval' call |
358 bool strict_mode_; // this scope is a strict mode scope | 358 bool strict_mode_; // this scope is a strict mode scope |
359 | 359 |
360 // Computed via PropagateScopeInfo. | 360 // Computed via PropagateScopeInfo. |
361 bool outer_scope_calls_eval_; | 361 bool outer_scope_calls_eval_; |
362 bool outer_scope_calls_non_strict_eval_; | 362 bool outer_scope_calls_non_strict_eval_; |
363 bool inner_scope_calls_eval_; | 363 bool inner_scope_calls_eval_; |
364 bool outer_scope_is_eval_scope_; | 364 bool outer_scope_is_eval_scope_; |
365 bool force_eager_compilation_; | 365 bool force_eager_compilation_; |
366 | 366 |
| 367 // True if it doesn't need scope resolution (e.g., if the scope was |
| 368 // constructed based on a serialized scope info or a catch context). |
| 369 bool already_resolved_; |
| 370 |
367 // Computed as variables are declared. | 371 // Computed as variables are declared. |
368 int num_var_or_const_; | 372 int num_var_or_const_; |
369 | 373 |
370 // Computed via AllocateVariables; function scopes only. | 374 // Computed via AllocateVariables; function scopes only. |
371 int num_stack_slots_; | 375 int num_stack_slots_; |
372 int num_heap_slots_; | 376 int num_heap_slots_; |
373 | 377 |
374 // Serialized scopes support. | 378 // Serialized scopes support. |
375 Handle<SerializedScopeInfo> scope_info_; | 379 Handle<SerializedScopeInfo> scope_info_; |
376 bool resolved() { return !scope_info_.is_null(); } | 380 bool already_resolved() { return already_resolved_; } |
377 | 381 |
378 // Create a non-local variable with a given name. | 382 // Create a non-local variable with a given name. |
379 // These variables are looked up dynamically at runtime. | 383 // These variables are looked up dynamically at runtime. |
380 Variable* NonLocal(Handle<String> name, Variable::Mode mode); | 384 Variable* NonLocal(Handle<String> name, Variable::Mode mode); |
381 | 385 |
382 // Variable resolution. | 386 // Variable resolution. |
383 Variable* LookupRecursive(Handle<String> name, | 387 Variable* LookupRecursive(Handle<String> name, |
384 bool inner_lookup, | 388 bool inner_lookup, |
385 Variable** invalidated_local); | 389 Variable** invalidated_local); |
386 void ResolveVariable(Scope* global_scope, | 390 void ResolveVariable(Scope* global_scope, |
(...skipping 15 matching lines...) Expand all Loading... |
402 | 406 |
403 // Variable allocation. | 407 // Variable allocation. |
404 void AllocateStackSlot(Variable* var); | 408 void AllocateStackSlot(Variable* var); |
405 void AllocateHeapSlot(Variable* var); | 409 void AllocateHeapSlot(Variable* var); |
406 void AllocateParameterLocals(); | 410 void AllocateParameterLocals(); |
407 void AllocateNonParameterLocal(Variable* var); | 411 void AllocateNonParameterLocal(Variable* var); |
408 void AllocateNonParameterLocals(); | 412 void AllocateNonParameterLocals(); |
409 void AllocateVariablesRecursively(); | 413 void AllocateVariablesRecursively(); |
410 | 414 |
411 private: | 415 private: |
| 416 // Construct a function scope based on the scope info. |
412 Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info); | 417 Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info); |
413 | 418 |
| 419 // Construct a catch scope with a binding for the name. |
| 420 Scope(Scope* inner_scope, Handle<String> catch_variable_name); |
| 421 |
414 void AddInnerScope(Scope* inner_scope) { | 422 void AddInnerScope(Scope* inner_scope) { |
415 if (inner_scope != NULL) { | 423 if (inner_scope != NULL) { |
416 inner_scopes_.Add(inner_scope); | 424 inner_scopes_.Add(inner_scope); |
417 inner_scope->outer_scope_ = this; | 425 inner_scope->outer_scope_ = this; |
418 } | 426 } |
419 } | 427 } |
420 | 428 |
421 void SetDefaults(Type type, | 429 void SetDefaults(Type type, |
422 Scope* outer_scope, | 430 Scope* outer_scope, |
423 Handle<SerializedScopeInfo> scope_info); | 431 Handle<SerializedScopeInfo> scope_info); |
424 }; | 432 }; |
425 | 433 |
426 } } // namespace v8::internal | 434 } } // namespace v8::internal |
427 | 435 |
428 #endif // V8_SCOPES_H_ | 436 #endif // V8_SCOPES_H_ |
OLD | NEW |